[Kubernetes] 쿠버네티스 미니홈서버 구축해보기 - 5 - Master Node Control Plane설정해보기
```
[k8s] 쿠버네티스 미니홈서버 구축해보기 - 5 - Master Node Control Plane설정해보기
```
이번 글을 통해 배워갈 내용
- Kubeadm 설명
- 설치전 SSH 접근 설정
- Kubeadm 및 Control plane 설치
- 기초보안
1. Kubeadm 설명
Kubeadm은 쿠버네티스(Kubernetes) 프로젝트에서 개발된 도구로, 순수 쿠버네티스를 실행하는 클러스터를 설정하는 데 사용됩니다.
Minikube, MicroK8s, K3s와 같은 도구에 비해 Kubeadm으로 클러스터를 만드는 과정은 조금 더 복잡합니다.
먼저 각 노드에 컨테이너 런타임을 직접 설치하고, 클러스터 제어 평면을 설정한 뒤, 네트워킹 플러그인을 추가하고,
작업 노드를 마스터에 연결해야 합니다.
즉, 클러스터를 구성하려면 더 많은 단계를 거쳐야 하며, 필요한 추가 소프트웨어도 직접 설치해야 합니다.
이 글에서는 Ubuntu 24에 kubeadm 설치 kube api 설치 그리고 calico 설치도 합니다.
2. 설치전 SSH 접근 설정
설치전 접속보안설정
접속설정1 OpenSSH 설정
https://codemasterkimc.tistory.com/568
우분투22.04 SSH 설정하고 Putty로 접속하기
SSH(Secure Shell) 말 그대로 보안 쉘, 원격 접속을 위해서 사용되는 프로토콜 기본적으로 CLI로 원격 접속할 때 사용합니다 사전작업으로 고정아이피를 설정합니다https://codemasterkimc.tisto
codemasterkimc.tistory.com
접속설정2 Ubuntu SSH 보안 강화 기초 – RSA 키 생성 및 PuTTY 활용법
https://codemasterkimc.tistory.com/733
Ubuntu SSH 보안 강화 기초 – RSA 키 생성 및 PuTTY 활용법
배워갈 내용개요실습 1 신규 키 생성실습 2 기존 키 활용추가 팁개요SSH(Secure Shell)는 원격 서버에 안전하게 접속하기 위한 필수 도구입니다. 하지만 단순 비밀번호 방식은 보안 취약점
codemasterkimc.tistory.com
3. Kubeadm 및 Control plane 설치
설치전 접속보안설정
접속설정1 OpenSSH 설정
3-1 시스템 업데이트
sudo apt update && sudo apt upgrade -y
3-2 도커 혹은 Containerd 설치 (둘중하나만)
도커
# sudo apt update && sudo apt install -y docker.io
# sudo systemctl enable --now docker
ContainerD
sudo apt install containerd -y
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml > /dev/null
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
sudo systemctl restart containerd
참조글
https://kubernetes.io/docs/setup/production-environment/container-runtimes/
Container Runtimes
Note: Dockershim has been removed from the Kubernetes project as of release 1.24. Read the Dockershim Removal FAQ for further details. You need to install a container runtime into each node in the cluster so that Pods can run there. This page outlines what
kubernetes.io
3-3
Swap 비활성화
sudo swapoff -a && sudo sed -i '/swap/d' /etc/fstab
sudo nano /etc/fstab
#주석처리 /swapfile none swap sw 0 0
#주석처리 UUID=xxxx-xxxx-xxxx-xxxx none swap sw 0 0
free -h
swapon --summary
참조
https://serverfault.com/questions/881517/why-disable-swap-on-kubernetes
Why disable swap on kubernetes
Since Kubernetes 1.8, it seems I need to disable swap on my nodes (or set --fail-swap-on to false). I cannot find the technical reason why Kubernetes insists on the swap being disabled. Is this for
serverfault.com
3-4
커널 모듈 설정
sudo modprobe overlay
sudo modprobe br_netfilter
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
sudo sysctl --system
3-5
kubeadm 설치
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gpg
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/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.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
3-6
Kubernetes Control Plane 초기화
sudo kubeadm init --control-plane-endpoint=<your-ip> --pod-network-cidr=10.244.0.0/16
필요시 도메인 주소로 세팅
# sudo kubeadm init --control-plane-endpoint=<your-ddns-hostname> --pod-network-cidr=10.244.0.0/16
3-7
설치완료
완료 후에 나오는 문구 실행
export KUBECONFIG=/etc/kubernetes/admin.conf
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
3-8
컨테이너 네트워킹 아래 글을 읽고 골라서 진행 해주시면 됩니다
https://www.tigera.io/learn/guides/cilium-vs-calico/
Cilium vs Calico
Calico is an open-source networking and security solution for containers and VMs, supporting platforms like Kubernetes and Docker. Cilium, based on eBPF, offers cloud-native networking and security.
www.tigera.io
아래중에 선택
Calico
Flannel
Weave Net
Cilium
만약 Calico 진행시 아래와 같이 진행합니다
최신버전은 아래 글 참조
https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
Tutorial: Quickstart on Kubernetes | Calico Documentation
Install Calico on a single-host Kubernetes cluster for testing or development in under 15 minutes.
docs.tigera.io
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.29.2/manifests/tigera-operator.yaml
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.29.2/manifests/custom-resources.yaml
# 필요시 cidr 등 값확인 후 변경
# 10.0.0.0/16 을 추천The 10.x.x.x range is commonly used in private networks and Kubernetes setups.
nano custom-resources.yaml
nano tigera-operator.yaml
k create -f custom-resources.yaml
k create -f tigera-operator.yaml
필요시 taint 제거 후 추가
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoSchedule-
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoExecute-
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoSchedule
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoExecute
이제 설치 완료가 되었습니다.

4. 기초보안
방화벽으로 외부 접근 막기
sudo ufw allow from 127.0.0.1 to any port 6443
sudo ufw allow from <워커노드_IP> to any port 6443
sudo ufw deny 6443
sudo ufw enable
SSH를 공개 키로만 설정
https://codemasterkimc.tistory.com/733
Ubuntu SSH 보안 강화 기초 – RSA 키 생성 및 PuTTY 활용법
배워갈 내용개요실습 1 신규 키 생성실습 2 기존 키 활용추가 팁개요SSH(Secure Shell)는 원격 서버에 안전하게 접속하기 위한 필수 도구입니다. 하지만 단순 비밀번호 방식은 보안 취약점
codemasterkimc.tistory.com
RBAC로 API 접근 제한.
# --authorization-mode=RBAC이 포함되어 있는지 확인.
sudo nano /etc/kubernetes/manifests/kube-apiserver.yaml
# 불필요한 익명 접근 막기: --anonymous-auth=false 추가
etcd 암호화하고 포트 차단.
sudo nano /etc/kubernetes/manifests/etcd.yaml
--cert-file, --key-file, --peer-cert-file 등이 설정돼 있는지 확인
etcd 포트 방화벽 설정
sudo ufw deny 2379
네트워크 정책으로 파드 통신 제어.
TLS 인증서 점검
ls /etc/kubernetes/pki/
Kubeconfig 파일 잠그기.
sudo chmod 600 /etc/kubernetes/admin.conf
sudo chown root:root /etc/kubernetes/admin.conf
최신 보안 패치로 유지
모니터링: 감사 로그를 켜서 누가 뭘 했는지 기록
kube-apiserver.yaml에 --audit-log-path=/var/log/kube-audit.log 추가.
백업: etcd 데이터를 주기적으로 백업
ETCDCTL_API=3 etcdctl snapshot save backup.db
Trouble Shooting
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/troubleshooting-kubeadm/
Troubleshooting kubeadm
As with any program, you might run into an error installing or running kubeadm. This page lists some common failure scenarios and have provided steps that can help you understand and fix the problem. If your problem is not listed below, please follow the f
kubernetes.io
읽어주셔서 감사합니다
무엇인가 얻어가셨기를 바라며
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
참조 및 인용
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
Installing kubeadm
This page shows how to install the kubeadm toolbox. For information on how to create a cluster with kubeadm once you have performed this installation process, see the Creating a cluster with kubeadm page. This installation guide is for Kubernetes v1.32. If
kubernetes.io
'DevOps > Kubernetes' 카테고리의 다른 글
쿠버네티스 미니홈서버 구축해보기 - 7 - Proxmox에서 프라이빗 네트워크 만들고 VM 연결하기 (1) | 2025.03.03 |
---|---|
쿠버네티스 미니홈서버 구축해보기 - 6 - Proxmox 방화벽 점검해보기 (0) | 2025.03.02 |
쿠버네티스 미니홈서버 구축해보기 - 4 - PROXMOX Ubuntu VM 세팅하기 (2) | 2025.02.26 |
쿠버네티스 미니홈서버 구축해보기 - 3 - PROXMOX 보안설정하기 (0) | 2025.02.25 |
쿠버네티스 미니홈서버 구축해보기 - 2 - PROXMOX 설치하기 (0) | 2025.02.25 |
[Kubernetes] 쿠버네티스 미니홈서버 구축해보기 - 5 - Master Node Control Plane설정해보기
```
[k8s] 쿠버네티스 미니홈서버 구축해보기 - 5 - Master Node Control Plane설정해보기
```

이번 글을 통해 배워갈 내용
- Kubeadm 설명
- 설치전 SSH 접근 설정
- Kubeadm 및 Control plane 설치
- 기초보안
1. Kubeadm 설명
Kubeadm은 쿠버네티스(Kubernetes) 프로젝트에서 개발된 도구로, 순수 쿠버네티스를 실행하는 클러스터를 설정하는 데 사용됩니다.
Minikube, MicroK8s, K3s와 같은 도구에 비해 Kubeadm으로 클러스터를 만드는 과정은 조금 더 복잡합니다.
먼저 각 노드에 컨테이너 런타임을 직접 설치하고, 클러스터 제어 평면을 설정한 뒤, 네트워킹 플러그인을 추가하고,
작업 노드를 마스터에 연결해야 합니다.
즉, 클러스터를 구성하려면 더 많은 단계를 거쳐야 하며, 필요한 추가 소프트웨어도 직접 설치해야 합니다.
이 글에서는 Ubuntu 24에 kubeadm 설치 kube api 설치 그리고 calico 설치도 합니다.
2. 설치전 SSH 접근 설정
설치전 접속보안설정
접속설정1 OpenSSH 설정
https://codemasterkimc.tistory.com/568
우분투22.04 SSH 설정하고 Putty로 접속하기
SSH(Secure Shell) 말 그대로 보안 쉘, 원격 접속을 위해서 사용되는 프로토콜 기본적으로 CLI로 원격 접속할 때 사용합니다 사전작업으로 고정아이피를 설정합니다https://codemasterkimc.tisto
codemasterkimc.tistory.com
접속설정2 Ubuntu SSH 보안 강화 기초 – RSA 키 생성 및 PuTTY 활용법
https://codemasterkimc.tistory.com/733
Ubuntu SSH 보안 강화 기초 – RSA 키 생성 및 PuTTY 활용법
배워갈 내용개요실습 1 신규 키 생성실습 2 기존 키 활용추가 팁개요SSH(Secure Shell)는 원격 서버에 안전하게 접속하기 위한 필수 도구입니다. 하지만 단순 비밀번호 방식은 보안 취약점
codemasterkimc.tistory.com
3. Kubeadm 및 Control plane 설치
설치전 접속보안설정
접속설정1 OpenSSH 설정
3-1 시스템 업데이트
sudo apt update && sudo apt upgrade -y
3-2 도커 혹은 Containerd 설치 (둘중하나만)
도커
# sudo apt update && sudo apt install -y docker.io
# sudo systemctl enable --now docker
ContainerD
sudo apt install containerd -y
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml > /dev/null
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
sudo systemctl restart containerd
참조글
https://kubernetes.io/docs/setup/production-environment/container-runtimes/
Container Runtimes
Note: Dockershim has been removed from the Kubernetes project as of release 1.24. Read the Dockershim Removal FAQ for further details. You need to install a container runtime into each node in the cluster so that Pods can run there. This page outlines what
kubernetes.io
3-3
Swap 비활성화
sudo swapoff -a && sudo sed -i '/swap/d' /etc/fstab
sudo nano /etc/fstab
#주석처리 /swapfile none swap sw 0 0
#주석처리 UUID=xxxx-xxxx-xxxx-xxxx none swap sw 0 0
free -h
swapon --summary
참조
https://serverfault.com/questions/881517/why-disable-swap-on-kubernetes
Why disable swap on kubernetes
Since Kubernetes 1.8, it seems I need to disable swap on my nodes (or set --fail-swap-on to false). I cannot find the technical reason why Kubernetes insists on the swap being disabled. Is this for
serverfault.com
3-4
커널 모듈 설정
sudo modprobe overlay
sudo modprobe br_netfilter
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
sudo sysctl --system
3-5
kubeadm 설치
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gpg
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/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.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
3-6
Kubernetes Control Plane 초기화
sudo kubeadm init --control-plane-endpoint=<your-ip> --pod-network-cidr=10.244.0.0/16
필요시 도메인 주소로 세팅
# sudo kubeadm init --control-plane-endpoint=<your-ddns-hostname> --pod-network-cidr=10.244.0.0/16
3-7
설치완료
완료 후에 나오는 문구 실행
export KUBECONFIG=/etc/kubernetes/admin.conf
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
3-8
컨테이너 네트워킹 아래 글을 읽고 골라서 진행 해주시면 됩니다
https://www.tigera.io/learn/guides/cilium-vs-calico/
Cilium vs Calico
Calico is an open-source networking and security solution for containers and VMs, supporting platforms like Kubernetes and Docker. Cilium, based on eBPF, offers cloud-native networking and security.
www.tigera.io
아래중에 선택
Calico
Flannel
Weave Net
Cilium
만약 Calico 진행시 아래와 같이 진행합니다
최신버전은 아래 글 참조
https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
Tutorial: Quickstart on Kubernetes | Calico Documentation
Install Calico on a single-host Kubernetes cluster for testing or development in under 15 minutes.
docs.tigera.io
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.29.2/manifests/tigera-operator.yaml
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.29.2/manifests/custom-resources.yaml
# 필요시 cidr 등 값확인 후 변경
# 10.0.0.0/16 을 추천The 10.x.x.x range is commonly used in private networks and Kubernetes setups.
nano custom-resources.yaml
nano tigera-operator.yaml
k create -f custom-resources.yaml
k create -f tigera-operator.yaml
필요시 taint 제거 후 추가
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoSchedule-
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoExecute-
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoSchedule
kubectl taint nodes <node-name> node.kubernetes.io/not-ready:NoExecute
이제 설치 완료가 되었습니다.

4. 기초보안
방화벽으로 외부 접근 막기
sudo ufw allow from 127.0.0.1 to any port 6443
sudo ufw allow from <워커노드_IP> to any port 6443
sudo ufw deny 6443
sudo ufw enable
SSH를 공개 키로만 설정
https://codemasterkimc.tistory.com/733
Ubuntu SSH 보안 강화 기초 – RSA 키 생성 및 PuTTY 활용법
배워갈 내용개요실습 1 신규 키 생성실습 2 기존 키 활용추가 팁개요SSH(Secure Shell)는 원격 서버에 안전하게 접속하기 위한 필수 도구입니다. 하지만 단순 비밀번호 방식은 보안 취약점
codemasterkimc.tistory.com
RBAC로 API 접근 제한.
# --authorization-mode=RBAC이 포함되어 있는지 확인.
sudo nano /etc/kubernetes/manifests/kube-apiserver.yaml
# 불필요한 익명 접근 막기: --anonymous-auth=false 추가
etcd 암호화하고 포트 차단.
sudo nano /etc/kubernetes/manifests/etcd.yaml
--cert-file, --key-file, --peer-cert-file 등이 설정돼 있는지 확인
etcd 포트 방화벽 설정
sudo ufw deny 2379
네트워크 정책으로 파드 통신 제어.
TLS 인증서 점검
ls /etc/kubernetes/pki/
Kubeconfig 파일 잠그기.
sudo chmod 600 /etc/kubernetes/admin.conf
sudo chown root:root /etc/kubernetes/admin.conf
최신 보안 패치로 유지
모니터링: 감사 로그를 켜서 누가 뭘 했는지 기록
kube-apiserver.yaml에 --audit-log-path=/var/log/kube-audit.log 추가.
백업: etcd 데이터를 주기적으로 백업
ETCDCTL_API=3 etcdctl snapshot save backup.db
Trouble Shooting
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/troubleshooting-kubeadm/
Troubleshooting kubeadm
As with any program, you might run into an error installing or running kubeadm. This page lists some common failure scenarios and have provided steps that can help you understand and fix the problem. If your problem is not listed below, please follow the f
kubernetes.io
읽어주셔서 감사합니다
무엇인가 얻어가셨기를 바라며
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
참조 및 인용
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
Installing kubeadm
This page shows how to install the kubeadm toolbox. For information on how to create a cluster with kubeadm once you have performed this installation process, see the Creating a cluster with kubeadm page. This installation guide is for Kubernetes v1.32. If
kubernetes.io
'DevOps > Kubernetes' 카테고리의 다른 글
쿠버네티스 미니홈서버 구축해보기 - 7 - Proxmox에서 프라이빗 네트워크 만들고 VM 연결하기 (1) | 2025.03.03 |
---|---|
쿠버네티스 미니홈서버 구축해보기 - 6 - Proxmox 방화벽 점검해보기 (0) | 2025.03.02 |
쿠버네티스 미니홈서버 구축해보기 - 4 - PROXMOX Ubuntu VM 세팅하기 (2) | 2025.02.26 |
쿠버네티스 미니홈서버 구축해보기 - 3 - PROXMOX 보안설정하기 (0) | 2025.02.25 |
쿠버네티스 미니홈서버 구축해보기 - 2 - PROXMOX 설치하기 (0) | 2025.02.25 |