Is it possible to use Jenkins secret as an imagePullSecret in Kubernetes pod agent template in declarative pipeline

8/6/2019

My goal is to set up jenkins agent pod in kubernetes cluster for which the docker image is needed to be pulled from a private registry. I cannot provide the credentials in source control. Is there any possible way to fetch credentials from jenkins secrets rather than providing a kubernetes secret in podSpec?

-- Junia Antony
jenkins-pipeline
kubernetes

1 Answer

8/6/2019

I've done this before when the images were stored in Azure Container Registry (ACR). In that case we used the "with credentials" plugin combined with the "Azure CLI" plugin to push/pull the images from ACR.

Here is a similar example, but using docker hub instead of ACR as the private registry: https://medium.com/@gustavo.guss/jenkins-building-docker-image-and-sending-to-registry-64b84ea45ee9

-- Anna B
Source: StackOverflow