Skip to content

Commit bcfbe27

Browse files
author
Simon Emms
committed
[installer]: add pod security policy to the telemetry cronjob
1 parent 7d9a4da commit bcfbe27

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

installer/pkg/components/gitpod/objects.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ var Objects = common.CompositeRenderFunc(
1010
configmap,
1111
cronjob,
1212
common.DefaultServiceAccount(Component),
13+
rolebinding,
1314
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2022 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 gitpod
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+
labels := common.DefaultLabels(Component)
19+
20+
return []runtime.Object{
21+
&rbacv1.RoleBinding{
22+
TypeMeta: common.TypeMetaRoleBinding,
23+
ObjectMeta: metav1.ObjectMeta{
24+
Name: Component,
25+
Namespace: ctx.Namespace,
26+
Labels: labels,
27+
},
28+
RoleRef: rbacv1.RoleRef{
29+
Kind: "ClusterRole",
30+
Name: fmt.Sprintf("%s-ns-psp:restricted-root-user", ctx.Namespace),
31+
APIGroup: "rbac.authorization.k8s.io",
32+
},
33+
Subjects: []rbacv1.Subject{{
34+
Kind: "ServiceAccount",
35+
Name: Component,
36+
}},
37+
},
38+
}, nil
39+
}

0 commit comments

Comments
 (0)