728x90
쿠버네티스 마스터 (Ubuntu Desktop 20.04 LTS)
- GUI 환경의 리눅스로 설치한다.
- 4GM RAM
- 2CPU
- HDD : 20G
- IP : 192.168.187.11/24
참조 : https://github.com/bjpublic/core_kubernetes
▣ OpenSSH Server 설치
student@Master:~$ sudo apt update
student@Master:~$ sudo apt install openssh-server
student@Master:~$ sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: e>
Active: active (running) since Fri 2022-08-19 07:24:08 KST; 23s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 5532 (sshd)
Tasks: 1 (limit: 4577)
Memory: 1.0M
CGroup: /system.slice/ssh.service
└─5532 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
8월 19 07:24:08 Master systemd[1]: Starting OpenBSD Secure Shell server...
8월 19 07:24:08 Master sshd[5532]: Server listening on 0.0.0.0 port 22.
8월 19 07:24:08 Master sshd[5532]: Server listening on :: port 22.
8월 19 07:24:08 Master systemd[1]: Started OpenBSD Secure Shell server.
lines 1-15/15 (END)
▣ 방화벽에서 SSH 허용하기
student@Master:~$ sudo ufw status
Status: inactive
student@Master:~$
▣ 방화벽이 켜져 있다면 다음 명령어로 ssh를 허용하자.
student@Master:~$ sudo ufw allow ssh
Rules updated
Rules updated (v6)
student@Master:~$
▣ 마스터 노드 설치
sudo apt update
sudo apt install -y docker.io nfs-common dnsutils curl
# k3s 마스터 설치
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="\
--disable traefik \
--disable metrics-server \
--node-name master --docker" \
INSTALL_K3S_VERSION="v1.18.6+k3s1" sh -s -
# 마스터 통신을 위한 설정
mkdir ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown -R $(id -u):$(id -g) ~/.kube
echo "export KUBECONFIG=~/.kube/config" >> ~/.bashrc
source ~/.bashrc
# 설치 확인
kubectl cluster-info
# Kubernetes master is running at https://127.0.0.1:6443
# CoreDNS is running at https://127.0.0.1:6443/api/v1/namespaces...
#
# To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
student@master:~/Desktop$ kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master Ready master 7m25s v1.18.6+k3s1 192.168.187.11 <none> Ubuntu 20.04.4 LTS 5.15.0-46-generic docker://20.10.12
student@master:~/Desktop$
kubectl get node 라는 명령으로 master가 보이고 Status가 Ready로 확인할 수 있다면 일단 마스터 노드는 정상적으로 설치가 된 것이다.
이제 클러스터에 워커 노드를 추가하기 위해 마스터 노드에서 NODE_TOKEN 값과 마슽터 노드의 IP인 MASTER_IP를 다음과 같이 확인한다.
student@master:~$ NODE_TOKEN=$(sudo cat /var/lib/rancher/k3s/server/node-token)
student@master:~$ echo $NODE_TOKEN
K10ad7a8c414ee02580edf3d8b0b7c96ff717fc8af941e5a026d19a1d26f2b8c546::server:03898fe3300a3af5a85e19be555b95e8
student@master:~$
위 값들을 확인하고 복사하여 별도로 준비하여 둔다. 이후에 워커 노드에서 사용한다.
▣ 워커 노드 설치
student@Worker:~$ NODE_TOKEN=K10ad7a8c414ee02580edf3d8b0b7c96ff717fc8af941e5a026d19a1d26f2b8c546::server:03898fe3300a3af5a85e19be555b95e8
student@Worker:~$ MASTER_IP=192.168.187.11
NODE_TOKEN=<마스터에서 확인한 토큰 입력>
MASTER_IP=<마스터에서 얻은 내부IP 입력>
sudo apt update
sudo apt install -y docker.io nfs-common curl
student@Worker:~$ sudo apt update
Hit:1 http://jp.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
student@Worker:~$ sudo apt install -y docker.io nfs-common curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
bridge-utils containerd git git-man keyutils liberror-perl libnfsidmap2 libtirpc-common libtirpc3 pigz rpcbind runc ubuntu-fan
Suggested packages:
ifupdown aufs-tools btrfs-progs cgroupfs-mount | cgroup-lite debootstrap docker-doc rinse zfs-fuse | zfsutils git-daemon-run | git-daemon-sysvinit
git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn open-iscsi watchdog
The following NEW packages will be ~~~~
# k3s 워커 설치
curl -sfL https://get.k3s.io | K3S_URL=https://$MASTER_IP:6443 \
K3S_TOKEN=$NODE_TOKEN \
INSTALL_K3S_EXEC="--node-name worker --docker" \
INSTALL_K3S_VERSION="v1.18.6+k3s1" sh -s -
student@Worker:~$ curl -sfL https://get.k3s.io | K3S_URL=https://$MASTER_IP:6443 \
> K3S_TOKEN=$NODE_TOKEN \
> INSTALL_K3S_EXEC="--node-name worker --docker" \
> INSTALL_K3S_VERSION="v1.18.6+k3s1" sh -s -
[INFO] Using v1.18.6+k3s1 as release
[INFO] Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.18.6+k3s1/sha256sum-amd64.txt
[INFO] Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.18.6+k3s1/k3s
[INFO] Verifying binary download
[INFO] Installing k3s to /usr/local/bin/k3s
[INFO] Skipping installation of SELinux RPM
[INFO] Creating /usr/local/bin/kubectl symlink to k3s
[INFO] Creating /usr/local/bin/crictl symlink to k3s
[INFO] Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
[INFO] Creating killall script /usr/local/bin/k3s-killall.sh
[INFO] Creating uninstall script /usr/local/bin/k3s-agent-uninstall.sh
[INFO] env: Creating environment file /etc/systemd/system/k3s-agent.service.env
[INFO] systemd: Creating service file /etc/systemd/system/k3s-agent.service
[INFO] systemd: Enabling k3s-agent unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s-agent.service → /etc/systemd/system/k3s-agent.service.
[INFO] systemd: Starting k3s-agent
student@Worker:~$
이제 마스터 노드에서 워커 노드가 추가되었는지 확인할 수 있다.
student@master:~$ kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master Ready master 147m v1.18.6+k3s1 192.168.187.11 <none> Ubuntu 20.04.4 LTS 5.15.0-46-generic docker://20.10.12
worker Ready <none> 37s v1.18.6+k3s1 192.168.187.12 <none> Ubuntu 20.04.4 LTS 5.15.0-46-generic docker://20.10.12
student@master:~$
728x90
'DevOps > DockerKubernetes' 카테고리의 다른 글
YAML 파일을 이용하여 컨테이너의 생성 (0) | 2022.08.20 |
---|---|
쿠버네티스 기본 명령어 (0) | 2022.08.16 |
Ubuntu에 Minikube 설치하기 (0) | 2022.08.16 |
컨테이너와 Docker Host간의 파일 복사 (0) | 2022.08.11 |
가상화와 컨테이너의 차이는 무엇? (0) | 2022.08.11 |