1. Install the kubeadm and kubelet packages on the controlplane and node01 nodes.
Use the exact version of 1.30.0-1.1 for both.
1-1. set net.bridge.bridge-nf-call-iptables to 1
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sudo sysctl --system
1-2. install container runtime.
해당 연구실실습에서는 설치되어 있다. (The container runtime has already been installed on both nodes, so you may skip this step.)
1-3. Install kubeadm, kubectl and kubelet on all nodes
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
# To see the new version labels
sudo apt-cache madison kubeadm
sudo apt-get install -y kubelet=1.30.0-1.1 kubeadm=1.30.0-1.1 kubectl=1.30.0-1.1
sudo apt-mark hold kubelet kubeadm kubectl
위과정을 controlplane 과 node01 에서 각각 진행시킨다.
2. What is the version of kubelet installed?
controlplane ~ ➜ kubelet --version
Kubernetes v1.30.0
3. How many nodes are part of kubernetes cluster currently? Are you able to run kubectl get nodes?
controlplane ~ ✖ k get nodes -A
E0825 08:08:03.743519 27576 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E0825 08:08:03.744542 27576 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E0825 08:08:03.745555 27576 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E0825 08:08:03.746575 27576 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
E0825 08:08:03.747556 27576 memcache.go:265] couldn't get current server API group list: the server could not find the requested resource
Error from server (NotFound): the server could not find the requested resource
answer : 0
4. Lets now bootstrap a kubernetes cluster using kubeadm. The latest version of Kubernetes will be installed.
5.
Initialize Control Plane Node (Master Node).
Use the following options:
1) apiserver-advertise-address - Use the IP address allocated to eth0 on the controlplane node
2) apiserver-cert-extra-sans - Set it to controlplane
3) pod-network-cidr - Set to 10.244.0.0/16
Once done, set up the default kubeconfig file and wait for node to be part of the cluster.
IP_ADDR=$(ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
kubeadm init --apiserver-cert-extra-sans=controlplane --apiserver-advertise-address $IP_ADDR --pod-network-cidr=10.244.0.0/16
설치 완료후
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
6. Generate a kubeadm join token Or copy the one that was generated by kubeadm init command
7. Join node01 to the cluster using the join token
controlplane ~ ➜ kubeadm token create --print-join-command
kubeadm join 192.11.220.3:6443 --token wj1nt9.ozyj03w85ietw4rf --discovery-token-ca-cert-hash sha256:cb2dfc43275590a8a2149fa0b81f1eb9f1f1644f2399e4d350c3941059144b52
controlplane ~ ➜ ssh node01^C
controlplane ~ ✖ ssh node01
Last login: Sun Aug 25 08:16:27 2024 from 192.11.220.4
node01 ~ ➜ kubeadm join 192.11.220.3:6443 --token wj1nt9.ozyj03w85ietw4rf --discovery-token-ca-cert-hash sha256:cb2dfc43275590a8a2149fa0b81f1eb9f1f1644f2399e4d350c3941059144b52
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-check] Waiting for a healthy kubelet. This can take up to 4m0s
[kubelet-check] The kubelet is healthy after 1.001643599s
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap
This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.
Run 'kubectl get nodes' on the control-plane to see this node join the cluster.
8. To install a network plugin, we will go with Flannel as the default choice.
For inter-host communication, we will utilize the eth0 interface.
Please ensure that the Flannel manifest includes the appropriate options for this configuration.
Refer to the official documentation for the procedure.
8-1. Flannel yaml 설치파일 다운로드
# Download the original YAML file and save it as kube-flannel.yml
curl -LO https://raw.githubusercontent.com/flannel-io/flannel/v0.20.2/Documentation/kube-flannel.yml
8-2. 다운로드된 파일에서 해당 파일 추가. (네트워크 인터페이스 eht0 설정내용)
vi kube-flannel.yaml
## in kube-flannel.yaml
...
args:
- --ip-masq
- --kube-subnet-mgr
- --iface=eth0 # 항목추가
...
controlplane ~ ➜ k apply -f kube-flannel.yml
namespace/kube-flannel created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created
8-3. 설치확인.
# 설치전
controlplane ~ ➜ k get nodes
NAME STATUS ROLES AGE VERSION
controlplane NotReady control-plane 104s v1.30.0
node01 NotReady <none> 17s v1.30.0
# 설치후
controlplane ~ ➜ k get nodes
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 5m9s v1.30.0
node01 Ready <none> 3m42s v1.30.0
'IT 기술 > k8s' 카테고리의 다른 글
[cka] TroubleShooting - Control Plane Failure (0) | 2024.08.25 |
---|---|
[cka] TroubleShooting - Application Failure (0) | 2024.08.25 |
[cka] Ingress Networking - 2 (0) | 2024.08.13 |
[cka] Ingress Networking - 1 (0) | 2024.08.13 |
[cka] CoreDNS in Kubernetes (0) | 2024.08.10 |
댓글