문제 1
Deploy a pod named nginx-pod using the nginx:alpine image. Once done, click on the Next Question button in the top right corner of this panel. You may navigate back and forth freely between all questions. Once done with all questions, click on End Exam. Your work will be validated at the end and score shown. Good Luck!
Name: nginx-pod
Image: nginx:alpine
문제 1 답
vi nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx
image: nginx:alpine
kubectl apply -f nginx-pod.yaml
문제 1 관련 공식 문서
Pods
Production-Grade Container Orchestration
kubernetes.io
문제 2
Deploy a messaging pod using the redis:alpine image with the labels set totier=msg.
Pod Name: messaging
Image: redis:alpine
Labels: tier=msg
문제 2 답
vi messaging.yaml
apiVersion: v1
kind: Pod
metadata:
name: messaging
labels:
tier: msg
spec:
containers:
- name: redis
image: redis:alpine
kubectl apply -f messaging.yaml
문제 2 관련 공식문서
Pods
Production-Grade Container Orchestration
kubernetes.io
Labels and Selectors
Labels are key/value pairs that are attached to objects such as Pods. Labels are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system. Labels can
kubernetes.io
문제 3
Create a namespace named apx-x9984574.
Namespace: apx-x9984574
문제 3 답
kubectl create namespace apx-x9984574
문제 3 관련 공식문서
Namespaces
In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster. Names of resources need to be unique within a namespace, but not across namespaces. Namespace-based scoping is applicable only for namespaced objects (
kubernetes.io
문제 4
Get the list of nodes in JSON format and store it in a file at /opt/outputs/nodes-z3444kd9.json.
Task completed
문제 4 답
kubectl get nodes -o json > /opt/outputs/nodes-z3444kd9.json
문제 4 관련 공식문서
Command line tool (kubectl)
Production-Grade Container Orchestration
kubernetes.io
문제 5
Create a service messaging-service to expose the messaging application within the cluster on port 6379. Use imperative commands.
Service: messaging-service
Port: 6379
Type: ClusterIp Use the right labels
문제 5 답 1
kubectl create service clusterip messaging-service --tcp=6379:6379 --dry-run=client -o yaml | kubectl apply -f -
문제 5 답 2
# 문제에 이미지가 없어 우선 nginx-alpine으로 대체한다.
kubectl create deployment messaging-deployment --image=nginx:alpine
kubectl expose deployment messaging-deployment --name=messaging-service --port=6379 --target-port=6379 --type=ClusterIP --labels=app=messaging
문제 5 관련 공식문서
Service
Expose an application running in your cluster behind a single outward-facing endpoint, even when the workload is split across multiple backends.
kubernetes.io
문제 6
Create a deployment named hr-web-app using the image kodekloud/webapp-color with 2 replicas.
Name: hr-web-app
Image: kodekloud/webapp-color
Replicas: 2
문제 6 답
kubectl create deployment hr-web-app --image=kodekloud/webapp-color --replicas=2
문제 6 관련 공식문서
Deployments
A Deployment manages a set of Pods to run an application workload, usually one that doesn't maintain state.
kubernetes.io
문제 7
Create a static pod named static-busybox on the controlplane node that uses the busybox image and the command sleep 1000.
Name: static-busybox
Image: busybox
문제 7 답
cd /etc/kubernetes/manifests/
cat <<EOF > /etc/kubernetes/manifests/static-busybox.yaml
apiVersion: v1
kind: Pod
metadata:
name: static-busybox
spec:
containers:
- name: busybox
image: busybox
command: ["sleep", "1000"]
EOF
문제 7 관련 공식문서
Create static Pods
Static Pods are managed directly by the kubelet daemon on a specific node, without the API server observing them. Unlike Pods that are managed by the control plane (for example, a Deployment); instead, the kubelet watches each static Pod (and restarts it i
kubernetes.io
문제 8
Create a POD in the finance namespace named temp-bus with the image redis:alpine.
Name: temp-bus
Image Name: redis:alpine
문제 8 답
kubectl create namespace finance
kubectl run temp-bus --image=redis:alpine --namespace=finance
문제 8 관련 공식문서
kubectl run
Production-Grade Container Orchestration
kubernetes.io
문제 9
A new application orange is deployed. There is something wrong with it. Identify and fix the issue.
문제 9 답
kubectl describe pod orange
kubectl get pod orange -o yaml > orange.yaml
vi orange.yaml
kubectl delete pod orange
kubectl apply -f orange.yaml
문제 9 관련 공식문서
Debug Pods
This guide is to help users debug applications that are deployed into Kubernetes and not behaving correctly. This is not a guide for people who want to debug their cluster. For that you should check out this guide. Diagnosing the problem The first step in
kubernetes.io
문제 10
Expose the hr-web-app as service hr-web-app-service application on port 30082 on the nodes on the cluster. The web application listens on port 8080.
Name: hr-web-app-service
Type: NodePort
Endpoints: 2
Port: 8080
NodePort: 30082
문제 10 답
kubectl create service nodeport hr-web-app-service --tcp=8080:8080 --node-port=30082
문제 10 관련 공식문서
https://kubernetes.io/docs/concepts/services-networking/service/#nodeport
Service
Expose an application running in your cluster behind a single outward-facing endpoint, even when the workload is split across multiple backends.
kubernetes.io
문제 11
Use JSON PATH query to retrieve the osImages of all the nodes and store it in a file /opt/outputs/nodes_os_x43kj56.txt. The osImages are under the nodeInfo section under status of each node. Task Completed
문제 11 답
kubectl get nodes -o jsonpath='{range .items[*]}{.status.nodeInfo.osImage}{"\n"}{end}'
문제 11 관련 공식 문서
JSONPath Support
Kubectl supports JSONPath template. JSONPath template is composed of JSONPath expressions enclosed by curly braces {}. Kubectl uses JSONPath expressions to filter on specific fields in the JSON object and format the output. In addition to the original JSON
kubernetes.io
문제 12
Create a Persistent Volume with the given specification:
Volume name: pv-analytics
Storage: 100Mi
Access mode: ReadWriteMany
Host path: /pv/data-analytics
Is the volume name set?
Is the storage capacity set?
Is the accessMode set?
Is the hostPath set?
문제 12 답
vi pv-analytics.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-analytics
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteMany
hostPath:
path: /pv/data-analytics
kubectl apply -f pv-analytics.yaml
문제 12 관련 공식 문서
Persistent Volumes
This document describes persistent volumes in Kubernetes. Familiarity with volumes, StorageClasses and VolumeAttributesClasses is suggested. Introduction Managing storage is a distinct problem from managing compute instances. The PersistentVolume subsystem
kubernetes.io
'기술 탐구 > k8s' 카테고리의 다른 글
(k8s) Volume이란 무엇일까? (emptyDir, hostPath, PVC/PV) (0) | 2024.08.13 |
---|---|
(k8s) Service의 정의와 3가지 타입(ClusterIP, NodePort, LoadBalaner) (0) | 2024.08.04 |
(k8s) m1 mac 환경에서 k8s 클러스터를 구축해보자. (0) | 2024.07.08 |
(k8s) Pod에 대한 정의와 각종 속성 (2) | 2024.06.14 |
(k8s) 쿠버네티스 명령어 (2) | 2024.06.13 |