CKA 응시 팁&설정
Lab settings
- YAML작성 편하게하는 vi 에디터 설정(적용되어있음)
    
$ vi .vimrc set et set sw=2 set ts=2 set nu - 자동완성 설정(공식문서)(적용되어있음)
    
https://kubernetes.io/ko/docs/tasks/tools/included/optional-kubectl-configs-bash-linux/ - 시험환경에서, 터미널에 복/붙할때는 
ctrl+shift+c,ctrl+shift+v - 가능한 yaml작성보다는 선언형(명령어 입력)으로 생성. 시험환경 렉걸림
 - 컨텍스트 변경에 항상 주의
 
명령어 예시
- pod 생성시
    
- k run {name} –image= … –dry-run=client -o yaml > pod.yaml
 
 - 리소스 생성시
    
- k create 로 생성가능한 리소스를 살펴보고
 - k create {resource} –help로 생성 예제를 확인한 뒤
 - k create {resource} –dry-run=client -o yaml > resource.yaml 생성 후 편집
 - k create/apply -f resource.yaml
 
 
11 vi Tip
- Backup
    
- k run tip1 –image nginx –dry-run=client -o yaml > 1.yaml
 - cp 1.yaml 1.yaml.b
 
 - Search & Replace (Tip 2&3)
    
- / -> Search
 - Shift C > Replace
 - To change container name in a Pod/Deploy
        
- k create deploy tip2 – image nginx –dry-run=client -o yaml > 2.yaml
 - vi 2.yaml
 - /nginx
 - Shift+c > 원하는 이름입력
 
 
 - Append Text at the End
    
- Shift A
 - Add a Plugin ImagePolicyWebhook in kube-apiserver.yaml
        
- vi kube-apiserver.yaml
 - /plugin
 - Shift+a > 입력모드, 커서 제일 오른쪽 끝으로 이동
 
 
 - Delete Text From Cursor Till End
    
- Shift D
 - Delete a Plugin AlwaysAdmit in k-api.yaml
        
- vi kube-apiserver.yaml
 - /Always
 - Shift+D > 입력모드, 커서 제일 오른쪽 끝으로 이동
 
 
 - Indent Single Line
    
- >> Shift right
 - << Shift left
 - Add serviceAccountName: build-robot
        
- vi kube-apiserver.yaml
 - /spec
 - 칸만들고 넣은 후 >>로 여백조절
 
 
 - Add line Above or Below
    
- o -> add line Below
 - O -> add line Above
 - Add nodePort: 30007 to svc
        
- k create deploy tip7 –image nginx
 - k expose deploy tip7 –name tip7-svc –port80 –target-port 80 –type NodePort –dry-run=client -o yaml > 7.yaml
 - vi 7.yaml
 - 필요한곳에 찾아가서 o 눌러서 입력상태 들어가기
 
 
 - Indent Block of Text
    
- Shift V
 - Shift > or <
 - .(dot) -> to repeat
 - Add volumes and volumeMounts to a deploy
        
- k create deploy tip8 – image nginx –dry-run=client -o yaml > 8.yaml
 - vi 8.yaml
 
 
 - Copy Pastee Block of text
    
- Shift V
 - y
 - p
 - Multi Container Pod
 
 - Comment line or Delete line
    
- 0i#
 - dd
 - kube-apiserver disable –allow-privileged
        
- 0i# -> 0(커서 줄앞으로)/i(입력모드전환)/#(주석기호)
 
 
 - Save & Quit
    
- :x
 - Add Label env: prod
 
 
220719 cka 팁
- finesse guide
    
- mindset
        
- time is your most valuable resource, speed is your best friend
 - be imperative first, declarative second
 
 k create|run ... -h- copying yaml from docs is LAST RESORT
 - just make the thing with 
k create|run - add 
... --dry-run=client -o yaml > resource.yamlif you need to add things before apply 
- use the 
-hoption- tells you EXACTLY what can be created imperatively WITH EXAMPLES
 - menu increases in detail with base command
 
 - understand the k8s docs
        
- remember important pages and examples
            
- mentally bookmark templates that can’t be created interactively (pv, pvc, netpol, etc.)
 
 - ctrl-f 
kind: <MY RESOURCE>to quickly find example yaml - use the one-pager api reference for specific details
 
 - remember important pages and examples
            
 - use shortnames
        
- never type out a full resource name if you can help it
            
- cm -> configmap
 - pvc -> persistentvolumeclaim
 - …
 
 - check all shortnames with 
k api-resources 
 - never type out a full resource name if you can help it
            
 - aliases, functions, and variables
        
- memorize what you think you’ll use
 
 
 - mindset
        
 
# IMHO must-haves
## create yaml on-the-fly faster
export do='--dry-run=client -o yaml'
## organize your files per question #
mkcd() { mkdir -p "$@" && cd "$@" ; }
# nice to haves
## create/destroy from yaml faster
alias kaf='k apply -f '
alias kdf='k destroy -f '
## namespaces (poor man's `kubens`)
export nk='-n kube-system'
export n='-n important-ns' # set this as needed
## destroy things without waiting
export now='--grace-period 0 --force'
Docs 정리
- Bookmark
 - kubectl Cheat sheet
 - kubectl reference docs
    
- pods
 - service
 - controllers
 - volumes
 - Auth
 - Security context
 - Networkpolicies
 - Troubleshooting
 - Deploy
 
 - Domain 별 시험 유형
    
- Storage (10%)
        
- emptyDir, hostPath, NFS 기반의 PV생성
 - PVC 생성 후 Pod에 볼륨 마운트 하기
 
 - Troubleshooting (30%)
        
- node에서 kubelet 동작 문제 해결
 - node에서 CNI, kube-proxy 동작 문제 해결
 - CPU 부하 많이 차지하는 특정 pod 찾아 기록 또는 log 별도 저장
 
 - Workloads & Scheduling (15%)
        
- 서비스 deploy 후 rolling/rollbacks, scale in/out
 - ConfigMaps/Secrets 생성 후 pod 적용
 - Pod에 liveness, readiness Probe 적용, Cpu/mem limit 설정
 
 - Cluster Architecture, Installation & Configuration(25%)
        
- ETCD Backup/restore
 - API 인증(RBAC) 보안 (Network policy) 설정
 - kubeadm install/upgrade
 
 - Sevices & Networking (20%)
        
- deply/pd 서비스를 위한 ClusterIP/NodePort 설정
 - Ingress 구성
 - nslookup 명령어 사용, pod와 서비스의 DNS 결과를 저장(CoreDNS 이해)
 - node의 CNI(Container N/W Interface plugin) 동작 문제 해결
 
 
 - Storage (10%)
        
 
기출 내역
- 220818후기
    
- 13점 문제가 1개 나왔고 Trouble shooting 문제 였습니다. (workder node의 kubelet down)
        
- systemctl status docker => systemctl enable –now docker
 - systemctl status kubelet => systemctl enable –now kubelet
 
 - 7점은 대부분 여러 resource가 연계된 문제들
        
- pv, pvc 생성해서 pod에 mount -> mounts 정보 describe로 확인하기
 - sidecar - multi containers -> sidecar cont. log 확인하기
 - svc생성하고 ingress로 http 설정
 - ETCD save & restore
 - clusteerrole &binding, sa
 - cluster upgrade 문제 ( master만)
 - deloyment의 cont. 에서 container port(name까지) 설정하고, nodePort로 된 svc의 target port에 설정한 port name으로 expose하기
 - node drain하기
 
 - 4점은 정말 Easy~
        
- taint가 적용되는 않은 node 갯수 count
 - pod schedule
 - 특정 node에서 pod deploy => nodeselector 설정
 - log grep해서 save
 - CPU사용량이 가장 많은 pod 이름 save
 - deployment replica scaling
 - multi container pod
 - hostPath로 PV 생성
 - storage로 PVC 생성 -> pv, pvc 확인
 
 
 - 13점 문제가 1개 나왔고 Trouble shooting 문제 였습니다. (workder node의 kubelet down)
        
 - 220707
    
- networkpolicy (다른 특정 네임스페이스에 있는 pod들 전부 ingress 허용)
 - 이미 존재하는 Deployment에 Service Expose (Nodeport 사용)
 - ETCD 백업 및 복구
 - CPU 사용량 가장 높은 Pod명 검색하여 파일로 저장
 - Ingress 생성
 - Control Plane만 Upgrade (Worker Node는 절대 하지 말 것)
 - Sidecar Container Pod 생성
 - Multi Container Pod 생성
 - NodeSelector 사용
 - Deployment Scale
 - Hostpath 타입의 볼륨 생성하기
 - PVC 및 PV 생성
 - Service Account & ClusterRole & Rolebiding 생성
 - Node Troubleshooting (Kubelet 장애)
 - Node 관리 (drain)
 - Node 정보 수집 (Ready 상태이며 Taint가 NoShedule을 포함하지 않는 Node명 검색하여 파일로 저장)
 - Label 설정한 Pod 생성(?)
 
 - 220627(지인 후기)
    
- etcd 백업 및 복구 ( 1개 )
 - pv , pvc 생성 ( 2문제 )
 - pod / deploy 생성 (3~4문제)
 - netpol 구성 (1문제)
 - trouble-shooting [ master, node 각 1문제 ]
 - ingress ( 1문제 ) < 시간 많이 뺏김 >
 - Cluster upgrade & Install (1문제)
 - Cordon & Uncordon (1문제)
 - static-pod (1문제)
 
 
      
Leave a comment