3
3
set -euo pipefail
4
4
5
5
API_SERVER_ENDPOINT=$( kubectl config view -o jsonpath=' {.clusters[0].cluster.server}' | sed s/' http[s]\?:\/\/' //)
6
- TOKEN=$( kubeadm token list -o jsonpath= ' {.token} ' )
6
+ TOKEN=$( kubeadm token create )
7
7
CA_CERT_HASH=" sha256:$( openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl ec -pubin -outform der 2> /dev/null | sha256sum | cut -d' ' -f1) "
8
8
9
9
echo " Generating kubeadm-join.yaml config..."
10
10
11
- cat config/kubeadm-join.tpl.yaml | \
12
- sed " s/{{API_SERVER_ENDPOINT}}/$API_SERVER_ENDPOINT /g" | \
13
- sed " s/{{TOKEN}}/$TOKEN /g" | \
14
- sed " s/{{CA_CERT_HASH}}/$CA_CERT_HASH /g" > config/kubeadm-join.yaml
11
+ kubeadm-join-config --config-path ./config/kubeadm-join.compute.yaml \
12
+ --api-server-endpoint $API_SERVER_ENDPOINT \
13
+ --token $TOKEN \
14
+ --ca-cert-hash $CA_CERT_HASH \
15
+ --label-key node.mmontes.io/type \
16
+ --label-value compute
17
+
18
+ kubeadm-join-config --config-path ./config/kubeadm-join.compute-small.yaml \
19
+ --api-server-endpoint $API_SERVER_ENDPOINT \
20
+ --token $TOKEN \
21
+ --ca-cert-hash $CA_CERT_HASH \
22
+ --label-key node.mmontes.io/type \
23
+ --label-value compute-small
24
+
25
+ kubeadm-join-config --config-path ./config/kubeadm-join.storage.yaml \
26
+ --api-server-endpoint $API_SERVER_ENDPOINT \
27
+ --token $TOKEN \
28
+ --ca-cert-hash $CA_CERT_HASH \
29
+ --label-key node.mmontes.io/type \
30
+ --label-value storage \
31
+ --taint node.mmontes.io/storage
15
32
16
33
cat << EOF
17
34
18
- Generated join configuration file: 'config/kubeadm-join.yaml'
19
- Copy this file to each worker node and run this command to join the cluster:
35
+ Generated join configuration files:
36
+ - 'config/kubeadm-join.compute.yaml'
37
+ - 'config/kubeadm-join.compute-small.yaml'
38
+ - 'config/kubeadm-join.storage.yaml'
20
39
21
- sudo bash worker.sh
40
+ Copy these file to each worker node and run this command to join the cluster:
41
+
42
+ sudo bash node.sh 'config/kubeadm-join.compute.yaml'
22
43
23
44
EOF
0 commit comments