Path: blob/main/install/installer/pkg/components/ws-proxy/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 wsproxy56import (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) {17return []runtime.Object{18&rbacv1.ClusterRoleBinding{19TypeMeta: common.TypeMetaClusterRoleBinding,20ObjectMeta: metav1.ObjectMeta{21Name: fmt.Sprintf("%s-%s-kube-rbac-proxy", ctx.Namespace, Component),22Labels: common.DefaultLabels(Component),23},24RoleRef: rbacv1.RoleRef{25Kind: "ClusterRole",26Name: fmt.Sprintf("%s-kube-rbac-proxy", ctx.Namespace),27APIGroup: "rbac.authorization.k8s.io",28},29Subjects: []rbacv1.Subject{30{31Kind: "ServiceAccount",32Name: Component,33Namespace: ctx.Namespace,34},35},36},37&rbacv1.RoleBinding{38TypeMeta: common.TypeMetaRoleBinding,39ObjectMeta: metav1.ObjectMeta{40Name: Component,41Namespace: ctx.Namespace,42Labels: common.DefaultLabels(Component),43},44RoleRef: rbacv1.RoleRef{45Kind: "ClusterRole",46Name: fmt.Sprintf("%s-ns-psp:unprivileged", ctx.Namespace),47APIGroup: "rbac.authorization.k8s.io",48},49Subjects: []rbacv1.Subject{{50Kind: "ServiceAccount",51Name: Component,52}},53},54&rbacv1.RoleBinding{55TypeMeta: common.TypeMetaRoleBinding,56ObjectMeta: metav1.ObjectMeta{57Name: Component + "-api",58Namespace: ctx.Namespace,59Labels: common.DefaultLabels(Component),60},61RoleRef: rbacv1.RoleRef{62Kind: "Role",63Name: Component,64APIGroup: "rbac.authorization.k8s.io",65},66Subjects: []rbacv1.Subject{{67Kind: "ServiceAccount",68Name: Component,69}},70},71}, nil72}737475