CodexBloom - Programming Q&A Platform

Kubernetes on CentOS 9 Stream - how to to Pull Images from Private Registry: 'Unauthorized' scenarios

👀 Views: 990 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-08
kubernetes centos docker YAML

I'm sure I'm missing something obvious here, but I'm working on a personal project and I'm currently running a Kubernetes cluster on CentOS 9 Stream and I've set up a private Docker registry. While I can push images to the registry without any issues, I'm experiencing problems when trying to pull images for my deployments. Every time I attempt to deploy, I receive the following behavior: ``` behavior from server (BadRequest): container "my-container" in pod "my-pod" is waiting to start: image "my-registry.com/my-image:latest" is not ready: behavior: Unauthorized ``` I have confirmed that my registry credentials are correct. I've created a Kubernetes secret for the Docker registry using the following command: ```bash kubectl create secret docker-registry my-registry-secret \ --docker-server=my-registry.com \ --docker-username=my-username \ --docker-password=my-password \ --docker-email=my-email@example.com ``` Then, I've referenced this secret in my deployment YAML file as follows: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: my-deployment spec: replicas: 1 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-container image: my-registry.com/my-image:latest imagePullSecrets: - name: my-registry-secret ``` Despite this configuration, the pods continue to unexpected result with the 'Unauthorized' behavior. I've also double-checked the permissions on the Docker registry to ensure the user has access to pull images. Additionally, I verified that the image exists in the registry and that the registry itself is reachable from the cluster. I've tried restarting the kubelet service and recreating the secret, but nothing seems to resolve the scenario. Any insights into this would be greatly appreciated! Cheers for any assistance!