Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling an Image from Private Registry in Kubernetes cronjob fails

I am pulling an image from a private repository on gitlab and running a cronjob in kubernetes. Since it is a private repo I would also have to supply the imagePullSecrets. but I noticed it gives an error because a cronjob doesn't accept the imagePullSecrets tag. It gives the following error. Does that mean I can't use an image from a private repository in a cronjob?

error: error validating "cron.yml": error validating data: ValidationError(CronJob.spec.jobTemplate.spec.template.spec.containers[0]): unknown field "imagePullSecrets" in io.k8s.api.core.v1.Container; if you choose to ignore these errors, turn validation off with --validate=false
like image 672
Anshul Tripathi Avatar asked Oct 24 '25 18:10

Anshul Tripathi


1 Answers

The imagePullSecrets field is not a per container field - you need to set that at CronJob.spec.jobTemplate.spec.template.spec.imagePullSecrets instead of CronJob.spec.jobTemplate.spec.template.spec.containers.imagePullSecrets. You can see an example for a Pod here.

like image 120
dippynark Avatar answered Oct 26 '25 08:10

dippynark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!