Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/node-labeler/role.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 wsmanager
6
7
import (
8
"github.com/gitpod-io/gitpod/installer/pkg/common"
9
10
rbacv1 "k8s.io/api/rbac/v1"
11
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
"k8s.io/apimachinery/pkg/runtime"
13
)
14
15
func role(ctx *common.RenderContext) ([]runtime.Object, error) {
16
labels := common.DefaultLabels(Component)
17
18
return []runtime.Object{
19
&rbacv1.ClusterRole{
20
TypeMeta: common.TypeMetaClusterRole,
21
ObjectMeta: metav1.ObjectMeta{
22
Name: Component,
23
Namespace: ctx.Namespace,
24
Labels: labels,
25
},
26
Rules: []rbacv1.PolicyRule{
27
{
28
APIGroups: []string{""},
29
Resources: []string{
30
"nodes",
31
},
32
Verbs: []string{
33
"get",
34
"list",
35
"watch",
36
"update",
37
"patch",
38
},
39
},
40
{
41
APIGroups: []string{""},
42
Resources: []string{
43
"pods",
44
},
45
Verbs: []string{
46
"get",
47
"list",
48
"watch",
49
},
50
},
51
// permissions required for the WorkspaceCountController
52
{
53
APIGroups: []string{"workspace.gitpod.io"},
54
Resources: []string{"workspaces"},
55
Verbs: []string{
56
"get",
57
"list",
58
"watch",
59
},
60
},
61
// ConfigMap, Leases, and Events access is required for leader-election.
62
{
63
APIGroups: []string{""},
64
Resources: []string{"configmaps"},
65
Verbs: []string{
66
"create",
67
"delete",
68
"get",
69
"list",
70
"patch",
71
"update",
72
"watch",
73
},
74
},
75
{
76
APIGroups: []string{"coordination.k8s.io"},
77
Resources: []string{"leases"},
78
Verbs: []string{
79
"create",
80
"delete",
81
"get",
82
"list",
83
"patch",
84
"update",
85
"watch",
86
},
87
},
88
{
89
APIGroups: []string{""},
90
Resources: []string{"events"},
91
Verbs: []string{
92
"create",
93
"patch",
94
},
95
},
96
},
97
},
98
}, nil
99
}
100
101