Last active
June 26, 2020 06:10
-
-
Save iknite/45dafc3bd687f7225704e9bd8467d470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -o errexit | |
# create registry container unless it already exists | |
reg_name='kind-registry' | |
reg_port='5000' | |
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" | |
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 | |
cat <<EOF | kind create cluster --config=- | |
kind: Cluster | |
apiVersion: kind.x-k8s.io/v1alpha4 | |
containerdConfigPatches: | |
- |- | |
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"] | |
endpoint = ["http://${reg_name}:${reg_port}"] | |
nodes: | |
- role: control-plane | |
kubeadmConfigPatches: | |
- | | |
kind: InitConfiguration | |
nodeRegistration: | |
kubeletExtraArgs: | |
node-labels: "ingress-ready=true" | |
extraPortMappings: | |
- containerPort: 80 | |
hostPort: 80 | |
protocol: TCP | |
- containerPort: 443 | |
hostPort: 443 | |
protocol: TCP | |
EOF | |
# connect the registry to the cluster network | |
docker network connect "kind" "${reg_name}" | |
# tell https://tilt.dev to use the registry | |
# https://docs.tilt.dev/choosing_clusters.html#discovering-the-registry | |
for node in $(kind get nodes); do | |
kubectl annotate node "${node}" "kind.x-k8s.io/registry=localhost:${reg_port}"; | |
done | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml | |
sleep 30 | |
kubectl wait --namespace ingress-nginx \ | |
--for=condition=ready pod \ | |
--selector=app.kubernetes.io/component=controller \ | |
--timeout=90s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment