《How to Pass the CKA Exam on Your First Attempt》Note

overview

  • 120 minutes exam
  • 15~20 questions
  • Free retake available

Time Management

  • Setup, prepare ~/.bashrc. Don’t foget to source ~/.bashrc after change.
1
2
3
4
5
6
7
8
9
alias k="kubectl"
alias v="vim"

function ns () {
  kubectl config set-context --current --namespace=$1
}

export drc="--dry-run=client -oyaml"
export drs="--dry-run=server -oyaml"
  • ns [空格] 可以取消 namespace 设置

  • k run test-pod --image=nginx $drc

    • get the basic pod template from client
    • paste the content into a file test-pod.yaml
    • then you can change the file and get the target yaml
  • vim settings:

    • :set nu can open “line number” function
    • :set autoindent when create new line, will auto indent
  • k apply -f test-pod.yaml create pod

  • k api-resource use shorthand names

Practice Approach

Key Areas

  • Volumes
  • RBAC
  • Labels, taints/tolerations
  • Etcd snapshots
  • Controlplane/kubelet debugging

practice

  • k create role my-role --verb=create --resource=pods $drs

  • k create rolebinding --role=my-role my-role-binding --user=john $drc

  • k auth can-i create pods --as=john yes

  • k auth can-i create pods --as=paul no

  • k get nodes --show-labels

  • k taint nodes minikube dedicated=special-user:NoSchedule node/monikube tainted

  • k get nodes -oyaml | grep -A3 taint

    1
    2
    3
    4
    taints:
      - effect: NoSchedule
        key: dedicated
        value: special-user
    
  • copy taints into test-pod.yaml, change the field name to “tolerations”

    1
    2
    3
    4
    5
    6
    spec:
      ...
      tolerations:
        - effect: NoSchedule
          key: dedicated
          value: special-user
    
  • get pods -n kube-system find etcd pod name like “etcd-minikube”

  • get pods -n kube-system etcd-minikube -oyaml

    1
    2
    3
    4
    5
    6
    7
    spec:
      containers:
        - command:
            - --cert-file=...
            - --key-file=...
            - --listen-client-urls=...(endpoints)
            - --trusted-ca-file=...
    
  • ETCDCTL_API=3 etcdctl snapshot save /xx/xx/file.db --cacert --cert --key --endpoints= save etcd snapshot

  • etcdctl snapshot status check snapshot

Tips conclusion

  • Know pluralities of fields
  • Edit vs create
  • Good Internet Connection
  • Verifying answers($drs)
  • Edit top level resources(or may be overwritten)

reference from others