mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
cleanup local registry example
This commit is contained in:
@@ -173,7 +173,9 @@ pre code {
|
||||
|
||||
/* inline copyable code snippet styling */
|
||||
table.includecode {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
background: #f3f4f4;
|
||||
border: 1px solid black;
|
||||
border-spacing: 0;
|
||||
|
||||
@@ -17,7 +17,7 @@ The following recipe leverages this to enable a local registry.
|
||||
The following shell script will create a local docker registry and a kind cluster
|
||||
with it enabled.
|
||||
|
||||
{{< codefromfile "static/examples/kind-with-registry.sh" >}}
|
||||
{{< codefromfile file="static/examples/kind-with-registry.sh" >}}
|
||||
|
||||
## Using The Registry
|
||||
|
||||
|
||||
@@ -3,12 +3,15 @@ set -o errexit
|
||||
|
||||
# desired cluster name; default is "kind"
|
||||
KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-kind}"
|
||||
REGISTRY_CONTAINER_NAME='kind-registry'
|
||||
REGISTRY_PORT='5000'
|
||||
|
||||
# create registry container unless it already exists
|
||||
if [ "$(docker inspect -f '{{.State.Running}}' "${REGISTRY_CONTAINER_NAME}")" != 'true' ]; then
|
||||
docker run -d -p "${REGISTRY_PORT}:5000" --restart=always --name "${REGISTRY_CONTAINER_NAME}" registry:2
|
||||
reg_name='kind-registry'
|
||||
reg_port='5000'
|
||||
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}")"
|
||||
if [ "${running}" != 'true' ]; then
|
||||
docker run \
|
||||
-d --restart=always -p "${reg_port}:5000" --name "${reg_name}" \
|
||||
registry:2
|
||||
fi
|
||||
|
||||
# create a cluster with the local registry enabled in containerd
|
||||
@@ -17,11 +20,13 @@ kind: Cluster
|
||||
apiVersion: kind.x-k8s.io/v1alpha4
|
||||
containerdConfigPatches:
|
||||
- |-
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry:${REGISTRY_PORT}"]
|
||||
endpoint = ["http://registry:${REGISTRY_PORT}"]
|
||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry:${reg_port}"]
|
||||
endpoint = ["http://registry:${reg_port}"]
|
||||
EOF
|
||||
|
||||
# add the registry to /etc/hosts on each node
|
||||
ip_fmt='{{.NetworkSettings.IPAddress}}'
|
||||
cmd="echo $(docker inspect -f "${ip_fmt}" "${reg_name}") registry >> /etc/hosts"
|
||||
for node in $(kind get nodes --name "${KIND_CLUSTER_NAME}"); do
|
||||
docker exec "${node}" sh -c "echo $(docker inspect --format '{{.NetworkSettings.IPAddress }}' "${REGISTRY_CONTAINER_NAME}") registry >> /etc/hosts"
|
||||
docker exec "${node}" sh -c "${cmd}"
|
||||
done
|
||||
Reference in New Issue
Block a user