Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hlucasfranca/f7d60d3e44c80ed1ebaa903eab97427c to your computer and use it in GitHub Desktop.
Save hlucasfranca/f7d60d3e44c80ed1ebaa903eab97427c to your computer and use it in GitHub Desktop.
#-------------------------------------------------------------------------
# FROM: https://kind.sigs.k8s.io/docs/user/local-registry/
set -o errexit
# create registry container unless it already exists
reg_name='kind-registry'
reg_port='5001'
if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then
docker run \
-d --restart=always -p "127.0.0.1:${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
nodes:
- role: control-plane
image: kindest/node:v1.23.3
extraPortMappings:
- containerPort: 31080
listenAddress: 127.0.0.1
hostPort: 80
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
endpoint = ["http://${reg_name}:5000"]
EOF
# connect the registry to the cluster network if not already connected
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${reg_name}")" = 'null' ]; then
docker network connect "kind" "${reg_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:${reg_port}"
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
EOF
#-------------------------------------------------------------------------
# FROM: https://knative.dev/docs/install/yaml-install/serving/install-serving-with-yaml/#verify-the-installation
echo 🔥 Installing Knative Eventing v1.3.0 ...
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.3.0/serving-crds.yaml
echo CRDs installed...
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.3.0/serving-core.yaml
echo Core installed...
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.3.0/kourier.yaml
echo 🕸 Configuring Kourier for Kind...
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.3.0/kourier.yaml
echo "⏳ waiting for kourier system to become healthy"
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n kourier-system
echo "⏳ waiting for knative serving to become healthy"
kubectl wait pod --timeout=-1s --for=condition=Ready -l '!job-name' -n knative-serving
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}'
echo "⏳ waiting for kourier ingress system to become healthy"
kubectl wait --timeout=120s deployment 3scale-kourier-gateway --for=condition=Available -n kourier-system
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: kourier-ingress
namespace: kourier-system
labels:
networking.knative.dev/ingress-provider: kourier
spec:
type: NodePort
selector:
app: 3scale-kourier-gateway
ports:
- name: http2
nodePort: 31080
port: 80
targetPort: 8080
EOF
kubectl patch configmap -n knative-serving config-domain -p '{"data": {"127.0.0.1.sslip.io": ""}}'
kubectl get pods -n kourier-system
kubectl get svc -n kourier-system kourier-ingress
kubectl --namespace kourier-system get service kourier
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.3.0/serving-default-domain.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment