cmd.Flags().String("registry-create","","Create a k3d-managed registry and connect it to the cluster (Format: `NAME[:HOST][:HOSTPORT]`\n - Example: `k3d cluster create --registry-create mycluster-registry:0.0.0.0:5432`")
l.Log().Warnf("Seems like you're mounting a file at '%s' while also using a referenced registries config or k3d-managed registries: Your mounted file will probably be overwritten!",k3d.DefaultRegistriesFilePath)
Here, the config for the k3d-managed registry, created by the `create: true` flag will be merged with the config specified under `config: |`.
Here, the config for the k3d-managed registry, created by the `create: {...}` option will be merged with the config specified under `config: |`.
### Authenticated registries
@ -100,14 +101,14 @@ k3d cluster create \
#### Create a dedicated registry together with your cluster
1. `#!bash k3d cluster create mycluster --registry-create`: This creates your cluster `mycluster` together with a registry container called `k3d-mycluster-registry`
1. `#!bash k3d cluster create mycluster --registry-create mycluster-registry`: This creates your cluster `mycluster` together with a registry container called `mycluster-registry`
- k3d sets everything up in the cluster for containerd to be able to pull images from that registry (using the `registries.yaml` file)
- the port, which the registry is listening on will be mapped to a random port on your host system
2. Check the k3d command output or `#!bash docker ps -f name=k3d-mycluster-registry` to find the exposed port (let's use `12345` here)
3. Pull some image (optional) `#!bash docker pull alpine:latest`, re-tag it to reference your newly created registry `#!bash docker tag alpine:latest k3d-mycluster-registry:12345/testimage:local` and push it `#!bash docker push k3d-mycluster-registry:12345/testimage:local`
4. Use kubectl to create a new pod in your cluster using that image to see, if the cluster can pull from the new registry: `#!bash kubectl run --image k3d-mycluster-registry:12345/testimage:local testimage --command -- tail -f /dev/null` (creates a container that will not do anything but keep on running)
2. Check the k3d command output or `#!bash docker ps -f name=mycluster-registry` to find the exposed port (let's use `12345` here)
3. Pull some image (optional) `#!bash docker pull alpine:latest`, re-tag it to reference your newly created registry `#!bash docker tag alpine:latest mycluster-registry:12345/testimage:local` and push it `#!bash docker push mycluster-registry:12345/testimage:local`
4. Use kubectl to create a new pod in your cluster using that image to see, if the cluster can pull from the new registry: `#!bash kubectl run --image mycluster-registry:12345/testimage:local testimage --command -- tail -f /dev/null` (creates a container that will not do anything but keep on running)
sed -E "s/name:.+/name: $clustername/g" < "$configfileoriginal" > "$configfile"# replace cluster name in config file so we can use it in this script without running into override issues
sed -E "s/^name:.+/name: $clustername/g" < "$configfileoriginal" > "$configfile"# replace cluster name in config file so we can use it in this script without running into override issues
highlight "[START] ConfigTest $EXTRA_TITLE"
@ -53,13 +53,14 @@ info "Ensuring that k3s node labels have been set as stated in the config"
k3s_assert_node_label "k3d-$clustername-server-0""foo=bar"|| failed "Expected label 'foo=bar' not present on node k3d-$clustername-server-0"
## Registry Node
registryname="registry.localhost"
info "Ensuring, that we have a registry node present"
$EXE node list "k3d-$clustername-registry"|| failed "Expected k3d-$clustername-registry to be present"
$EXE node list "$registryname"|| failed "Expected registry node $registryname to be present"
## merged registries.yaml
info "Ensuring, that the registries.yaml file contains both registries"
exec_in_node "k3d-$clustername-server-0""cat /etc/rancher/k3s/registries.yaml"| grep -qi "my.company.registry"|| failed "Expected 'my.company.registry' to be in the /etc/rancher/k3s/registries.yaml"
exec_in_node "k3d-$clustername-server-0""cat /etc/rancher/k3s/registries.yaml"| grep -qi "k3d-$clustername-registry"|| failed "Expected 'k3d-$clustername-registry' to be in the /etc/rancher/k3s/registries.yaml"
exec_in_node "k3d-$clustername-server-0""cat /etc/rancher/k3s/registries.yaml"| grep -qi "$registryname"|| failed "Expected '$registryname' to be in the /etc/rancher/k3s/registries.yaml"