Skip to content
Merged
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 @@ -331,6 +331,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.

36,161 changes: 17,474 additions & 18,687 deletions config/crd/bases/cdap.cdap.io_cdapmasters.yaml

Large diffs are not rendered by default.

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
Comment on lines 12 to 13

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The RBAC permissions for 'configmaps' and 'services' have been severely restricted to only 'create'. The operator requires full CRUD capabilities ('get', 'list', 'watch', 'create', 'update', 'patch', 'delete') for both resources to function properly (e.g., in 'ConfigMapHandler' and 'ServiceHandler'). This change will cause the operator to fail during reconciliation.

  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is combining configmaps and services into a single rule block containing all verbs; the other CRUD verbs are still in the file but hidden from the diff as unchanged context.

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 @@ -188,6 +188,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