Orange-OpenSource / casskop

This Kubernetes operator automates the Cassandra operations such as deploying a new rack aware cluster, adding/removing nodes, configuring the C* and JVM parameters, upgrading JVM and C* versions, and many more...
https://orange-opensource.github.io/casskop/
Apache License 2.0
183 stars 54 forks source link

Unable to deploy CassandraCluster if PodSecurityPolicy prevents fsGroup 1 #309

Closed armingerten closed 3 years ago

armingerten commented 3 years ago

Bug Report

What did you do? I deployed an instance of cassandraclusters.db.orange.com while having a PodSecurityPolicy that prevents fsGroups < 1000.

Relevant section of the PodSecurityPolicy:

apiVersion: policy/v1beta1
kind: PodSecurityPolicy
spec:
  fsGroup:
    rule: MustRunAs
    ranges:
    - min: 1000
      max: 65536

What did you expect to see? The StatefulSet created by the operator should start-up.

What did you see instead? Under which circumstances? Pod's within the StatefulSet were unschedulable.

Output of kubectl describe sts cassandra-dev-dc-rack1:

Warning FailedCreate 16m (x22 over 60m) statefulset-controller create Pod cassandra-dev-dc-rack1-0 in StatefulSet cassandra-dev-dc-rack1 failed error: pods "cassandra-dev-dc-rack1-0" is forbidden: unable to validate against any pod security policy: [spec.securityContext.fsGroup: Invalid value: []int64{1}: group 1 must be in the ranges: [{1000 65536}] spec.containers[0].securityContext.capabilities.add: Invalid value: "IPC_LOCK": capability may not be added]

Environment

Possible Solution The CRD & controller could be enhanced to allow the configuration of arbitrary FSGroups (analogous to the runAsUser option):

Controller:

SecurityContext: &v1.PodSecurityContext{
    RunAsUser:    cc.Spec.RunAsUser,
    RunAsNonRoot: func(b bool) *bool { return &b }(true),
    FSGroup:      cc.Spec.FSGroup,
},

CRD in Helm Chart

cscetbon commented 3 years ago

@armingerten thanks for the report. Would you mind creating a PR ? I can guide you if needed.

armingerten commented 3 years ago

Sure - I'll create a PR, soon. 👍

I was wondering: