container "abc-job" in pod "abc-job-manual-h9k-vbbzw" is waiting to start: CreateContainerConfigError
Error: container has runAsNonRoot and image will run as root (pod: "abc-job-manual-h9k-xyz-ns-nonprod(e38ece94-b411-4d70-bc29-3711f36cfe45)", container: abc-cron-job)
Below image is from cluser in pod details
below is my yaml file for cronjob
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: abc-cron-job
spec:
schedule: "10 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: abc-cron-job
image: docker.repo1.jkl.com/xyz-services/abc/REPLACE_ME
imagePullPolicy: Always
env:
- name: spring-profile
valueFrom:
configMapKeyRef:
name: spring-profile
key: ENV
restartPolicy: OnFailure
in yaml file, securityContext was missing, i added that and now it is working fine. Below one is the updated yaml file
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: abc-cron-job
spec:
schedule: "10 * * * *"
jobTemplate:
spec:
template:
spec:
securityContext:
runAsGroup: 3000
runAsUser: 3000
containers:
- name: abc-cron-job
image: docker.repo1.xyz.com/abc-services/abc-application/REPLACE_ME
imagePullPolicy: Always
env:
- name: spring-profile
valueFrom:
configMapKeyRef:
name: spring-profile
key: ENV
securityContext:
privileged: false
restartPolicy: OnFailure