nginx:alpine
image를 사용하는 nginx-pod
를 배포하도록 하자.
kubectl run nginx-pod --image nginx:alpine
redis:alpine
image를 사용하는 messagin
pod 배포하되, label로 tier=msg
를 설정하도록 하자.
kubectl run messaging --image redis:alpine --labels="tier=msg"
apx-x9984574
namespace를 만들도록 하자.
kubectl create namespace apx-x9984574
node들 리스트를 json format으로 가져와서 /opt/outputs/nodes-z3444kd9.json
에 저장하도록 하자.
kubectl get nodes -o json > /opt/outputs/nodes-z3444kd9.json
messaging-service
service를 만들어서 messaging
application을 6379
port로 노출시키도록 하자.
kubectl get po messaging --show-labels
NAME READY STATUS RESTARTS AGE LABELS
messaging 1/1 Running 0 8m17s tier=msg
kubectl create service clusterip messaging-service --tcp=6379:6379 -o yaml --dry-run=client > service.yaml
vi ./service.yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: messaging-service
name: messaging-service
spec:
ports:
- name: 6379-6379
port: 6379
protocol: TCP
targetPort: 6379
selector:
tier: msg
type: ClusterIP
status:
loadBalancer: {}
kubectl create -f ./service.yaml
hr-web-app
이라는 deployment를 만들도록 하자. image는 kodekloud/webapp-color
를 사용하고 replicas는 2로 하자.
kubectl create deployment --image kodekloud/webapp-color hr-web-app --replicas 2
busybox
image를 사용하고 sleep 1000
command를 실행하는 static-busybox
pod를 controlplane node에 만들도록 하자. 단, static pod로 만들도록 하자.
static pod를 배포시키는 위치는 default로 /etc/kubernetes/manifests
이다.
kubectl run --image busybox static-busybox --dry-run=client -o yaml --command -- sleep 1000 > /etc/kubernetes/manifests/pod.yaml
finance
namespace에 temp-bus
pod를 만들되 image는 reids:alpine
으로 만들도록 하자.
kubectl create ns temp-bus
kubectl run temp-bus --image redis:alpine --namespace finance
orange
pod가 만들어졌는데 문제를 해결하고 정상복구하도록 하자.
kubectl logs orange init-myservice
sh: sleeeep: not found
kubectl get pod orange -o yaml > orange.yaml
kubectl delete -f ./orange.yaml
vi ./orange.yaml
...
initContainers:
- command:
- sh
- -c
- sleep 2;
...
kubectl create -f ./orange.yaml
kubectl get pod orange
NAME READY STATUS RESTARTS AGE
orange 1/1 Running 0 15s
hr-web-app
을 hr-web-app-service
를 사용하여 8080
를 30082
로 노출시키도록 하자.
kubectl get deployments.apps hr-web-app --show-labels
NAME READY UP-TO-DATE AVAILABLE AGE LABELS
hr-web-app 2/2 2 2 35m app=hr-web-app
kubectl create service nodeport hr-web-app-service --tcp=8080:8080 --node-port=30082 -o yaml --dry-run=client > nodeport.yaml
vi ./nodeport.yaml
...
selector:
app: hr-web-app
type: NodePort
...
kubectl create -f ./nodeport.yaml
json path query를 사용하여 모든 node들의 osImage
결과를 /opt/outputs/nodes_os_x43kj56.txt
에 넣도록 하자.
kubectl get nodes -o=jsonpath={.items[*].status.nodeInfo.osImage} > /opt/outputs/nodes_os_x43kj56.txt
다음의 주어진 조건을 만족하는 Persistent Volume
을 만들도록 하자.
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-analytics
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteMany
hostPath:
path: /pv/data-analytics