오후 12:07 2024-11-03
[root@master ~/kube/07/rc]# kubectl get pod --show-labels
NAME READY STATUS RESTARTS AGE LABELS
nginx-rc-7q52r 1/1 Running 0 4m app=webui
nginx-rc-mz5m9 1/1 Running 0 4m app=webui
nginx-rc-qcbmk 1/1 Running 0 4m app=webui
오후 12:10 2024-11-03
[root@master ~/kube/07/rc]# kubectl edit rc nginx-rc
replicationcontroller/nginx-rc edited
^C[root@master ~/kube/07/rc]# kubectl scale rc nginx-rc --replicas 2
replicationcontroller/nginx-rc scaled
>> 최근에 생성된 게 사라짐.
>> 사람 많을 땐 replica를 조절 (pod 개수를 조절)
==========================
오후 1:06 2024-11-03
>> 파드가 새로 생겼을 때 edit한 것이 반영된다. (기존에 동작중인 파드에는 반영되지 않는다.)
[root@master ~/kube/07/rc]# kubectl delete pod --all
pod "nginx-rc-7q52r" deleted
pod "nginx-rc-v58vp" deleted
===========================
오후 1:09 2024-11-03
[root@master ~/kube/07/rc]# kubectl get rc,pod
NAME DESIRED CURRENT READY AGE
replicationcontroller/nginx-rc 2 2 2 65m
NAME READY STATUS RESTARTS AGE
pod/nginx-rc-9d8p8 1/1 Running 0 38s
pod/nginx-rc-p6zqv 1/1 Running 0
===========================
오후 1:09 2024-11-03
[root@master ~/kube/07/rc]# kubectl delete rc nginx-rc
replicationcontroller "nginx-rc" deleted
===========================
오후 1:21 2024-11-03
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx-rs
spec:
replicas: 3
selector:
matchLabels:
app: webui
template:
metadata:
name: nginx-pod
labels:
app: webui
spec:
containers:
- name: nginx-container
image: nginx:1.14
===========================
오후 1:25 2024-11-03
[root@master ~/kube/07/rs]# kubectl delete rs nginx-rs --cascade=orphan
>> replica는 삭제 진행하지만,, 파드는 그대로 둔다.
[root@master ~/kube/07/rs]# kubectl get rs,pod
NAME READY STATUS RESTARTS AGE
pod/nginx-rs-brcd7 1/1 Running 0 98s
pod/nginx-rs-k8xxh 1/1 Running 0 5m4s
pod/nginx-rs-kcqvn 1/1 Running 0 5m4s
pod/nginx-rs-mzjfj 1/1 Running 0 98s
===========================
오후 1:38 2024-11-03
* 아래 namespaced가 true이면 namespace를 이용하여 따로 분리하여 생성 가능.
[root@master ~/kube/07/rs]# kubectl api-resources
NAME SHORTNAMES APIVERSION NAMESPACED KIND
bindings v1 true Binding
componentstatuses cs v1 false ComponentStatus
configmaps cm v1 true
===========================
오후 1:40 2024-11-03
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-rs
spec:
replicas: 3
selector:
matchLabels:
app: webui
template:
metadata:
name: nginx-pod
labels:
app: webui
spec:
containers:
- name: nginx-container
image: nginx:1.14
===========================
오후 1:44 2024-11-03
[root@master ~/kube/07/rs]# kubectl create -f nginx-deploy.yml
deployment.apps/nginx-deploy created
[root@master ~/kube/07/rs]# kubectl delete deploy nginx-deploy
deployment.apps "nginx-deploy" deleted
===========================
오후 1:48 2024-11-03
[root@master ~/kube/07/roll]# kubectl create -f deploy-test1.yml --record
Flag --record has been deprecated, --record will be removed in the future
deployment.apps/nginx-deploy created
[root@master ~/kube/07/roll]# kubectl rollout history deploy nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 kubectl create --filename=deploy-test1.yml --record=true
[root@master ~/kube/07/roll]# kubectl create -f deploy-test1.yml --record
Flag --record has been deprecated, --record will be removed in the future
deployment.apps/nginx-deploy created
[root@master ~/kube/07/roll]# kubectl rollout history deploy nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 kubectl create --filename=deploy-test1.yml --record=true
[root@master ~/kube/07/roll]# kubectl set image deploy nginx-deploy nginx-container=nginx:1.15 --record
Flag --record has been deprecated, --record will be removed in the future
deployment.apps/nginx-deploy image updated
[root@master ~/kube/07/roll]# kubectl rollout status deployment nginx-deploy
Waiting for deployment "nginx-deploy" rollout to finish: 2 out of 3 new replicas have been updated...
[root@master ~/kube/07/roll]# kubectl rollout history deploy nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 kubectl set image deploy nginx-deploy nginx-container=nginx:1.14 --record=true
2 kubectl set image deploy nginx-deploy nginx-container=nginx:1.15 --record=true
3 kubectl set image deploy nginx-deploy nginx-container=nginx:1.16 --record=true
4 kubectl set image deploy nginx-deploy nginx-container=nginx:1.17 --record=true
===========================
오후 2:00 2024-11-03
[root@master ~/kube/07/roll]# kubectl rollout history deploy nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 kubectl set image deploy nginx-deploy nginx-container=nginx:1.14 --record=true
2 kubectl set image deploy nginx-deploy nginx-container=nginx:1.15 --record=true
3 kubectl set image deploy nginx-deploy nginx-container=nginx:1.16 --record=true
4 kubectl set image deploy nginx-deploy nginx-container=nginx:1.17 --record=true
===========================
오후 2:02 2024-11-03
[root@master ~/kube/07/roll]# kubectl rollout undo deployment nginx-deploy
deployment.apps/nginx-deploy rolled back
[root@master ~/kube/07/roll]# kubectl rollout undo deployment nginx-deploy --to-revision=2
deployment.apps/nginx-deploy rolled back
===========================
오후 2:22 2024-11-03
[root@master ~/kube/07/roll]# kubectl create -f deploy-test2.yml
Error from server (AlreadyExists): error when creating "deploy-test2.yml": deployments.apps "nginx-deploy" already exists
[root@master ~/kube/07/roll]# kubectl apply -f deploy-test2.yml
Warning: resource deployments/nginx-deploy is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
deployment.apps/nginx-deploy configured
[root@master ~/kube/07/roll]# kubectl rollout history deployment nginx-deploy
deployment.apps/nginx-deploy
REVISION CHANGE-CAUSE
1 version 1.14
2 version 1.15
>> 다 확인 완료..
[root@master ~/kube/07/roll]# kubectl delete deployments.apps nginx-deploy
deployment.apps "nginx-deploy" deleted
========================================
오후 2:25 2024-11-03
https://k8syaml.com/
https://syshunt.com/kubernetes-yaml-generator/
========================================
오후 2:35 2024-11-03
[root@master ~/kube/07/ds]# kubectl get ds,pod
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/nginx-ds 3 3 3 3 3 <none> 62s
NAME READY STATUS RESTARTS AGE
pod/nginx-ds-82kc9 1/1 Running 0 62s
pod/nginx-ds-gqbgw 1/1 Running 0 62s
pod/nginx-ds-hj9k9 1/1 Running 0 62s
========================================
오후 2:38 2024-11-03
[root@master ~/kube/07/ds]# kubectl describe pod | grep Image
Image: nginx:1.15
Image ID: docker-pullable://nginx@sha256:23b4dcdf0d34d4a129755fc6f52e1c6e23bb34ea011b315d87e193033bcd1b68
Image: nginx:1.15
Image ID: docker-pullable://nginx@sha256:23b4dcdf0d34d4a129755fc6f52e1c6e23bb34ea011b315d87e193033bcd1b68
Image: nginx:1.15
Image ID: docker-pullable://nginx@sha256:23b4dcdf0d34d4a129755fc6f52e1c6e23bb34ea011b315d87e193033bcd1b68
[root@master ~/kube/07/ds]# kubectl rollout undo daemonset nginx-ds
daemonset.apps/nginx-ds rolled back
========================================
오후 2:45 2024-11-03
[root@master ~/kube/07/sts]# kubectl describe sts nginx-sts | grep -i update
Update Strategy: RollingUpdate
[root@master ~/kube/07/sts]# kubectl get sts,pod
NAME READY AGE
statefulset.apps/nginx-sts 3/3 56s
NAME READY STATUS RESTARTS AGE
pod/nginx-sts-0 1/1 Running 0 56s
pod/nginx-sts-1 1/1 Running 0 54s
pod/nginx-sts-2 1/1 Running 0 52s
[root@master ~/kube/07/sts]# kubectl delete pod nginx-sts-2
pod "nginx-sts-2" deleted
^[[A[root@master ~/kube/07/sts]# kubectl get sts,pod
NAME READY AGE
statefulset.apps/nginx-sts 2/3 67s
NAME READY STATUS RESTARTS AGE
pod/nginx-sts-0 1/1 Running 0 67s
pod/nginx-sts-1 1/1 Running 0 65s
pod/nginx-sts-2 0/1 ContainerCreating 0 2s
========================================
오후 2:49 2024-11-03
[root@master ~/kube/07/sts]# kubectl edit statefulsets.apps nginx-sts
statefulset.apps/nginx-sts edited
[root@master ~/kube/07/sts]# kubectl rollout undo statefulset nginx-sts
[root@master ~/kube/07/sts]# kubectl delete sts nginx-sts
========================================
오후 2:59 2024-11-03
at 절대적인 스케줄러 job (일회용)
cron 주기적인 스케줄러 cronjob (지속)
[root@master ~/kube/07/job]# kubectl logs job-test-fwn8j
Hello Docker
total 4
-rwx------. 1 root root 836 Nov 13 2020 ks-script-DrRL8A
-rw-------. 1 root root 0 Nov 13 2020 yum.log
Bye Docker
[root@master ~/kube/07/job]# kubectl delete jobs.batch job-test
job.batch "job-test" deleted
========================================
오후 3:13 2024-11-03
[root@master ~/kube/07/cronjob]# kubectl get cronjobs.batch cronjob-test
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
cronjob-test * * * * * False 1 2s 58s
[root@master ~/kube/07/cronjob]# kubectl get pod
NAME READY STATUS RESTARTS AGE
cronjob-test-28843573-bqkq9 0/1 ContainerCreating 0 6s
'Kubernetes' 카테고리의 다른 글
[kubernetes 수업] 06장 POD 관련 (0) | 2024.11.02 |
---|---|
[kubernetes 수업] 05장 Architecture 관련 (0) | 2024.11.02 |
[kubernetes 수업] 04장 kubernetes 컨테이너 관리 (0) | 2024.11.02 |