Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/content-service/rolebinding.go
2501 views
1
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package content_service
6
7
import (
8
"fmt"
9
10
"github.com/gitpod-io/gitpod/installer/pkg/common"
11
12
rbacv1 "k8s.io/api/rbac/v1"
13
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
"k8s.io/apimachinery/pkg/runtime"
15
)
16
17
func rolebinding(ctx *common.RenderContext) ([]runtime.Object, error) {
18
return []runtime.Object{&rbacv1.RoleBinding{
19
TypeMeta: common.TypeMetaRoleBinding,
20
ObjectMeta: metav1.ObjectMeta{
21
Name: Component,
22
Namespace: ctx.Namespace,
23
Labels: common.DefaultLabels(Component),
24
},
25
RoleRef: rbacv1.RoleRef{
26
Kind: "ClusterRole",
27
Name: fmt.Sprintf("%s-ns-psp:restricted-root-user", ctx.Namespace),
28
APIGroup: "rbac.authorization.k8s.io",
29
},
30
Subjects: []rbacv1.Subject{{
31
Kind: "ServiceAccount",
32
Name: Component,
33
}},
34
}, &rbacv1.ClusterRoleBinding{
35
TypeMeta: common.TypeMetaClusterRoleBinding,
36
ObjectMeta: metav1.ObjectMeta{
37
Name: fmt.Sprintf("%s-%s-rb-kube-rbac-proxy", ctx.Namespace, Component),
38
Labels: common.DefaultLabels(Component),
39
},
40
RoleRef: rbacv1.RoleRef{
41
Kind: "ClusterRole",
42
Name: fmt.Sprintf("%s-kube-rbac-proxy", ctx.Namespace),
43
APIGroup: "rbac.authorization.k8s.io",
44
},
45
Subjects: []rbacv1.Subject{
46
{
47
Kind: "ServiceAccount",
48
Name: Component,
49
Namespace: ctx.Namespace,
50
},
51
},
52
},
53
}, nil
54
}
55
56