Skip to content

Commit f93aff3

Browse files
committed
[Doc] Elaborated k8s controlplane initialization and worker node join script.
Signed-off-by: insukim1994 <insu.kim@moreh.io>
1 parent 419dd10 commit f93aff3

File tree

5 files changed

+38
-40
lines changed

5 files changed

+38
-40
lines changed

utils/11-crio-ipv4-bridge.conflist

Lines changed: 0 additions & 22 deletions
This file was deleted.

utils/init-kubernetes-controlplane-node.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@
44
# for more information.
55
# This script will create a Kubernetes cluster using kubeadm.
66

7+
# IMPORTANT: THIS STEP IS REQUIRED FOR CNI SETUP VIA CALICO
8+
79
# Look for a line starting with "default via"
10+
# For example: default via 10.128.0.1 dev ens5
811
ip route show
912

13+
# Or get your network interface's ip address using the following command:
14+
export K8S_NET_IP=$(ip addr show dev $(ip route show | awk '/^default/ {print $5}') | awk '/inet / {print $2}' | cut -d/ -f1)
15+
echo "K8S_NET_IP=${K8S_NET_IP}"
16+
1017
# On one of your nodes which to become a control node, execute following command:
11-
sudo kubeadm init --cri-socket=unix:///var/run/crio/crio.sock
18+
sudo kubeadm init \
19+
--cri-socket=unix:///var/run/crio/crio.sock \
20+
--apiserver-advertise-address=${K8S_NET_IP} \
21+
--pod-network-cidr=192.168.0.0/16
1222

1323
# The output will look like this:
1424
# --------------------------------------------------------------------------------

utils/install-calico.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Refer to https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
4+
# for more information.
5+
6+
# Install the Tigera operator and custom resource definitions:
7+
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.30.0/manifests/tigera-operator.yaml
8+
9+
# Install Calico by creating the necessary custom resources:
10+
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.30.0/manifests/custom-resources.yaml

utils/install-cri-o.sh

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,23 @@ echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://download.o
2222
sudo apt-get update
2323
sudo apt-get install -y cri-o
2424

25+
# Update crio config by creating (or editing) /etc/crio/crio.conf
26+
sudo tee /etc/crio/crio.conf > /dev/null <<EOF
27+
[crio.image]
28+
pause_image="registry.k8s.io/pause:3.10"
29+
30+
[crio.runtime]
31+
conmon_cgroup = "pod"
32+
cgroup_manager = "systemd"
33+
EOF
34+
2535
# Start CRI-O
2636
sudo systemctl start crio.service
2737

2838
sudo swapoff -a
2939
sudo modprobe br_netfilter
3040
sudo sysctl -w net.ipv4.ip_forward=1
3141

32-
# Update crio config by creating (or editing) /etc/crio/crio.conf
33-
# sudo vi /etc/crio/crio.conf
34-
# [crio.image]
35-
# pause_image="registry.k8s.io/pause:3.10"
36-
# [crio.runtime]
37-
# conmon_cgroup = "pod"
38-
# cgroup_manager = "systemd"
39-
40-
# sysctl params required by setup, params persist across reboots
41-
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
42-
net.ipv4.ip_forward = 1
43-
EOF
44-
4542
# Apply sysctl params without reboot
4643
sudo sysctl --system
4744

utils/join-kubernetes-worker-node.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717
sudo kubeadm join <YOUR_CONTROL_PLANE_NODE_IP> --token <YOUR_GENERATED_TOKEN> \
1818
--discovery-token-ca-cert-hash sha256:<YOUR_GENERATED_CA_CERT_HASH> --cri-socket=unix:///var/run/crio/crio.sock
1919

20+
exit 0
21+
2022
# If you lost above information, you can get the token and hash by running following command on your CONTROL PLANE node:
21-
# To get <YOUR_CONTROL_PLANE_NODE_IP>
22-
kubectl get nodes -o wide | grep -i control-plane | awk '{printf $6}'
23+
# To get <YOUR_CONTROL_PLANE_NODE_IP>:
24+
export K8S_NET_IP=$(ip addr show dev $(ip route show | awk '/^default/ {print $5}') | awk '/inet / {print $2}' | cut -d/ -f1)
25+
echo "K8S_NET_IP=${K8S_NET_IP}"
2326

24-
# To get <YOUR_GENERATED_TOKEN>
27+
# To get <YOUR_GENERATED_TOKEN>:
2528
sudo kubeadm token create
2629

27-
# To get <YOUR_GENERATED_CA_CERT_HASH>
30+
# To get <YOUR_GENERATED_CA_CERT_HASH>:
2831
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | \
2932
openssl rsa -pubin -outform der 2>/dev/null | \
3033
sha256sum | awk '{print $1}'

0 commit comments

Comments
 (0)