CKA

Practice Test

백셀건전지 2022. 2. 28. 21:40
  • Worker node가 안되면 ssh 접속하여 kubelet 상태 확인하여 start
systemctl status kubelet
systemctl start kubelet
  • kubelet 이 실행중인데도 안되면 journalctl 명령어로 로그 확인
journalctl -u kubelet

 

  • kubelet의 config file 디렉토리는 /var/lib/kubelet/config.yaml
  • 수정 후 아래의 명령어로 재시작
systemctl restart kubelet
  • worker node가 control plane과 통신하는 포트는 6443
  • config 파일의 key 파일 디렉토리도 확인 필요

Network practice

  • pod event에서 'FailedCreatePodSandBox' 에러가 나오면, network addon 설치가 되어있는지 확인해본다. weave 를 설치하여 해결 가능함.
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
  • kube-proxy의 config 파일은 kube-proxy 이름의 ConfigMap이 pod에 mount 되어 있다
  • config file의 default mount directory는 /var/lib/kube-proxy/config.conf
  • daemonset으로 선언되어 있는 kube-proxy의 daemonset을 수정하여 에러를 고칠 수 있음.

Lighting Lab

  • 여러 deployment 정보 중 jsonpath 말고 custom-columns 를 사용할 수 있고, sort도 가능함
  • $ kubectl -n admin2406 get deployment -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.containers[].image,READY_REPLICAS:.status.readyReplicas,NAMESPACE:.metadata.namespace --sort-by=.metadata.name > /opt/admin2406_data
    
  • etcd backup 방법
    https://kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/
    1) ps aux로 etcd의 옵션 중 trusted-ca-file, cert-file, key-file 옵션을 찾는다.
    2) etcdctl 로 백업한다
# ps aux 로 etcd 확인
root@controlplane:~# ps aux | grep -i etcd
root     15476  0.0  0.0  11468  1056 pts/2    S+   08:23   0:00 grep --color=auto -i etcd
root     17285  0.0  0.0 10619380 70424 ?      Ssl  07:24   1:25 etcd --advertise-client-urls=https://10.14.147.12:2379 --cert-file=/etc/kubernetes/pki/etcd/server.crt --client-cert-auth=true --data-dir=/var/lib/etcd --initial-advertise-peer-urls=https://10.14.147.12:2380 --initial-cluster=controlplane=https://10.14.147.12:2380 --key-file=/etc/kubernetes/pki/etcd/server.key --listen-client-urls=https://127.0.0.1:2379,https://10.14.147.12:2379 --listen-metrics-urls=http://127.0.0.1:2381 --listen-peer-urls=https://10.14.147.12:2380 --name=controlplane --peer-cert-file=/etc/kubernetes/pki/etcd/peer.crt --peer-client-cert-auth=true --peer-key-file=/etc/kubernetes/pki/etcd/peer.key --peer-trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt --snapshot-count=10000 --trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt
# etcdctl로 backup
ETCDCTL_API=3 etcdctl \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
snapshot save /opt/etcd-backup.db

etcd restore 방법

  • 같은 서버에서는 아래의 명령어와 같이 --data-dir 추가해야.
ETCDCTL_API=3 etcdctl \
--data-dir /var/lib/etcd-from-backup \
snapshot restore /opt/etcd-backup.db

 

  • 업데이트 이후에 /etc/kubernetes/manifests/etcd.yaml파일에 있는 아래의 path를 --data-dir 옵션의 path로 바꿔줘야 함.
  volumes:
  - hostPath:
      path: /var/lib/etcd-from-backup
      type: DirectoryOrCreate
    name: etcd-data

 

Secrets

A Secret is an object that contains a small amount of sensitive data such as a password, a token, or a key. Such information might otherwise be put in a Pod specification or in a container image. Using a Secret means that you don't need to include confiden

kubernetes.io