---
url: https://ibee.ai/docs/infrastructure/kubernetes/pull-private-images
last_updated: 2026-11-26
---

> For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://ibee.ai/docs/llms.txt (full text of every page: https://ibee.ai/docs/llms-full.txt). For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://ibee.ai/docs/_mcp/server.

# Pull private images in Kubernetes

> Let your Kubernetes cluster pull images from a private registry. Create an image pull secret from an IBEE Container Registry pull-only token, attach it to a service account or pod spec, rotate it before the token expires, and fix ImagePullBackOff errors.

Kubernetes needs registry credentials to pull images from a private registry. You store them in an **image pull secret** (a Secret of type `kubernetes.io/dockerconfigjson`) in each namespace that runs the images, then point workloads at it: once on the namespace's service account, or in each pod spec.

The examples use [IBEE Container Registry](/docs/infrastructure/container-registry) (`registry.ibee.ai`). The same steps work for other private registries with their own server address and credentials.

## Before you begin

* A cluster and `kubectl` connected to it.
* A private registry in Container Registry with the image pushed to it.
* A registry access token with **Pull only** permission for that registry. See [Create an access token](/docs/infrastructure/container-registry#create-an-access-token). Keep the **Registry username** and **Access token** at hand.
* The namespace the workloads run in. The examples use `example-app`.

## Steps

### Create the image pull secret

Read the token into a shell variable without echoing it, so it doesn't end up in your shell history:

```bash
read -rs IBEE_REGISTRY_TOKEN
# Paste the access token and press Enter.
```

Create the Secret in the namespace where the workloads run. The username contains a `$` character, so wrap it in **single quotes**:

```bash
kubectl create secret docker-registry ibee-registry \
  --namespace example-app \
  --docker-server=registry.ibee.ai \
  --docker-username='PASTE-REGISTRY-USERNAME' \
  --docker-password="$IBEE_REGISTRY_TOKEN"
```

A Secret is only visible to pods in its own namespace. Create one in every namespace that pulls from the registry.

### Attach it to your workloads

Pick one of these.

**Attach it to the service account (recommended).** Every pod that runs as the service account uses the secret, so your manifests don't need to mention it. Pods use the `default` service account unless their spec says otherwise:

```bash
kubectl patch serviceaccount default -n example-app \
  -p '{"imagePullSecrets":[{"name":"ibee-registry"}]}'
```

This replaces the service account's list of pull secrets. If it already has some, include them in the list. Check with `kubectl get serviceaccount default -n example-app -o yaml`.

**Or name it in the pod spec.** Add `imagePullSecrets` to each Deployment, StatefulSet, Job or Pod:

**`deployment.yaml`**

```yaml title="deployment.yaml"
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-api
  namespace: example-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: web-api
  template:
    metadata:
      labels:
        app: web-api
    spec:
      imagePullSecrets:
        - name: ibee-registry
      containers:
        - name: web-api
          image: registry.ibee.ai/acme-prod/web-api:v1.4.2
```

### Restart pods that already failed

A service account's pull secrets are added to pods when the pods are created. Pods already stuck in `ImagePullBackOff` keep failing until they're replaced:

```bash
kubectl rollout restart deployment/web-api -n example-app
```

## Verify

Check that the Secret holds the right server and username:

```bash
kubectl get secret ibee-registry -n example-app \
  -o jsonpath='{.data.\.dockerconfigjson}' | base64 --decode
```

Then check that the pods are running:

```bash
kubectl get pods -n example-app
```

The pods show `Running`. If one shows `ErrImagePull` or `ImagePullBackOff`, run `kubectl describe pod POD-NAME -n example-app` and read the **Events** at the end. See [Troubleshooting](#troubleshooting).

## Rotate the registry token

Registry access tokens expire (after 90 days by default), and **Rotate** in the portal stops the old token immediately. After that, every **new** pull fails until you update the Secret: new deployments, scale-ups, and pods moved to another node. Pods that are already running keep running.

Before the token expires, or right after you rotate it, update the Secret in place:

```bash
read -rs IBEE_REGISTRY_TOKEN
kubectl create secret docker-registry ibee-registry \
  --namespace example-app \
  --docker-server=registry.ibee.ai \
  --docker-username='PASTE-REGISTRY-USERNAME' \
  --docker-password="$IBEE_REGISTRY_TOKEN" \
  --dry-run=client -o yaml | kubectl apply -f -
```

`--dry-run=client -o yaml | kubectl apply -f -` creates the Secret if it's missing and updates it if it exists, so the same command works from a CI pipeline. Workloads pick up the new credentials on their next pull without a restart.

To keep the token out of your cluster manifests and rotate it in one place, store it in Secret Manager and sync it with [External Secrets Operator](/docs/tools/secret-manager/kubernetes).

## Other registries

Use the registry's own server address and a read-only token or deploy token created as your provider documents:

| Registry                  | `--docker-server`             |
| ------------------------- | ----------------------------- |
| IBEE Container Registry   | `registry.ibee.ai`            |
| Docker Hub                | `https://index.docker.io/v1/` |
| GitHub Container Registry | `ghcr.io`                     |
| GitLab Container Registry | `registry.gitlab.com`         |

## Troubleshooting

| You see                                                                                   | What it means                                     | What to do                                                                                                                                                                                                                                                |
| ----------------------------------------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ErrImagePull` or `ImagePullBackOff` with `401 Unauthorized` or `authentication required` | The pod has no valid credentials for the registry | Check that `ibee-registry` exists in the pod's namespace and is attached to its service account or pod spec. Check that the username kept its `$`: recreate the Secret with the username in single quotes. Rotate the token if it expired or was revoked. |
| `403 Forbidden` or `denied`                                                               | The token doesn't cover this registry             | Create a **Pull only** token for this registry and update the Secret.                                                                                                                                                                                     |
| `not found` or `manifest unknown`                                                         | The image name or tag doesn't exist               | Check the full image name, `registry.ibee.ai/REGISTRY-NAME/REPOSITORY:TAG`, against the registry's **Overview** tab.                                                                                                                                      |
| Pods still fail after you patched the service account                                     | The pods were created before the patch            | Restart the workload with `kubectl rollout restart`.                                                                                                                                                                                                      |
| Pods in one namespace pull, pods in another don't                                         | Secrets are per namespace                         | Create the Secret in the other namespace and attach it there too.                                                                                                                                                                                         |
| `error: failed to create secret ... already exists`                                       | The Secret is already there                       | Update it with the `kubectl apply` command in [Rotate the registry token](#rotate-the-registry-token).                                                                                                                                                    |

## Related pages

* [Container Registry](/docs/infrastructure/container-registry): create registries, access tokens and push images
* [Deploy to Kubernetes from GitHub Actions](/docs/infrastructure/kubernetes/deploy-from-github-actions)
* [Kubernetes with External Secrets](/docs/tools/secret-manager/kubernetes)