git.iko.soy/typeable/octopod
on new-control-scripts help sign in
typeable/octopod/octopod_local_install.sh
101 lines 3.0 kB history raw
1#!/bin/bash
2set -e
3message () {
4 echo "==> $1"
5}
6for 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
11done
12if [ "$(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
15fi
16if [ "$(kind version | awk -F ' ' '{print $2}')" != "v0.11.1" ]; then
17 message "Warning! This kind version hasn't been tested"
18fi
19if 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
29fi
30message "Creating kind cluster"
31cat <<EOF | kind create cluster --config=-
32kind: Cluster
33apiVersion: kind.x-k8s.io/v1alpha4
34name: octopod
35networking:
36 kubeProxyMode: "ipvs"
37nodes:
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
52EOF
53cat <<EOF | kubectl apply -f -
54apiVersion: v1
55kind: ConfigMap
56metadata:
57 name: coredns
58 namespace: kube-system
59data:
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 }
81EOF
82message "Installing ingress-nginx controller"
83kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.45.0/deploy/static/provider/kind/deploy.yaml
84while 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
91done
92message "Creating nessesary namespaces"
93kubectl create ns octopod
94kubectl create ns octopod-deployment
95message "Adding typeable helm repository"
96helm repo add typeable https://typeable.github.io/octopod
97helm repo update
98message "Installing octopod helm chart"
99helm -n octopod install octopod typeable/octopod --wait --timeout=5m --set octopod.baseDomain="lvh.me" --set ingress.tls.enabled=false
100message "Octopod was successfully installed! Use instruction above to connect to it."
101message "To uninstall octopod just run: kind delete cluster --name octopod"