Path: blob/main/install/installer/pkg/components/ws-manager-mk2/rolebinding.go
2501 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 wsmanagermk256import (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-kube-rbac-proxy", ctx.Namespace, Component),24Labels: labels,25},26RoleRef: rbacv1.RoleRef{27Kind: "ClusterRole",28Name: fmt.Sprintf("%s-kube-rbac-proxy", ctx.Namespace),29APIGroup: "rbac.authorization.k8s.io",30},31Subjects: []rbacv1.Subject{32{33Kind: "ServiceAccount",34Name: Component,35Namespace: ctx.Namespace,36},37},38},39&rbacv1.RoleBinding{40TypeMeta: common.TypeMetaRoleBinding,41ObjectMeta: metav1.ObjectMeta{42Name: Component,43Namespace: ctx.Namespace,44Labels: labels,45},46RoleRef: rbacv1.RoleRef{47APIGroup: "rbac.authorization.k8s.io",48Kind: "Role",49Name: Component,50},51Subjects: []rbacv1.Subject{52{53Kind: "ServiceAccount",54Name: Component,55Namespace: ctx.Namespace,56},57},58},5960&rbacv1.RoleBinding{61TypeMeta: common.TypeMetaRoleBinding,62ObjectMeta: metav1.ObjectMeta{63Name: Component,64Namespace: common.WorkspaceSecretsNamespace,65Labels: labels,66},67RoleRef: rbacv1.RoleRef{68APIGroup: "rbac.authorization.k8s.io",69Kind: "Role",70Name: Component,71},72Subjects: []rbacv1.Subject{73{74Kind: "ServiceAccount",75Name: Component,76Namespace: ctx.Namespace,77},78},79},8081&rbacv1.ClusterRoleBinding{82TypeMeta: common.TypeMetaClusterRoleBinding,83ObjectMeta: metav1.ObjectMeta{84Name: Component,85Labels: labels,86},87RoleRef: rbacv1.RoleRef{88Kind: "ClusterRole",89Name: Component,90APIGroup: "rbac.authorization.k8s.io",91},92Subjects: []rbacv1.Subject{93{94Kind: "ServiceAccount",95Name: Component,96Namespace: ctx.Namespace,97},98},99},100}, nil101}102103104