-
Notifications
You must be signed in to change notification settings - Fork 88
/
shared_object_config.go
46 lines (40 loc) · 1.07 KB
/
shared_object_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package kotsadm
import (
"github.com/replicatedhq/kots/pkg/util"
corev1 "k8s.io/api/core/v1"
)
func boolPointer(boolValue bool) *bool {
return &boolValue
}
func securePodContext(user int64, isStrict bool) *corev1.PodSecurityContext {
var context corev1.PodSecurityContext
if isStrict {
context = corev1.PodSecurityContext{
RunAsNonRoot: boolPointer(true),
RunAsUser: &user,
RunAsGroup: &user,
FSGroup: &user,
SupplementalGroups: []int64{user},
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
}
} else {
context = corev1.PodSecurityContext{
RunAsUser: util.IntPointer(int(user)),
FSGroup: util.IntPointer(int(user)),
}
}
return &context
}
func secureContainerContext(isStrict bool) *corev1.SecurityContext {
var context *corev1.SecurityContext
if isStrict {
context = &corev1.SecurityContext{
Privileged: boolPointer(false),
AllowPrivilegeEscalation: boolPointer(false),
ReadOnlyRootFilesystem: boolPointer(true),
}
}
return context
}