728x90
반응형
Practice Test - Rolling Updates and Rollbacks
$ alias k=kubectl
## Deployment 배포 전략 확인
$ k describe deploy frontend
Name: frontend
Namespace: default
CreationTimestamp: Sat, 18 Feb 2023 07:02:45 +0000
Labels: <none>
Annotations: deployment.kubernetes.io/revision: 1
Selector: name=webapp
Replicas: 4 desired | 4 updated | 4 total | 4 available | 0 unavailable
StrategyType: RollingUpdate
## Deployment 이미지 변경 명령어 옵션 확인
$ k set image -h
Update existing container image(s) of resources.
Possible resources include (case insensitive):
pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts),
cronjob (cj), replicaset (rs)
Examples:
# Set a deployment's nginx container image to 'nginx:1.9.1', and its busybox container image to
'busybox'
kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1
# Update all deployments' and rc's nginx container's image to 'nginx:1.9.1'
kubectl set image deployments,rc nginx=nginx:1.9.1 --all
# Update image of all containers of daemonset abc to 'nginx:1.9.1'
kubectl set image daemonset abc *=nginx:1.9.1
# Print result (in yaml format) of updating nginx container image from local file, without hitting
the server
kubectl set image -f path/to/file.yaml nginx=nginx:1.9.1 --local -o yaml
...
## Container 이름 확인
$ k get deploy frontend -o yaml
...
spec:
containers:
- image: kodekloud/webapp-color:v1
imagePullPolicy: IfNotPresent
name: simple-webapp
...
## 이미지 변경
## 옵션 1
$ k set image deploy frontend simple-webapp=kodekloud/webapp-color:v2
## 옵션 2
$ k edit deploy frontend
Practice Test - Commands and Arguments
- Pod 시작 시 실행되는 명령어 확인
$ k get po ubuntu-sleeper -o yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2023-02-18T12:17:43Z"
name: ubuntu-sleeper
namespace: default
resourceVersion: "785"
uid: d1e21263-5e88-4167-8566-921649ab09a1
spec:
containers:
- command:
- sleep
- "4800"
image: ubuntu
- 오류있는 yaml 파일 수정
$ k apply -f ubuntu-sleeper-3.yaml
Error from server (BadRequest): error when creating "ubuntu-sleeper-3.yaml": Pod in version "v1" cannot be handled as a Pod: json: cannot unmarshal number into Go struct field Container.spec.containers.command of type string
## 수정 전
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-3
spec:
containers:
- name: ubuntu
image: ubuntu
command:
- "sleep"
- 1200
## 수정 후
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-3
spec:
containers:
- name: ubuntu
image: ubuntu
command:
- sleep
- "1200"
- command : 명령어, args : 명령어 전달 인자
apiVersion: v1
kind: Pod
metadata:
name: webapp-green
labels:
name: webapp-green
spec:
containers:
- name: simple-webapp
image: kodekloud/webapp-color
command: ["python", "app.py"]
args: ["--color", "green"]
728x90
'기타 > 자격증' 카테고리의 다른 글
[CKA][실습] 5. Cluster Maintenance (2) | 2023.02.26 |
---|---|
[CKA][실습] 4. Application Lifecycle Management (2) (0) | 2023.02.19 |
[CKA][실습] 3. Logging & Monitoring (0) | 2023.02.11 |
[CKA][실습] 2. Scheduling (2) (0) | 2023.02.11 |
[CKA][실습] 2. Scheduling (0) | 2023.02.05 |