Created
March 31, 2023 16:21
-
-
Save samruddhikhandale/e93358e7cf3a222e7624f70960098a14 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 -eux | |
export KO_DOCKER_REPO=kind.local | |
export KO_FLAGS='--platform=linux/amd64' | |
echo "Setting up local container registry..." | |
REGISTRY_NAME='registry.local' | |
REGISTRY_PORT='5001' | |
if [ "$(docker inspect -f '{{.State.Running}}' "${REGISTRY_NAME}" 2>/dev/null || true)" != 'true' ]; then | |
docker run \ | |
-d --restart=always -p "127.0.0.1:${REGISTRY_PORT}:5000" --name "${REGISTRY_NAME}" \ | |
registry:2 | |
fi | |
echo "Creating KinD cluster..." | |
cat <<EOF | kind create cluster --config=- | |
kind: Cluster | |
apiVersion: kind.x-k8s.io/v1alpha4 | |
containerdConfigPatches: | |
- |- | |
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${REGISTRY_PORT}"] | |
endpoint = ["http://${REGISTRY_NAME}:5000"] | |
EOF | |
echo "Connecting registry to KinD cluster..." | |
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${REGISTRY_NAME}")" = 'null' ]; then | |
docker network connect "kind" "${REGISTRY_NAME}" | |
fi | |
# Document the local registry | |
# https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry | |
cat <<EOF | kubectl apply -f - | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: local-registry-hosting | |
namespace: kube-public | |
data: | |
localRegistryHosting.v1: | | |
host: "localhost:${REGISTRY_PORT}" | |
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | |
EOF | |
echo "Deploying cert-manager..." | |
kubectl apply -f ./third_party/cert-manager-latest/cert-manager.yaml | |
kubectl wait --for=condition=Established --all crd | |
kubectl wait --for=condition=Available -n cert-manager --all deployments | |
echo "Deploying Knative Serving..." | |
ko apply --selector knative.dev/crd-install=true -Rf config/core/ | |
kubectl wait --for=condition=Established --all crd | |
ko apply -Rf config/core/ | |
echo "Deploying Knative ingress with Kourier..." | |
kubectl apply -f ./third_party/kourier-latest/kourier.yaml | |
kubectl patch configmap/config-network \ | |
-n knative-serving \ | |
--type merge \ | |
-p '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment