Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1alpha1/cdapmaster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ type SecurityContext struct {
// FSGroup mounts volumes as the specified group ID and gives the primary user access
// to that group. It is applied at the pod level.
FSGroup *int64 `json:"fsGroup,omitempty"`
// FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
// before being mounted. Refer to official Kubernetes docs.
// +kubebuilder:validation:Enum=Always;OnRootMismatch
FSGroupChangePolicy *corev1.PodFSGroupChangePolicy `json:"fsGroupChangePolicy,omitempty"`
// AllowPrivilegeEscalation prevents the container process from running SUID binaries.
// It is applied at the container level.
AllowPrivilegeEscalation *bool `json:"allowPrivilegeEscalation,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 128 additions & 0 deletions config/crd/bases/cdap.cdap.io_cdapmasters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4380,6 +4380,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -7214,6 +7222,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -10047,6 +10063,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -12884,6 +12908,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -15845,6 +15877,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -18677,6 +18717,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -21510,6 +21558,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -24331,6 +24387,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -28525,6 +28589,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -31369,6 +31441,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -34206,6 +34286,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -34305,6 +34393,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -37097,6 +37193,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -39933,6 +40037,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -42766,6 +42878,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down Expand Up @@ -45610,6 +45730,14 @@ spec:
to that group. It is applied at the pod level.
format: int64
type: integer
fsGroupChangePolicy:
description: |-
FSGroupChangePolicy defines behavior of changing ownership and permission of the volume
before being mounted. Refer to official Kubernetes docs.
enum:
- Always
- OnRootMismatch
type: string
privileged:
description: |-
Privileged runs container in privileged mode. It is applied at the container level.
Expand Down
26 changes: 1 addition & 25 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
Expand All @@ -34,6 +21,7 @@ rules:
- apps
resources:
- deployments
- statefulsets
verbs:
- create
- delete
Expand All @@ -50,18 +38,6 @@ rules:
- get
- patch
- update
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- batch
resources:
Expand Down
8 changes: 8 additions & 0 deletions controllers/testdata/cdap_master_cr.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@
"memory": "100Mi"
}
},
"securityContext": {
"runAsUser": 1000,
"runAsGroup": 1000,
"fsGroup": 2000,
"fsGroupChangePolicy": "OnRootMismatch",
"runAsNonRoot": true,
"allowPrivilegeEscalation": false
},
"storageSize": "100Gi"
},
"messaging": {
Expand Down
1 change: 1 addition & 0 deletions controllers/testdata/logs.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"schedulerName": "default-scheduler",
"securityContext": {
"fsGroup": 2000,
"fsGroupChangePolicy": "OnRootMismatch",
"runAsGroup": 1000,
"runAsUser": 1000,
"runAsNonRoot": true
Expand Down
3 changes: 3 additions & 0 deletions templates/cdap-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ spec:
{{if .Base.SecurityContext.FSGroup}}
fsGroup: {{.Base.SecurityContext.FSGroup}}
{{end}}
{{if .Base.SecurityContext.FSGroupChangePolicy}}
fsGroupChangePolicy: {{.Base.SecurityContext.FSGroupChangePolicy}}
{{end}}
# For boolean pointers, we always set the value and ensure there is a default set for nil values.
runAsNonRoot: {{.Base.SecurityContext.RunAsNonRoot}}
{{end}}
Expand Down
3 changes: 3 additions & 0 deletions templates/cdap-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ spec:
{{if .Base.SecurityContext.FSGroup}}
fsGroup: {{.Base.SecurityContext.FSGroup}}
{{end}}
{{if .Base.SecurityContext.FSGroupChangePolicy}}
fsGroupChangePolicy: {{.Base.SecurityContext.FSGroupChangePolicy}}
{{end}}
# For boolean pointers, we always set the value and ensure there is a default set for nil values.
runAsNonRoot: {{.Base.SecurityContext.RunAsNonRoot}}
{{end}}
Expand Down