@@ -0,0 +1,101 @@
1+#!/bin/bash
2+set -e
3+message () {
4+ echo "==> $1"
5+}
6+for cmd in kind kubectl helm; do
7+ if ! command -v $cmd &> /dev/null; then
8+ message "$cmd is not installed. Please, install it!"
9+ exit 1;
10+ fi
11+done
12+if [ "$(helm version --short | awk -F '.' '{print $1}')" != "v3" ]; then
13+ message 'Your version of helm is not supported. Please install helm 3'
14+ exit 1
15+fi
16+if [ "$(kind version | awk -F ' ' '{print $2}')" != "v0.11.1" ]; then
17+ message "Warning! This kind version hasn't been tested"
18+fi
19+if kind get clusters | grep -q octopod; then
20+ echo -n 'Octopod kind cluster already exists. Do you want do delete it? [y/n] ';
21+ read confirm
22+ if [ "$confirm" != 'y' ]; then
23+ message "Exiting"
24+ exit 0
25+ else
26+ message "Deleting and recreating cluster"
27+ kind delete cluster --name octopod
28+ fi
29+fi
30+message "Creating kind cluster"
31+cat <<EOF | kind create cluster --config=-
32+kind: Cluster
33+apiVersion: kind.x-k8s.io/v1alpha4
34+name: octopod
35+networking:
36+ kubeProxyMode: "ipvs"
37+nodes:
38+- role: control-plane
39+ kubeadmConfigPatches:
40+ - |
41+ kind: InitConfiguration
42+ nodeRegistration:
43+ kubeletExtraArgs:
44+ node-labels: "ingress-ready=true"
45+ extraPortMappings:
46+ - containerPort: 80
47+ hostPort: 80
48+ protocol: TCP
49+ - containerPort: 443
50+ hostPort: 443
51+ protocol: TCP
52+EOF
53+cat <<EOF | kubectl apply -f -
54+apiVersion: v1
55+kind: ConfigMap
56+metadata:
57+ name: coredns
58+ namespace: kube-system
59+data:
60+ Corefile: |
61+ .:53 {
62+ errors
63+ health {
64+ lameduck 5s
65+ }
66+ ready
67+ kubernetes cluster.local in-addr.arpa ip6.arpa {
68+ pods insecure
69+ fallthrough in-addr.arpa ip6.arpa
70+ ttl 30
71+ }
72+ prometheus :9153
73+ forward . 8.8.8.8 1.1.1.1 {
74+ max_concurrent 1000
75+ }
76+ cache 30
77+ loop
78+ reload
79+ loadbalance
80+ }
81+EOF
82+message "Installing ingress-nginx controller"
83+kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.45.0/deploy/static/provider/kind/deploy.yaml
84+while true; do
85+ if [ $(kubectl -n ingress-nginx get deploy | awk -F ' ' '$1 ~ /^ingress-nginx/ {print $4}') == '1' ]; then
86+ message 'ingress-controller is ready'
87+ break;
88+ else
89+ message 'waiting for ingress-controller to become ready...'; sleep 5;
90+ fi
91+done
92+message "Creating nessesary namespaces"
93+kubectl create ns octopod
94+kubectl create ns octopod-deployment
95+message "Adding typeable helm repository"
96+helm repo add typeable https://typeable.github.io/octopod
97+helm repo update
98+message "Installing octopod helm chart"
99+helm -n octopod install octopod typeable/octopod --wait --timeout=5m --set octopod.baseDomain="lvh.me" --set ingress.tls.enabled=false
100+message "Octopod was successfully installed! Use instruction above to connect to it."
101+message "To uninstall octopod just run: kind delete cluster --name octopod"