-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstallkind.sh
54 lines (37 loc) · 1.26 KB
/
installkind.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
#!/bin/bash -x
## Install docker
sudo apt update
sudo apt-get install docker.io -y
sudo usermod -aG docker ubuntu
sudo chmod 666 /var/run/docker.sock
### Install de kind pour démarrer un cluster k8s dans des conteneurs docker
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.14.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/bin/kind
### Install kubectl => kubectl est un client en cli pour communiquer avec le cluster.
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/bin/kubectl
### Generate config file
cat <<EOF | tee kind.yml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30001
hostPort: 30001
- role: worker
- role: worker
EOF
# Initialize cluster
# kind create cluster --name dev-cluster --config kind.yml
kind create cluster --name dev-cluster --config kind.yml 2>&1 | tee output_logger.txt
OUT_PUT_STRING=`cat output_logger.txt`
BIGIN_STRING="cluster-info"
END_STRING="Have"
RESULT="${OUT_PUT_STRING#*${BIGIN_STRING}}"
RESULT="${RESULT%${END_STRING}*}"
echo $RESULT
echo "--------> The config command is : kubectl cluster-info $RESULT"
kubectl cluster-info$RESULT