dragonflydb / dragonfly-operator

A Kubernetes operator to install and manage Dragonfly instances.
https://www.dragonflydb.io/docs/managing-dragonfly/operator/installation
Apache License 2.0
144 stars 34 forks source link

Set containerSecurityContext for the dragonfly custom resource #231

Open geckiss opened 3 months ago

geckiss commented 3 months ago

Hello,

Right now the dragonfly crd doesn't seem to support setting any containerSecurityContext. Some environments require containers to run under non-root user. Helm chart already supports this - https://github.com/dragonflydb/dragonfly/blob/1f36c9952dd5537fb004d408ffebc977bc4cce8b/contrib/charts/dragonfly/values.yaml#L42 Would it be possible to add this please? It would be a nice addition together with https://github.com/dragonflydb/dragonfly-operator/issues/229

So we can create something like this:

apiVersion: dragonflydb.io/v1alpha1
kind: Dragonfly
metadata:
  labels:
    app.kubernetes.io/name: dragonfly-sample
    app.kubernetes.io/instance: dragonfly
    app.kubernetes.io/part-of: dragonfly-operator
    app.kubernetes.io/managed-by: helm
    app.kubernetes.io/created-by: dragonfly-operator
  name: dragonfly-sample
spec:
  containerSecurityContext:
    runAsUser: 1000
    runAsNonRoot: true