티스토리 뷰
본 예제 풀이는 v1.20.00에서 진행되었음을 말씀드립니다.
문제 1 - Print the state of a pod
Print pod name and start time to "/opt/que1/pod-status" file |
풀이
root@controlplane ~ ➜ k get po -o jsonpath={.items[*].metadata.name} |
root@controlplane ~ ➜ k get po -o jsonpath={.items[*].status.startTime} |
root@controlplane ~ ➜ k get po -o custom-columns=NAME:{.metadata.name},START_TIME:{.status.startTime} --no-headers |
root@controlplane ~ ➜ k get po -o custom-columns=NAME:{.metadata.name},START_TIME:{.status.startTime} --no-headers > /opt/que1/pod-status |
전체 풀이
root@controlplane ~ ➜ k get po -o jsonpath={.items[*].metadata.name}
coredns-74ff55c5b-brqqz coredns-74ff55c5b-ts8wz etcd-controlplane kube-apiserver-controlplane kube-controller-manager-controlplane kube-proxy-8pq2h kube-proxy-w7wd6 kube-scheduler-controlplane nginx non-persistent-redis weave-net-n9lk9 weave-net-ss9zq webserver-559b886555-dsrfd webserver-559b886555-vjmhx webserver-559b886555-zzkj2
root@controlplane ~ ➜ k get po -o jsonpath={.items[*].status.startTime}
2022-07-19T00:30:28Z 2022-07-19T00:30:28Z 2022-07-19T00:29:53Z 2022-07-19T00:29:53Z 2022-07-19T00:29:53Z 2022-07-19T00:30:03Z 2022-07-19T00:30:30Z 2022-07-19T00:29:53Z 2022-07-19T00:39:49Z 2022-07-19T00:38:15Z 2022-07-19T00:30:03Z 2022-07-19T00:30:30Z 2022-07-19T00:40:34Z 2022-07-19T00:40:24Z 2022-07-19T00:40:34Z
root@controlplane ~ ➜ k get po -o custom-columns=NAME:{.metadata.name},START_TIME:{.status.startTime} --no-headers
coredns-74ff55c5b-brqqz 2022-07-19T00:30:28Z
coredns-74ff55c5b-ts8wz 2022-07-19T00:30:28Z
etcd-controlplane 2022-07-19T00:29:53Z
kube-apiserver-controlplane 2022-07-19T00:29:53Z
kube-controller-manager-controlplane 2022-07-19T00:29:53Z
kube-proxy-8pq2h 2022-07-19T00:30:03Z
kube-proxy-w7wd6 2022-07-19T00:30:30Z
kube-scheduler-controlplane 2022-07-19T00:29:53Z
nginx 2022-07-19T00:39:49Z
non-persistent-redis 2022-07-19T00:38:15Z
weave-net-n9lk9 2022-07-19T00:30:03Z
weave-net-ss9zq 2022-07-19T00:30:30Z
webserver-559b886555-dsrfd 2022-07-19T00:40:34Z
webserver-559b886555-vjmhx 2022-07-19T00:40:24Z
webserver-559b886555-zzkj2 2022-07-19T00:40:34Z
root@controlplane ~ ➜ k get po -o custom-columns=NAME:{.metadata.name},START_TIME:{.status.startTime} --no-headers > /opt/que1/pod-status
문제 2 - ETCD backup and Restore
First, create a snapshot of the existing etcd instance running at https://127.0.0.1:2379, saving the snapshot to /opt/data/etcd-snapshot-2022.db. Next, create a pod nginx image nginx. Next, restore an existing, previous snapshot located at /opt/data/etcd-snapshot-2022.db. |
풀이
root@controlplane ~ ➜ k get po etcd-controlplane -n kube-system -o jsonpath={.spec.containers[0].command} |
root@controlplane ~ ➜ mkdir /opt/data root@controlplane ~ ➜ ETCDCTL_API=3 etcdctl snapshot save /opt/data/etcd-snapshot-2022.db \ > --cacert=/etc/kubernetes/pki/etcd/ca.crt \ > --cert=/etc/kubernetes/pki/etcd/server.crt \ > --key=/etc/kubernetes/pki/etcd/server.key \ > --endpoints=127.0.0.1:2379 |
root@controlplane ~ ➜ k run nginx --image nginx -n default |
root@controlplane ~ ➜ k get po nginx -n default |
root@controlplane ~ ➜ ETCDCTL_API=3 etcdctl snapshot restore /opt/data/etcd-snapshot-2022.db \ --data-dir=/var/lib/etcd-snapshot-2022 \ --initial-advertise-peer-urls=https://10.73.68.3:2380 \ --initial-cluster=controlplane=https://10.73.68.3:2380 \ --name=controlplane |
root@controlplane ~ ➜ sed -i -e 's/path:\s\/var\/lib\/etcd/path: \/var\/lib\/etcd-snapshot-2022/' /etc/kubernetes/manifests/etcd.yaml |
root@controlplane ~ ➜ k get po nginx -n default |
전체풀이
root@controlplane ~ ➜ k get po etcd-controlplane -n kube-system -o jsonpath={.spec.containers[0].command}
["etcd","--advertise-client-urls=https://10.73.68.3:2379","--cert-file=/etc/kubernetes/pki/etcd/server.crt","--client-cert-auth=true","--data-dir=/var/lib/etcd","--initial-advertise-peer-urls=https://10.73.68.3:2380","--initial-cluster=controlplane=https://10.73.68.3:2380","--key-file=/etc/kubernetes/pki/etcd/server.key","--listen-client-urls=https://127.0.0.1:2379,https://10.73.68.3:2379","--listen-metrics-urls=http://127.0.0.1:2381","--listen-peer-urls=https://10.73.68.3: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"]
root@controlplane ~ ➜ mkdir /opt/data
root@controlplane ~ ➜ ETCDCTL_API=3 etcdctl snapshot save /opt/data/etcd-snapshot-2022.db \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
--endpoints=127.0.0.1:2379
Snapshot saved at /opt/data/etcd-snapshot-2022.db
root@controlplane ~ ➜ k run nginx --image nginx -n default
pod/nginx created
root@controlplane ~ ➜ k get po nginx -n default
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 6s
root@controlplane ~ ➜ ETCDCTL_API=3 etcdctl snapshot restore /opt/data/etcd-snapshot-2022.db \
--data-dir=/var/lib/etcd-snapshot-2022 \
--initial-advertise-peer-urls=https://10.73.68.3:2380 \
--initial-cluster=controlplane=https://10.73.68.3:2380 \
--name=controlplane
2022-07-19 01:38:09.979419 I | mvcc: restore compact to 4959
2022-07-19 01:38:09.986899 I | etcdserver/membership: added member 4e00da14c627878 [https://10.73.68.3:2380] to cluster d9d586278a0a5b2c
root@controlplane ~ ➜ sed -i -e 's/path:\s\/var\/lib\/etcd/path: \/var\/lib\/etcd-snapshot-2022/' /etc/kubernetes/manifests/etcd.yaml
root@controlplane ~ ✖ k get po nginx -n default
Error from server (NotFound): pods "nginx" not found
문제 3 - Create pod and check ip
Create a pod nginx-dev with image nginx and get IP address of the pod and write the value to /opt/question/nginx-dev-ip.txt |
풀이
root@controlplane ~ ➜ k run nginx-dev --image nginx |
root@controlplane ~ ➜ k get po nginx-dev -o jsonpath={.status.podIP} |
root@controlplane ~ ➜ mkdir /opt/question/ root@controlplane ~ ➜ k get po nginx-dev -o jsonpath={.status.podIP} > /opt/question/nginx-dev-ip.txt root@controlplane ~ ➜ cat /opt/question/nginx-dev-ip.txt |
전체풀이
root@controlplane ~ ➜ k run nginx-dev --image nginx
pod/nginx-dev created
root@controlplane ~ ➜ k get po nginx-dev -o jsonpath={.status.podIP}
10.50.192.2
root@controlplane ~ ➜ mkdir /opt/question/
root@controlplane ~ ➜ k get po nginx-dev -o jsonpath={.status.podIP} > /opt/question/nginx-dev-ip.txt
- Total
- Today
- Yesterday
- 정보기기운용기능사 실기 독학
- 패킷트레이서 정적라우팅 설정
- kubernetes와 docker
- 정보기기운용기능사 정적라우팅
- 정보기기운용기능사 동적라우팅 설정
- 정보기기운용기능사 동적라우팅
- 패킷트레이서 IP
- 패킷트레이서 정적라우팅
- 패킷트레이서 명령어
- 정보기기운용기능사 IP
- 정보기기운용기능사 명령어모음
- gala game 별 올리기
- town star 별 올리기
- 정보기기운용기능사 실기 명령어모음
- cri-dockerd
- cri-dockerd란?
- 정보기기운용기능사 static routing
- 패킷트레이서 동적라우팅
- 패킷트레이서 static 라우팅설정
- 패킷트레이서 static routing 설정
- 패킷트레이서 동적라우팅 설정
- 패킷트레이서 routing 설정
- 패킷트레이서 static routing
- 패킷트레이서 라우팅 설정
- 정보기기운용기능사 static routing 설정
- dockershim이란?
- 정보기기운용기능사 독학
- 정보기기운용기능사 실기 명령어
- 정보기기운용기능사 정적라우팅 설정
- 정보기기운용기능사 필기 독학
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |