Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions docs/canonicalk8s/charm/howto/custom-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
The `k8s` charm can be configured to use a custom container registry for its
container images. This is particularly useful if you have a private registry or
operate in an air-gapped environment where you need to pull images from a
different registry. This guide will walk you through the steps to set up `k8s`
charm to pull images from a custom registry.
different registry.

## Prerequisites

Expand All @@ -13,14 +12,15 @@ charm to pull images from a custom registry.
- Access to a custom container registry from the cluster (e.g., docker registry
or Harbor).

## Adding a custom registry
## Add a custom registry

To configure the charm to use a custom registry, you need to set the
`containerd-custom-registries` configuration option. This options allows
the charm to configure `containerd` to pull images from registries that require
authentication. This configuration option should be a JSON-formatted array of
credential objects. For more details on the `containerd-custom-registries`
option, refer to the [charm configurations] documentation.
`containerd-custom-registries` configuration option of the control-plane
application. This options allows the charm to configure `containerd` to pull
images from registries that require authentication. This configuration option
should be a JSON-formatted array of credential objects. For more details on the
`containerd-custom-registries` option, refer to the [charm configurations]
documentation.

For example, to configure the charm to use a custom registry at
`myregistry.example.com:5000` with the username `myuser` and password
Expand All @@ -44,7 +44,7 @@ progress by running:
juju status --watch 2s
```

### Adding a registry mirror
### Add a registry mirror

To configure the charm to use a registry mirror, you need to add to the
`containerd-custom-registries` configuration option.
Expand All @@ -65,7 +65,7 @@ juju config k8s containerd-custom-registries='[{
}]'
```

### Adding a nested path registry mirror
### Add a nested path registry mirror

To configure the charm to use a registry mirror where the path to the images is
nested deeper, you need to add set the `override_path` flag to true
Expand All @@ -88,6 +88,26 @@ juju config k8s containerd-custom-registries='[{
}]'
```

## Share with all workers in the cluster

If the model contains Kubernetes workers, ensure the `containerd` relation
is integrated with each worker application. This configures containerd with the
same custom configuration, not only to every control-plane node, but to each
worker node as well.

> **Note:** This assumes worker applications are already deployed and integrated
> in the cluster. If you haven't yet deployed workers, refer to the how-to on
> [adding kubernetes workers][] for complete deployment instructions

```bash
for WORKER_APP in $(
juju status --format json |
jq -r '.applications | to_entries[] | select(.value["charm-name"]=="k8s-worker") | .key'
); do
juju integrate k8s "${WORKER_APP}:containerd"
done
```

## Verify the configuration

Once the charm is configured and active, verify that the custom registry is
Expand Down Expand Up @@ -119,3 +139,4 @@ myregistry.example.com:5000/nginx:latest->true
<!-- LINKS -->

[charm configurations]: https://charmhub.io/k8s/configurations
[adding kubernetes workers]: ./install/custom-workers.md
Loading