Path: blob/main/install/installer/pkg/components/ws-daemon/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 wsdaemon56import (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)1819bindings := []runtime.Object{20&rbacv1.ClusterRoleBinding{21TypeMeta: common.TypeMetaClusterRoleBinding,22ObjectMeta: metav1.ObjectMeta{23Name: fmt.Sprintf("%s-%s-rb-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.ClusterRoleBinding{40TypeMeta: common.TypeMetaClusterRoleBinding,41ObjectMeta: metav1.ObjectMeta{42Name: fmt.Sprintf("%s-%s-rb", ctx.Namespace, Component),43Labels: labels,44},45RoleRef: rbacv1.RoleRef{46Kind: "ClusterRole",47Name: fmt.Sprintf("%s-ns-%s", ctx.Namespace, Component),48APIGroup: "rbac.authorization.k8s.io",49},50Subjects: []rbacv1.Subject{{51Kind: "ServiceAccount",52Name: Component,53Namespace: ctx.Namespace,54}},55},56&rbacv1.RoleBinding{57TypeMeta: common.TypeMetaRoleBinding,58ObjectMeta: metav1.ObjectMeta{59Name: Component,60Namespace: common.WorkspaceSecretsNamespace,61},62RoleRef: rbacv1.RoleRef{63APIGroup: "rbac.authorization.k8s.io",64Kind: "Role",65Name: Component,66},67Subjects: []rbacv1.Subject{68{69Kind: "ServiceAccount",70Name: Component,71Namespace: ctx.Namespace,72},73},74},75}7677return bindings, nil78}798081