1. We have deployed a simple web application. Inspect the PODs and the Services
Wait for the application to fully deploy and view the application using the link called Webapp Portal above your terminal.
2. What is the current color of the web application? Access the Webapp Portal.
blue
3. Run the script named curl-test.sh to send multiple requests to test the web application. Take a note of the output.
Execute the script at /root/curl-test.sh.
4. Inspect the deployment and identify the number of PODs deployed by it
controlplane ~ ➜ k get deployments.apps
NAME READY UP-TO-DATE AVAILABLE AGE
frontend 4/4 4 4 5m7s
answer : 4
5. What container image is used to deploy the applications?
controlplane ~ ➜ k describe deployments.apps frontend
Name: frontend
Namespace: default
CreationTimestamp: Tue, 02 Jul 2024 14:13:59 +0000
...
Pod Template:
Labels: name=webapp
Containers:
simple-webapp:
Image: kodekloud/webapp-color:v1
Port: 8080/TCP
Host Port: 0/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Node-Selectors: <none>
Tolerations: <none>
...
answer : kodekloud/webapp-color:v1
6. Inspect the deployment and identify the current strategy
controlplane ~ ➜ k describe deployments.apps frontend
...
RollingUpdateStrategy: 25% max unavailable, 25% max surge
...
answer : RollingUpdate
7. If you were to upgrade the application now what would happen?
answer : PODs are upgrades few at a time
8. Let us try that. Upgrade the application by setting the image on the deployment to kodekloud/webapp-color:v2
Do not delete and re-create the deployment. Only set the new image name for the existing deployment.
controlplane ~ ➜ k edit deployments.apps frontend
###
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
creationTimestamp: "2024-07-02T14:13:59Z"
generation: 2
...
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
name: webapp
spec:
containers:
- image: kodekloud/webapp-color:v1 ## 변경 kodekloud/webapp-color:v2
imagePullPolicy: IfNotPresent
name: simple-webapp
...
9. Run the script curl-test.sh again. Notice the requests now hit both the old and newer versions. However none of them fail. Execute the script at /root/curl-test.sh.
controlplane ~ ➜ /root/curl-test.sh
Hello, Application Version: v1 ; Color: blue OK
Hello, Application Version: v1 ; Color: blue OK
Hello, Application Version: v1 ; Color: blue OK
Failed
Failed
Failed
Failed
Failed
Hello, Application Version: v3 ; Color: red OK
Hello, Application Version: v3 ; Color: red OK
Hello, Application Version: v2 ; Color: green OK
Hello, Application Version: v2 ; Color: green OK
Hello, Application Version: v2 ; Color: green OK
10. Up to how many PODs can be down for upgrade at a time
Consider the current strategy settings and number of PODs - 4
RollingUpdate -> Pod 를 한개씩 업데이트 시키고 업데이트 완료시 이전 버전 1개를 종료시킨다.
answer : 1
11. Change the deployment strategy to Recreate
Delete and re-create the deployment if necessary. Only update the strategy type for the existing deployment.
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
creationTimestamp: "2024-07-02T14:13:59Z"
generation: 3
name: frontend
namespace: default
resourceVersion: "1376"
uid: 1f743bc7-9710-4f83-b243-7901fb2bd370
spec:
minReadySeconds: 20
progressDeadlineSeconds: 600
replicas: 4
revisionHistoryLimit: 10
selector:
matchLabels:
name: webapp
strategy:
type: RolllingUpdate ## Recreate 로 변경
template:
12. Upgrade the application by setting the image on the deployment to kodekloud/webapp-color:v3
Do not delete and re-create the deployment. Only set the new image name for the existing deployment.
controlplane ~ ➜ k edit deployments.apps frontend
###
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "2"
creationTimestamp: "2024-07-02T14:13:59Z"
generation: 2
...
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
name: webapp
spec:
containers:
- image: kodekloud/webapp-color:v2 ## 변경 kodekloud/webapp-color:v3
imagePullPolicy: IfNotPresent
name: simple-webapp
...
13. Run the script curl-test.sh again. Notice the failures. Wait for the new application to be ready. Notice that the requests now do not hit both the versions
Execute the script at /root/curl-test.sh.
Hello, Application Version: v2 ; Color: green OK
Hello, Application Version: v2 ; Color: green OK
Failed
Failed
Failed
Failed
Failed
Hello, Application Version: v3 ; Color: red OK
Hello, Application Version: v3 ; Color: red OK
'IT 기술 > k8s' 카테고리의 다른 글
[cka] Secrets (0) | 2024.07.05 |
---|---|
[cka] Env Variables (0) | 2024.07.05 |
[cka] Managing Application Logs (0) | 2024.06.24 |
[cka] Monitor Cluster Components (0) | 2024.06.24 |
[cka] Multiple Schedulers (0) | 2024.06.23 |
댓글