Path: blob/main/install/installer/pkg/components/registry-facade/rolebinding.go
2506 views
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package registryfacade56import (7"fmt"89"github.com/gitpod-io/gitpod/installer/pkg/common"1011rbacv1 "k8s.io/api/rbac/v1"12metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"13"k8s.io/apimachinery/pkg/runtime"14)1516func rolebinding(ctx *common.RenderContext) ([]runtime.Object, error) {17labels := common.DefaultLabels(Component)1819return []runtime.Object{20&rbacv1.ClusterRoleBinding{21TypeMeta: common.TypeMetaClusterRoleBinding,22ObjectMeta: metav1.ObjectMeta{23Name: fmt.Sprintf("%s-%s-rb", ctx.Namespace, Component),24Labels: labels,25},26RoleRef: rbacv1.RoleRef{27Kind: "ClusterRole",28Name: fmt.Sprintf("%s-ns-%s", ctx.Namespace, Component),29APIGroup: "rbac.authorization.k8s.io",30},31Subjects: []rbacv1.Subject{{32Kind: "ServiceAccount",33Name: Component,34Namespace: ctx.Namespace,35}},36},37&rbacv1.ClusterRoleBinding{38TypeMeta: common.TypeMetaClusterRoleBinding,39ObjectMeta: metav1.ObjectMeta{40Name: fmt.Sprintf("%s-%s-kube-rbac-proxy", ctx.Namespace, Component),41Labels: labels,42},43RoleRef: rbacv1.RoleRef{44Kind: "ClusterRole",45Name: fmt.Sprintf("%s-kube-rbac-proxy", ctx.Namespace),46APIGroup: "rbac.authorization.k8s.io",47},48Subjects: []rbacv1.Subject{{49Kind: "ServiceAccount",50Name: Component,51Namespace: ctx.Namespace,52}},53},54}, nil55}565758