CKA (Certified Kubernetes Administrator)
Introduction
CKA: Kubernetes 관리자의 책임을 수행할 수 있는 기술, 지식 및 역량을 갖추고 있음을 보증하는 자격증
CKA curriculum에서 CKA가 포함하는 내용들을 아래와 같이 확인할 수 있다.
v1.29
기준Domain | Weight | Key Points |
---|---|---|
Cluster Architecture, Installation & Configuration |
25% | ✅ Manage role based access control (RBAC) ✅ Use Kubeadm to install a basic cluster ✅ Manage a highly-available Kubernetes cluster ✅ Provision underlying infrascruture to deploy a Kubernetes cluster ✅ Implement etcd backup and restore |
Workloads & Scheduling | 15% | ✅ Understand deployments and how to perform rolling update and rollbacks ✅ Use ConfigMaps and Secrets to configure applications ✅ Know how to scale applications ✅ Understand how resource limits can effect Pod scheduling ✅ Awareness of manifest management and common templating tools |
Services & Networking | 20% | ✅ Understand host networking configuration on the cluster nodes ✅ Understand connectivity between Pods ✅ Understand ClusterIP, NodePort, LoadBalancer service types and endpoints ✅ Know how to use Ingress controllers and Ingress resources ✅ Know how to configure and use CoreDNS ✅ Choose an appropriate container network interface plugin |
Storage | 10% | ✅ Understand storage classes, persistent volumes ✅ Understand volume mode, access modes and reclaim polices for volumes ✅ Understand persistent volume claims primitive ✅ Know how to configure applications with persistent storage |
Troubleshooting | 30% | ✅ Evaluate cluster and node logging ✅ Understand how to monitor applications ✅ Manage container stdout & stderr logs ✅ Troubleshoot application failure ✅ Troubleshoot cluster component failure ✅ Troubleshoot networking |
- 가격: \$375
- 시간: 2시간
- 문제: 17문제
- 장소: 사방이 막힌 조용한 장소
- 준비물: 신분증 (영문 이름 필수)
공식 사이트에서 결제하여 CKA 응시를 신청할 수 있다.
결제 전에 Coupert를 설치하면 기존 \$395의 가격을 할인 받을 수 있다. (필자는 40%의 할인을 받아 \$237에 결제했다.)
결제를 마쳤다면 1년 내로 아래와 같이 시험을 예약해야 한다.
시험 응시 시 환경에서는 현재 존재하지 않지만 multi-cluster 환경에서 시험을 응시하게 된다.
여기에서 시험 응시 시 사용할 기기의 검증을 수행할 수 있다.
Udemy에서 Mumshad님이 진행하신 강의가 매우 유명하기 때문에 해당 강의를 수강했다.
해당 강의를 수강하면 KodeKloud를 통해 실제 시험과 유사한 조건 속에서 연습할 수 있다.
마지막으로 CKA 시험의 결제를 마치면 아래와 같이 killer.sh의 문제를 2회 풀 수 있는 권한을 주기 때문에 복기를 위해 이를 풀었다.
Theoretical Backgrounds
Kubernetes Components
Kubernetes의 요소들은 아래와 같이 구성된다.
Core Concepts
Pods
1 | kubectl get po | wc -l |
ReplicaSets
1 | kubectl get po | wc -l |
Deployments
1 | kubectl get po |
Namespaces
1 | kubectl get ns | wc -l |
Services
1 | kubectl get svc |
Imperative Commands
1 | kubectl run nginx-pod --image nginx:alpine |
Scheduling
Manual Scheduling
1 | kubectl apply -f nginx.yaml |
Labels and Selectors
1 | kubectl describe po | grep dev | wc -l |
Taints and Tolerations
1 | kubectl get node |
Node Affinity
1 | kubectl describe node node01 | grep -i labels -A4 |
Resource Limits
1 | kubectl describe po | grep cpu: -B1 |
DaemonSets
1 | kubectl get -A ds |
Static Pods
1 | kubectl get -A po | grep controlplane |
Multiple Schedulers
1 | kubectl get -n kube-system po | grep scheduler |
Logging & Monitoring
Monitor Cluster Components
1 | git clone https://github.com/kodekloudhub/kubernetes-metrics-server.git |
Managing Application Logs
1 | kubectl logs webapp-1 | grep USER5 | tail -n1 |
Application Lifecycle Management
Rolling Updates and Rollbacks
1 | kubectl get po |
Commands and Argumnets
1 | kubectl get po |
Env Variables
1 | kubectl get po | wc -l |
Secrets
1 | kubectl get secret | wc -l |
Multi Container Pods
1 | kubectl get po red |
Init Containers
1 | kubectl describe po blue | grep -i init |
Cluster Maintenance
OS Upgrades
1 | kubectl get node |
Cluster Upgrade Process
1 | kubectl get node |
1 | echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list |
1 | ssh node01 |
Backup and Restore Methods (Stacked etcd)
1 | kubectl get deploy |
1 | kubectl describe -n kube-system po etcd-controlplane | grep ca |
1 | ETCDCTL_API=3 etcdctl snapshot restore /opt/snapshot-pre-boot.db --data-dir=/var/lib/etcd-from-backup |
Backup and Restore Methods (External etcd)
1 | kubectl config view |
1 | ca=/etc/etcd/pki/ca.pem |
1 | ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=$ca --cert=$cert --key=$key snapshot save cluster2.db |
1 | ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=$ca --cert=$cert --key=$key snapshot restore cluster2.db --data-dir=/var/lib/etcd-data-new |
Security
View Certificate Details
1 | kubectl describe -n kube-system po kube-apiserver-controlplane | grep cert | grep tls |
Certificates API
1 | cat akshay.csr |
KubeConfig
1 | kubectl config view |
Role Based Access Controls
1 | kubectl describe -n kube-system po kube-apiserver-controlplane | grep -i auth |
Cluster Roles
1 | kubectl get clusterrole | wc -l |
Service Accounts
1 | kubectl get sa |
Image Security
1 | kubectl create secret --help | grep docker |
Security Contexts
1 | kubectl get po ubuntu-sleepr -oyaml > tmp.yaml |
Network Policies
1 | kubectl get netpol |
Storage
Persistent Volume Claims
1 | kubectl exec webapp -- cat /log/app.log |
Storage Class
1 | kubectl get sc |
Networking
Explore Environment
1 | kubectl get node |
CNI
1 | ps -aux | grep kubelet | grep --color container-runtime-endpoint |
Depoly Network Solution
1 | kubectl describe po | grep -i events -A10 |
Networking Weave
1 | kubectl get node |
Service Networking
1 | ip a show eth0 |
CoreDNS in Kubernetes
1 | kubectl get -n kube-system po |
Ingress Networking
1 | kubectl get -A po | grep ingress |
1 | kubectl create ns ingress-nginx |
Install
Cluster Installation using Kubeadm
1 | cat <<EOF | tee /etc/modules-load.d/k8s.conf |
1 | ifconfig eth0 |
1 | kubeadm token create --print-join-command |
1 | curl -LO https://raw.githubusercontent.com/flannel-io/flannel/v0.20.2/Documentation/kube-flannel.yml |
Troubleshooting
Application Failure
1 | k get -n alpha all |
1 | kubectl get -n beta all |
1 | kubectl get -n gamma all |
1 | kubectl get -n delta all |
1 | kubectl get -n epsilon all |
1 | kubectl get -n zeta all |
Control Plane Failure
1 | kubectl get -n kube-system po |
1 | kubectl scale deploy app --replicas 2 |
1 | kubectl get deploy |
Worker Node Failure
1 | kubectl get node |
1 | kubectl get node |
1 | kubectl get node |
Troubleshoot Network
1 | kubectl get -n triton all |
1 | kubectl get -n triton all |
Mock Exam
Warming Up
1 | kubectl run nginx-pod --image nginx:alpine |
kubectl get -o
1 | kubectl get -n admin2406 deploy -ojson | jq -c paths | grep name |
1 | kubectl get node -ojson | jq -c paths | grep osImage |
1 | kubectl get node -ojson | jq -c paths | grep type | grep -v conditions |
Cluster Upgrade
1 | kubectl get node |
1 | echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list |
1 | ssh node01 |
etcd Backup
1 | kubectl get -n kube-system po etcd-controlplane -oyaml | grep ca |
Pod: Mount Secret
1 | kubectl run -n admin1401 secret-1401 --image busybox --dry-run=client -oyaml > tmp.yaml |
1 | apiVersion: v1 |
Pod: Mount Volume
1 | kubectl run redis-storage --image redis:alpine --dry-run=client -oyaml > tmp.yaml |
1 | apiVersion: v1 |
1 | kubectl apply -f tmp.yaml |
Pod: securityContext
1 | kubectl run super-user-pod --image busybox:1.28 --dry-run=client -oyaml > tmp.yaml |
1 | apiVersion: v1 |
1 | kubectl apply -f tmp.yaml |
PV & PVC
1 | kubectl get pv |
1 | apiVersion: v1 |
1 | apiVersion: v1 |
Deployment: Create & Upgrade
1 | kubectl create deploy nginx-deploy --image nginx:1.16 |
CertificateSigningRequest
1 | cat john.csr | base64 -w0 |
1 | apiVersion: certificates.k8s.io/v1 |
Pod: Service
1 | kubectl run nginx-resolver --image nginx |
Static Pod
1 | kubectl run nginx-critical --image nginx --dry-run=client -oyaml > tmp.yaml |
1 | apiVersion: v1 |
ServiceAccount
1 | kubectl create sa pvviewer |
1 | apiVersion: v1 |
Pod: Multi-container
1 | kubectl run multi-pod --image nginx --dry-run=client -oyaml > tmp.yaml |
1 | apiVersion: v1 |
NetworkPolicy
1 | kubectl run test --image alpine/curl --rm -it --restart Never -- sh |
1 | apiVersion: networking.k8s.io/v1 |
Node: Taint
1 | kubectl taint node node01 env_type=production:NoSchedule |
1 | apiVersion: v1 |
Killer Shell
Contexts
1 | kubectl config get-contexts -oname |
Schedule Pod on Control Plane
1 | kubectl config use-context k8s-c1-H |
1 | apiVersion: v1 |
Scale down StatefulSet
1 | kubectl config use-context k8s-c1-H |
Pod Ready if Service is Reachable
1 | kubectl config use-context k8s-c1-H |
1 | apiVersion: v1 |
kubectl sorting
1 | kubectl config use-context k8s-c1-H |
Storage, PV, PVC, Pod volume
1 | kubectl config use-context k8s-c1-H |
1 | apiVersion: v1 |
Node and Pod Resource Usage
1 | kubectl config use-context k8s-c1-H |
Get Control Plane Information
1 | kubectl config use-context k8s-c1-H |
1 | # /opt/course/8/controlplane-components.txt |
Kill Scheduler, Manual Scheduling
1 | kubectl config use-context k8s-c2-AC |
1 | apiVersion: v1 |
RBAC ServiceAccount Role RoleBinding
1 | kubectl config use-context k8s-c1-H |
DaemonSet on all Nodes
1 | kubectl config use-context k8s-c1-H |
1 | apiVersion: apps/v1 |
Deployment on all Nodes
1 | kubectl config use-context k8s-c1-H |
1 | apiVersion: apps/v1 |
Multi Containers and Pod shared Volume
1 | kubectl config use-context k8s-c1-H |
1 | apiVersion: v1 |
Find out Cluster Information
1 | kubectl config use-context k8s-c1-H |
1 | # /opt/course/14/cluster-info |
Cluster Event Logging
1 | kubectl config use-context k8s-c2-AC |
Namespace and API Resources
1 | kubectl config use-context k8s-c1-H |
Find Container of Pod and check info
1 | kubectl config use-context k8s-c1-H |
Fix kubelet
1 | kubectl config use-context k8s-c3-CCC |
Create Secret and mount into Pod
1 | kubectl config use-context k8s-c3-CCC |
1 | apiVersion: v1 |
1 | apiVersion: v1 |
Update Kubernetes Version and join cluster
1 | kubectl config use-context k8s-c3-CCC |
Create a Static Pod and Service
1 | kubectl config use-context k8s-c3-CCC |
1 | apiVersion: v1 |
Check how long certificates are valid
1 | kubectl config use-context k8s-c2-AC |
kubelet client/server cert info
1 | kubectl config use-context k8s-c2-AC |
NetworkPolicy
1 | kubectl config use-context k8s-c1-H |
1 | apiVersion: networking.k8s.io/v1 |
etcd Snapshot Save and Restore
1 | kubectl config use-context k8s-c3-CCC |
Tips
빈출 유형
- Cluster Architecture, Installation & Configuration
- Cluster Upgrade (
kubeadm
) - etcd Backup & Restore (
etcdctl snapshot
) - RBAC (
ServiceAccount
,Role
,RoleBinding
)
- Cluster Upgrade (
- Workloads & Scheduling
- Node: Drain & Uncordon (
kubectl drain
,kubectl uncordon
) - Deployment: Rolling Update & Undo Rollback
- Deployment: Scaling (
kubectl scale
) - Pod: Toleration
- Pod: Multi-container
- Node: Drain & Uncordon (
- Services & Networking
- Deployment & Service (
kubectl expose
) - NetworkPolicy (
namespaceSelector
,podSelector
,ports
) - Ingress (
curl
)
- Deployment & Service (
- Storage
- Pod: Sidecar (
emptyDir
) - Pod: PV, PVC
- Pod: Sidecar (
- Troubleshooting
- Node: notReady (
systemctl status kubelet
) - Monitoring (
kubectl top
) - Pod: Log (
kubectl logs
) -ojsonpath
&--sort-by
- Node: notReady (
Shortnames
1 | kubectl api-resources |
OpenSSL
Network 통신과 data를 암호화하는 데 사용되는 도구
1 | kubectl describe -n kube-system po kube-apiserver-controlplane | grep -i cert |
x509
: X.509 (공개 키 국제 표준 인증서) 설정-in
${FILE}: 입력 파일 지정-text
: 인증서의 내용을 text 형식으로 출력-noout
: 출력에서 인증서의 encoding 원본 data 제외