-
Notifications
You must be signed in to change notification settings - Fork 0
/
_spin_k8s.sh
executable file
·82 lines (58 loc) · 1.96 KB
/
_spin_k8s.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
CLUSTER="dc1"
ASSETS="./assets"
LOGS="./logs"
clean_env() {
kind delete cluster --name ${CLUSTER}
}
## Check Parameters
if [ "$1" == "clean" ]; then
clean_env
exit 0
fi
## Clean environment
echo "Cleaning Environment"
clean_env
cat > ${ASSETS}/kind-config.yaml <<EOF
# three node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
EOF
kind create cluster --name ${CLUSTER} --config ${ASSETS}/kind-config.yaml
kubectl cluster-info --context kind-${CLUSTER}
# helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
# helm install dashboard kubernetes-dashboard/kubernetes-dashboard -n kubernetes-dashboard --create-namespace
# tee ${ASSETS}/service-account.yaml > /dev/null << EOF
# # service-account.yaml
# apiVersion: v1
# kind: ServiceAccount
# metadata:
# name: admin-user
# namespace: kubernetes-dashboard
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: ClusterRoleBinding
# metadata:
# name: admin-user
# roleRef:
# apiGroup: rbac.authorization.k8s.io
# kind: ClusterRole
# name: cluster-admin
# subjects:
# - kind: ServiceAccount
# name: admin-user
# namespace: kubernetes-dashboard
# EOF
# kubectl apply -f ${ASSETS}/service-account.yaml
# kubectl describe secret `kubectl describe serviceaccount admin-user -n kubernetes-dashboard | grep Tokens | awk '{print $2}'` -n kubernetes-dashboard
# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/master/manifests/namespace.yaml
# kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/master/manifests/metallb.yaml
# # docker network inspect -f '{{.IPAM.Config}}' kind
# # kubectl apply -f https://kind.sigs.k8s.io/examples/loadbalancer/metallb-configmap.yaml
# kubectl apply -f ${ASSETS}/metallb-configmap.yaml