Description
Describe the bug
We want to completly remove the securityContext entry from the grafana deployment to make it work within our openshift environment. But we don't seem to be able to completly disable the generation of that section.
Version
v5.0.0-rc1
To Reproduce
Greate a Grafana instance with the following definition:
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: test-no-security-context
spec:
deployment:
spec:
template:
spec:
securityContext: {}
containers:
- name: grafana
securityContext: {}
Which creates the following deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: "2023-04-03T11:54:44Z"
generation: 1
name: test-no-security-context-deployment
namespace: grafana-operator
ownerReferences:
- apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
name: test-no-security-context
uid: c6d7c4d3-6417-4862-ab34-a1641e38b135
resourceVersion: "5940916"
uid: 37c273f2-9df3-4d09-988a-37090cbda454
spec:
progressDeadlineSeconds: 601
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: test-no-security-context
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: test-no-security-context
name: test-no-security-context-deployment
spec:
containers:
- args:
- -config=/etc/grafana/grafana.ini
env:
- name: PLUGINS_HASH
valueFrom:
configMapKeyRef:
key: PLUGINS_HASH
name: test-no-security-context-plugins
optional: true
- name: CONFIG_HASH
value: 98e8da23b51963ae3b3569c19ffdc1ec060852dfde6dab68bfb63d46751b4b08
- name: GF_INSTALL_PLUGINS
- name: GF_SECURITY_ADMIN_USER
valueFrom:
secretKeyRef:
key: GF_SECURITY_ADMIN_USER
name: test-no-security-context-admin-credentials
- name: GF_SECURITY_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
key: GF_SECURITY_ADMIN_PASSWORD
name: test-no-security-context-admin-credentials
image: docker.io/grafana/grafana:9.1.6
imagePullPolicy: IfNotPresent
name: grafana
ports:
- containerPort: 3000
name: grafana-http
protocol: TCP
readinessProbe:
failureThreshold: 1
httpGet:
path: /api/health
port: 3000
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 3
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 100m
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/grafana/
name: test-no-security-context-ini
- mountPath: /var/lib/grafana
name: grafana-data
- mountPath: /var/log/grafana
name: grafana-logs
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
seccompProfile:
type: RuntimeDefault
serviceAccount: test-no-security-context-sa
serviceAccountName: test-no-security-context-sa
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: test-no-security-context-ini
name: test-no-security-context-ini
- emptyDir: {}
name: grafana-logs
- emptyDir: {}
name: grafana-data
status:
conditions:
- lastTransitionTime: "2023-04-03T11:54:44Z"
lastUpdateTime: "2023-04-03T11:54:44Z"
message: Deployment does not have minimum availability.
reason: MinimumReplicasUnavailable
status: "False"
type: Available
- lastTransitionTime: "2023-04-03T11:54:44Z"
lastUpdateTime: "2023-04-03T11:54:44Z"
message: ReplicaSet "test-no-security-context-deployment-7f95c96b44" is progressing.
reason: ReplicaSetUpdated
status: "True"
type: Progressing
observedGeneration: 1
replicas: 1
unavailableReplicas: 1
updatedReplicas: 1
Expected behavior
We would expect that none of those entries appear in the deployment file.
Suspect component/Location where the bug might be occurring
unknown
Runtime (please complete the following information):
- Environment: OpenShift version:
4.12.8