If the image repository requires authentication, you need to add the corresponding ImagePullSecrets to the ServiceAccount used by the application. This ensures that the application can successfully pull images from the private repository.
To create an ImagePullSecret, please refer to Creating a Secret for detailed steps on creating an ImagePullSecret.
If the Pod of your application uses the ServiceAccount example, you can add the ImagePullSecret to the example ServiceAccount in the namespace where your application is located.
Edit the ServiceAccount example with patch command:
Replace <namespace> with the namespace where your application is located, and my-docker-creds with the name of the ImagePullSecret you created.
You can verify the addition of the ImagePullSecret by describing the ServiceAccount:
You should see the Image pull secrets section showing the added secret.
Note: If your Pod does not specify a ServiceAccount, it will use the default ServiceAccount in the namespace by default. You can add the ImagePullSecret to the default ServiceAccount in the same way.
When you create a new Pod that uses the ServiceAccount example, the Pod will automatically use the ImagePullSecrets specified in the ServiceAccount.
You can verify this by run the command: