git.iko.soy/typeable/octopod
on nixify-control-scripts help sign in
typeable/octopod/octopod_local_install.sh
131 lines 4.2 kB history raw
1#!/bin/bash
2set -e
3message () {
4 echo "==> $1"
5}
7echo
8echo " ๐Ÿ”– If you encounter any issues during the installation please open an issue:"
9echo " https://github.com/typeable/octopod/issues/new"
10echo
11echo " โ„น๏ธ Please note that you might experience performance issues if you have low resouce limits:"
12echo " https://github.com/typeable/octopod/blob/master/docs/en/Octopod_deployment_guide.md#if-you-want-to-try-it-locally"
13echo
15for cmd in kind kubectl helm; do
16 if ! command -v $cmd &> /dev/null; then
17 message "$cmd is not installed. Please, install it!"
18 exit 1;
19 fi
20done
21if [ "$(helm version --short | awk -F '.' '{print $1}')" != "v3" ]; then
22 message 'Your version of helm is not supported. Please install helm 3'
23 exit 1
24fi
25if [ "$(kind version | awk -F ' ' '{print $2}')" != "v0.11.1" ]; then
26 message "Warning! This kind version hasn't been tested"
27fi
28if kind get clusters | grep -q octopod; then
29 echo -n 'Octopod kind cluster already exists. Do you want do delete it? [y/n] ';
30 read confirm
31 if [ "$confirm" != 'y' ]; then
32 message "Exiting"
33 exit 0
34 else
35 message "Deleting and recreating cluster"
36 kind delete cluster --name octopod
37 fi
38fi
39message "Creating kind cluster"
40cat <<EOF | kind create cluster --config=-
41kind: Cluster
42apiVersion: kind.x-k8s.io/v1alpha4
43name: octopod
44networking:
45 kubeProxyMode: "ipvs"
46nodes:
47- role: control-plane
48 kubeadmConfigPatches:
49 - |
50 kind: InitConfiguration
51 nodeRegistration:
52 kubeletExtraArgs:
53 node-labels: "ingress-ready=true"
54 extraPortMappings:
55 - containerPort: 80
56 hostPort: 80
57 protocol: TCP
58 - containerPort: 443
59 hostPort: 443
60 protocol: TCP
61EOF
62cat <<EOF | kubectl --context=kind-octopod apply -f -
63apiVersion: v1
64kind: ConfigMap
65metadata:
66 name: coredns
67 namespace: kube-system
68data:
69 Corefile: |
70 .:53 {
71 errors
72 health {
73 lameduck 5s
74 }
75 ready
76 kubernetes cluster.local in-addr.arpa ip6.arpa {
77 pods insecure
78 fallthrough in-addr.arpa ip6.arpa
79 ttl 30
80 }
81 prometheus :9153
82 forward . 8.8.8.8 1.1.1.1 {
83 max_concurrent 1000
84 }
85 cache 30
86 loop
87 reload
88 loadbalance
89 }
90EOF
91message "Installing ingress-nginx controller"
92kubectl --context=kind-octopod apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.45.0/deploy/static/provider/kind/deploy.yaml
93has_error=0
94while true; do
95 set +e
96 kube_out=`kubectl --context=kind-octopod -n ingress-nginx get deploy 2>&1`
97 err_code=$?
98 set -e
99 if [ $err_code != 0 ] && [ $has_error == 0 ]; then
100 echo "kubectl returned: $kube_out"
101 echo "Do you want to continue installation? [y/n] "
102 read confirm
103 if [ "$confirm" != 'y' ]; then
104 message "Deleting cluster..."
105 kind delete cluster --name octopod
106 exit 0;
107 else
108 has_error=1
109 fi
110 fi
111 if [ $err_code == 0 ] && [ $( echo -n "$kube_out" | awk -F ' ' '$1 ~ /^ingress-nginx/ {print $4}') == '1' ]; then
112 message 'ingress-controller is ready'
113 break;
114 else
115 message 'waiting for ingress-controller to become ready...'; sleep 5;
116 fi
117done
118message "Creating nessesary namespaces"
119kubectl --context=kind-octopod create ns octopod
120kubectl --context=kind-octopod create ns octopod-deployment
121message "Adding typeable helm repository"
122helm repo add typeable https://typeable.github.io/octopod
123helm repo update
124message "Installing octopod helm chart"
125helm --kube-context=kind-octopod -n octopod install octopod typeable/octopod --wait --timeout=5m --set octopod.baseDomain="lvh.me" --set ingress.tls.enabled=false
126echo
127echo " ๐ŸŒŸ Don't forget to star Octopod on GitHub:"
128echo " https://github.com/typeable/octopod"
129echo
130echo " ๐Ÿ—‘๏ธ To uninstall Octopod just run:"
131echo " kind delete cluster --name octopod"