기타/자격증

[CKA][실습] 8. Install

백곰곰 2023. 6. 19. 22:33
728x90
반응형

Practice Test - Cluster Installation Using Kubeadm

# 기본 설정(https://kubernetes.io/docs/setup/production-environment/container-runtimes/)
$ cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

$ sudo modprobe overlay
$ sudo modprobe br_netfilter

# sysctl params required by setup, params persist across reboots
$ cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

# Apply sysctl params without reboot
$ sudo sysctl --system

kubeadm 설치 (https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/)

# OS 버전 확인
$ cat /etc/*release*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

# kubeadm 설치 (controlplane, node01 동일)
$ sudo apt-get update
$ sudo apt-get install -y apt-transport-https ca-certificates curl
$ mkdir -p /etc/apt/keyrings
$ sudo curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg
$ echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

$ sudo apt-get update && apt-get install -y kubelet=1.27.0-00 kubeadm=1.27.0-00 kubectl=1.27.0-00
$ sudo apt-mark hold kubelet kubeadm kubectl

control plane init (https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#initializing-your-control-plane-node)

$ kubelet --version
Kubernetes v1.27.

$ ifconfig -a
...
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 192.23.110.6  netmask 255.255.255.0  broadcast 192.23.110.255
        ether 02:42:c0:17:6e:06  txqueuelen 0  (Ethernet)
        RX packets 5983  bytes 681402 (681.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5066  bytes 1532227 (1.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
...
$ kubeadm init --apiserver-advertise-address=192.23.110.6 \
--apiserver-cert-extra-sans=controlplane \
--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
$ export KUBECONFIG=/etc/kubernetes/admin.conf

노드 join (https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#more-information)

$ kubeadm token create
isqrs2.pid2vl9getydnjzp

$ openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | \
>    openssl dgst -sha256 -hex | sed 's/^.* //'
bf0096882e5692f7d3bf4fc2cbda0a3185217b1efac39824d7e73c58d9da0e30

# node01
$ kubeadm join 192.23.110.6:6443 --token isqrs2.pid2vl9getydnjzp --discovery-token-ca-cert-hash sha256:bf0096882e5692f7d3bf4fc2cbda0a3185217b1efac39824d7e73c58d9da0e30
$ kubectl get no
NAME           STATUS     ROLES           AGE     VERSION
controlplane   NotReady   control-plane   5m45s   v1.27.0
node01         NotReady   <none>          11s     v1.27.0

flannel 설치 (https://github.com/flannel-io/flannel/blob/master/Documentation/backends.md)

$ wget https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
$ vi kube-flannel.yml
...
                - linux
      containers:
      - args:
        - --ip-masq
        - --kube-subnet-mgr
        - --iface=eth0
...
$ kubectl apply -f kube-flannel.yml
$ kubectl get no
NAME           STATUS   ROLES           AGE     VERSION
controlplane   Ready    control-plane   11m     v1.27.0
node01         Ready    <none>          5m35s   v1.27.0
728x90

'기타 > 자격증' 카테고리의 다른 글

[CKA][실습] 9. Networking (2)  (0) 2023.06.22
[CKA][실습] 9. Networking  (0) 2023.06.19
[CKA][실습] 7. Storage  (0) 2023.06.12
[CKA][실습] 6. Security (4)  (2) 2023.05.14
[CKA][실습] 6. Security (3)  (1) 2023.05.11