Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/ws-daemon/clusterrole.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 wsdaemon
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 clusterrole(ctx *common.RenderContext) ([]runtime.Object, error) {
18
labels := common.DefaultLabels(Component)
19
20
return []runtime.Object{
21
&rbacv1.ClusterRole{
22
TypeMeta: common.TypeMetaClusterRole,
23
ObjectMeta: metav1.ObjectMeta{
24
Name: fmt.Sprintf("%s-ns-%s", ctx.Namespace, Component),
25
Labels: labels,
26
},
27
Rules: []rbacv1.PolicyRule{
28
{
29
APIGroups: []string{""},
30
Resources: []string{"nodes"},
31
Verbs: []string{"get", "list", "update", "patch"},
32
},
33
{
34
APIGroups: []string{""},
35
Resources: []string{"pods", "services"},
36
Verbs: []string{"get", "list", "watch"},
37
},
38
{
39
APIGroups: []string{""},
40
Resources: []string{"pods"},
41
Verbs: []string{"delete", "update", "patch"},
42
},
43
{
44
APIGroups: []string{"workspace.gitpod.io"},
45
Resources: []string{"workspaces"},
46
Verbs: []string{
47
"get",
48
"list",
49
"watch",
50
},
51
},
52
{
53
APIGroups: []string{"workspace.gitpod.io"},
54
Resources: []string{"workspaces/status"},
55
Verbs: []string{
56
"get",
57
"patch",
58
"update",
59
},
60
},
61
{
62
APIGroups: []string{"workspace.gitpod.io"},
63
Resources: []string{"snapshots"},
64
Verbs: []string{
65
"get",
66
"list",
67
"watch",
68
},
69
},
70
{
71
APIGroups: []string{"workspace.gitpod.io"},
72
Resources: []string{"snapshots/status"},
73
Verbs: []string{
74
"get",
75
"patch",
76
"update",
77
},
78
},
79
{
80
APIGroups: []string{""},
81
Resources: []string{"events"},
82
Verbs: []string{
83
"create",
84
"patch",
85
},
86
},
87
},
88
},
89
}, nil
90
}
91
92