# How do I pull images in Kubernetes or push from CI?

> Create a Kubernetes pull secret for your Phluit container registry with a read-only token, and push images from GitHub Actions or any CI with a read/write token.

Source: https://docs.phluit.com/products/container-registry/registry-kubernetes-and-ci/

Use a **read-only** token for clusters and servers, and a **read/write** token for your CI. Create them on the registry's **Access tokens** tab. See [How do I create and manage access tokens?](/products/container-registry/registry-access-tokens/)

## Kubernetes: a pull secret

Create the secret with a read-only token:

```
kubectl create secret docker-registry phluit-registry \
  --docker-server=cr.phluit.net \
  --docker-username='robot$<your-registry>+<token-name>' \
  --docker-password='<your-token>'
```

Then use it in your pod spec, and point the container's `image` at `cr.phluit.net/<your-registry>/<image>:<tag>`:

```
imagePullSecrets:
  - name: phluit-registry
```

Create the secret in each namespace that pulls from the registry.

## GitHub Actions

In your repository, add two secrets: `PHLUIT_REGISTRY_USER` (the token's user name) and `PHLUIT_REGISTRY_TOKEN` (the token). Then add these steps to your workflow:

```
- uses: docker/login-action@v3
  with:
    registry: cr.phluit.net
    username: ${{ secrets.PHLUIT_REGISTRY_USER }}
    password: ${{ secrets.PHLUIT_REGISTRY_TOKEN }}
- run: docker build -t cr.phluit.net/<your-registry>/my-app:${{ github.sha }} . && docker push cr.phluit.net/<your-registry>/my-app:${{ github.sha }}
```

Your registry's **Overview** tab shows the same steps with your address under **GitHub Actions**.

## Other CI systems (GitLab CI and others)

Keep the user name and token as protected CI variables, then:

```
echo "$PHLUIT_TOKEN" | docker login cr.phluit.net -u "$PHLUIT_USER" --password-stdin
docker build -t cr.phluit.net/<your-registry>/app:$COMMIT .
docker push cr.phluit.net/<your-registry>/app:$COMMIT
```

## Phluit servers

On a Phluit cloud server, log in with a read-only token and pull or run the image:

```
docker login cr.phluit.net -u 'robot$<your-registry>+<token-name>' --password-stdin < token.txt
docker run -d cr.phluit.net/<your-registry>/app:1.0
```

## Good to know

-   Tag images with the commit or a version number, not only `latest`, so you know what runs where.
-   A token with an expiry date stops working on that date. Create the new token and update your secrets before then.
-   Old tags take space. See [How do I see scan results and delete old images?](/products/container-registry/registry-repositories-scans-cleanup/)
