☁️ Cloud

Control Plane

Kubernetes Control Plane (Master Components)

The set of Kubernetes components that manage and control the cluster. Composed of the API Server, etcd, Scheduler, and Controller Manager.

📖 Detailed Explanation

The Control Plane is the set of components that acts as the "brain" of a Kubernetes cluster. It manages the overall state of the cluster and is responsible for core functions such as workload scheduling, event detection, and maintaining the desired state (Desired State).

Core components of the Control Plane:

In production environments, the Control Plane is distributed across three or more nodes for high availability (HA). In particular, etcd uses the Raft consensus algorithm, so it must be configured with an odd number of nodes (3, 5, 7). Managed services such as AWS EKS, GKE, and AKS manage the Control Plane automatically.

💻 Code Example

# Control Plane 컴포넌트 상태 확인

# 클러스터 전체 상태 확인
kubectl cluster-info
# Kubernetes control plane is running at https://api.k8s.company.com:6443
# CoreDNS is running at https://api.k8s.company.com:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

# Control Plane 컴포넌트 상태
kubectl get componentstatuses
# NAME                 STATUS    MESSAGE             ERROR
# scheduler            Healthy   ok
# controller-manager   Healthy   ok
# etcd-0               Healthy   {"health":"true"}

# kube-system 네임스페이스의 Control Plane Pod 확인
kubectl get pods -n kube-system -l tier=control-plane
# NAME                                       READY   STATUS    RESTARTS
# etcd-master-1                              1/1     Running   0
# kube-apiserver-master-1                    1/1     Running   0
# kube-controller-manager-master-1           1/1     Running   0
# kube-scheduler-master-1                    1/1     Running   0

# API Server 엔드포인트 확인
kubectl get endpoints kubernetes -n default
# NAME         ENDPOINTS           AGE
# kubernetes   10.0.0.10:6443      30d

# etcd 클러스터 멤버 확인 (etcd Pod에서 실행)
kubectl exec -it etcd-master-1 -n kube-system -- etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  member list -w table

# etcd 클러스터 상태
kubectl exec -it etcd-master-1 -n kube-system -- etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  endpoint health

# API Server 메트릭 확인 (Prometheus 엔드포인트)
kubectl get --raw /metrics | head -50

# Scheduler가 Pod를 스케줄하는 과정 확인
kubectl get events --field-selector reason=Scheduled -A

# Controller Manager 리더 선출 상태 확인
kubectl get lease -n kube-system kube-controller-manager -o yaml
# kubeadm으로 HA Control Plane 구성

# kubeadm-config.yaml - HA 클러스터 설정
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
kubernetesVersion: v1.28.0
controlPlaneEndpoint: "k8s-api.company.com:6443"  # Load Balancer VIP
networking:
  podSubnet: "10.244.0.0/16"
  serviceSubnet: "10.96.0.0/12"
apiServer:
  extraArgs:
    audit-log-path: /var/log/kubernetes/audit.log
    audit-log-maxage: "30"
    audit-log-maxbackup: "10"
    audit-log-maxsize: "100"
    enable-admission-plugins: NodeRestriction,PodSecurityPolicy
  certSANs:
  - "k8s-api.company.com"
  - "10.0.0.100"
  - "master-1"
  - "master-2"
  - "master-3"
controllerManager:
  extraArgs:
    bind-address: "0.0.0.0"
    terminated-pod-gc-threshold: "100"
scheduler:
  extraArgs:
    bind-address: "0.0.0.0"
etcd:
  local:
    dataDir: /var/lib/etcd
    extraArgs:
      quota-backend-bytes: "8589934592"  # 8GB
      auto-compaction-retention: "8"
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: InitConfiguration
localAPIEndpoint:
  advertiseAddress: "10.0.0.11"
  bindPort: 6443
nodeRegistration:
  criSocket: unix:///var/run/containerd/containerd.sock
  taints:
  - effect: NoSchedule
    key: node-role.kubernetes.io/control-plane

---
# 첫 번째 Control Plane 노드 초기화
sudo kubeadm init --config kubeadm-config.yaml --upload-certs

# 출력된 join 명령어로 다른 Control Plane 노드 추가
# kubeadm join k8s-api.company.com:6443 --token  \
#   --discovery-token-ca-cert-hash sha256: \
#   --control-plane --certificate-key 

# etcd 백업 (정기적으로 실행)
ETCDCTL_API=3 etcdctl snapshot save /backup/etcd-$(date +%Y%m%d).db \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key

# etcd 백업 검증
etcdctl snapshot status /backup/etcd-20240115.db -w table
# Control Plane 트러블슈팅

# 1. API Server 연결 문제 진단
# 인증서 만료 확인
kubeadm certs check-expiration
# CERTIFICATE                EXPIRES                  RESIDUAL TIME
# admin.conf                 Jan 15, 2025 09:00 UTC   364d
# apiserver                  Jan 15, 2025 09:00 UTC   364d
# apiserver-etcd-client      Jan 15, 2025 09:00 UTC   364d

# 인증서 갱신 (만료 전)
kubeadm certs renew all

# API Server 로그 확인
kubectl logs -n kube-system kube-apiserver-master-1 --tail=100

# crictl로 직접 컨테이너 로그 확인 (kubectl 불가 시)
sudo crictl logs $(sudo crictl ps | grep kube-apiserver | awk '{print $1}')

# 2. Scheduler 문제 진단
# Pending Pod가 스케줄되지 않는 이유 확인
kubectl describe pod  | grep -A 10 Events

# 노드 리소스 상태 확인
kubectl top nodes
kubectl describe node  | grep -A 20 "Allocated resources"

# Scheduler 로그에서 스케줄링 실패 원인 찾기
kubectl logs -n kube-system kube-scheduler-master-1 | grep -i "failed"

# 3. Controller Manager 문제 진단
# ReplicaSet이 Pod를 생성하지 못하는 경우
kubectl logs -n kube-system kube-controller-manager-master-1 | grep -i error

# 컨트롤러별 워크큐 상태 (메트릭)
kubectl get --raw /metrics | grep workqueue

# 4. etcd 문제 진단
# etcd 상태 확인
kubectl exec -it etcd-master-1 -n kube-system -- etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  endpoint status -w table

# etcd 디스크 사용량 확인
kubectl exec -it etcd-master-1 -n kube-system -- etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  endpoint status -w json | jq '.[] | {endpoint: .Endpoint, dbSize: .Status.dbSize}'

# etcd 조각 모음 (디스크 공간 확보)
kubectl exec -it etcd-master-1 -n kube-system -- etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  defrag

# 5. HA 클러스터 리더 확인
# Scheduler 리더
kubectl get lease -n kube-system kube-scheduler -o jsonpath='{.spec.holderIdentity}'

# Controller Manager 리더
kubectl get lease -n kube-system kube-controller-manager -o jsonpath='{.spec.holderIdentity}'

🗣️ Say It Like This in Practice

During a Cluster Incident Response
"kubectl is not responding. Let's check the API Server first. I logged into the Control Plane node directly and checked the container status with crictl, and kube-apiserver keeps restarting. The certificates may have expired, so let's check with kubeadm certs check-expiration."
In an Interview Question About Kubernetes Architecture
"The Control Plane consists of four core components. The API Server acts as the gateway for all requests, and the cluster state is stored in etcd. The Scheduler places Pods on appropriate nodes, and the Controller Manager runs controllers such as Deployment and ReplicaSet to maintain the declarative state. In an HA configuration, etcd must be deployed in an odd number so that the Raft consensus algorithm works properly."
In a Cluster Capacity Planning Meeting
"We currently have 200 nodes, and etcd performance is becoming a bottleneck. The default etcd quota is 2GB, so it slows down as the number of objects grows. We need to raise the quota to 8GB and use SSD storage. Also, if API Server requests exceed 1000 per second, we need additional Control Plane nodes."

Take a mock interview on this topic → WIA SOOM AI Interview · Start for free

⚠️ Common Mistakes & Cautions

❌

Running Production on a Single Control Plane Node

A single Control Plane is a SPOF (single point of failure). If that node goes down, creating new Pods, scheduling, and autoscaling all stop. In production, set up HA with at least three Control Plane nodes.

❌

Not Backing Up etcd

If etcd is corrupted, the entire state of the cluster is lost. All object definitions such as Deployment, Service, and ConfigMap disappear. Regular etcd snapshot backups and restore tests are essential. Automate them with tools such as Velero.

✅

The Right Approach: Use Managed Kubernetes

Managed services such as EKS, GKE, and AKS manage the Control Plane automatically. HA configuration, automatic upgrades, backups, and monitoring are provided by default, which greatly reduces the operational burden. Unless you have special requirements that call for operating the Control Plane yourself, managed services are recommended.

🔗 Related Terms

📚 Learn More