Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/docker-registry/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 dockerregistry
6
7
import (
8
"fmt"
9
"github.com/gitpod-io/gitpod/installer/pkg/common"
10
rbacv1 "k8s.io/api/rbac/v1"
11
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
"k8s.io/apimachinery/pkg/runtime"
13
"k8s.io/utils/pointer"
14
)
15
16
func rolebinding(ctx *common.RenderContext) ([]runtime.Object, error) {
17
if !pointer.BoolDeref(ctx.Config.ContainerRegistry.InCluster, false) {
18
return nil, nil
19
}
20
21
return []runtime.Object{
22
&rbacv1.RoleBinding{
23
TypeMeta: common.TypeMetaRoleBinding,
24
ObjectMeta: metav1.ObjectMeta{
25
Name: Component,
26
Namespace: ctx.Namespace,
27
Labels: common.DefaultLabels(Component),
28
},
29
RoleRef: rbacv1.RoleRef{
30
Kind: "ClusterRole",
31
Name: fmt.Sprintf("%s-ns-psp:restricted-root-user", ctx.Namespace),
32
APIGroup: "rbac.authorization.k8s.io",
33
},
34
Subjects: []rbacv1.Subject{
35
{
36
Kind: "ServiceAccount",
37
Name: Component,
38
},
39
},
40
},
41
}, nil
42
}
43
44