Exercise 3.4: Deploy A Sample Application
Deployment 생성
kubectl create deployment nginx --image=nginxDeployment 상태 확인
kubectl get deployPod가 생성되었는지 확인
kubectl get pod생성된 NGINX Deployment 상태 상세 확인
kubectl describe deployment nginx클러스터에 발생한 이벤트 확인
kubectl get events --sort-by='.metadata.creationTimestamp'생성된 NGINX Deployment의 Manifest를 YAML 형식으로 출력
kubectl get deploy nginx -o yaml생성된 NGINX Deployment의 Manifest를 YAML 형식으로 저장
kubectl get deploy nginx -o yaml > first.yamlfirst.yaml파일을 텍스트 에디터에서 열고 아래와 같이 수정하세요.creationTimestamp,resourceVersion,uid를 포함하는 라인 삭제status아래의 모든 라인 삭제 (status 포함)수정 완료 버전
apiVersion: apps/v1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" generation: 1 labels: app: nginx name: nginx namespace: default spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: nginx strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx imagePullPolicy: Always name: nginx resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30
NGINX Deployment 삭제
kubectl delete deploy nginx위에서 생성한
first.yaml파일을 이용해서 Deployment 생성kubectl apply -f first.yamlDeployment 상태 확인
kubectl get deploy새로 생성된 NGINX Deployment의 Manifest를 YAML 형식으로 저장
kubectl get deploy nginx -o yaml > second.yaml두개의 YAML 파일을 비교
diff first.yaml second.yaml -yDeployment의 resourceVersion 값 확인
kubectl get deploy nginx -o=jsonpath='{.metadata.resourceVersion}{"\n"}'Deployment에 속하는 Pod 삭제
kubectl delete pod -l app=nginxDeployment의 resourceVersion 값을 다시 확인
kubectl get deploy nginx -o=jsonpath='{.metadata.resourceVersion}{"\n"}'dry-run옵션으로 실제 리소스를 생성하지 않고 Manifest만 확인kubectl create deployment nginx --image=nginx --dry-run=client -o yamlNGINX Deployment의 Manifest를 JSON 형식으로 출력
kubectl get deployment nginx -o jsonNGINX Deployment에 서비스 생성
kubectl expose deployment/nginxkubectl expose명령어에 대한 도움말 보기kubectl expose -hfirst.yaml파일의spec.templates.spec.containers부분을 아래와 같이 수정.... spec: containers: - image: nginx imagePullPolicy: Always name: nginx ports: - containerPort: 80 protocol: TCP ....first.yaml파일의 수정 완료 버전apiVersion: apps/v1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" generation: 1 labels: app: nginx name: nginx namespace: default spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: nginx strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx imagePullPolicy: Always name: nginx ports: - containerPort: 80 protocol: TCP resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30변경사항 반영
kubectl apply -f first.yamlDeployment와 Pod가 새로 생성됐는지 확인
kubectl get deploy,rs,podNGINX Deployment에 서비스 생성
kubectl expose deployment/nginxNGINX 서비스 확인
kubectl get svc nginxNGINX 서비스에 연결된 Endpoints 확인
kubectl get ep nginx현재 배포된 Pod의 IP 주소 확인
kubectl get pod -l app=nginx -o wideWorker 노드에 연결된 터미널로 이동해서 트래픽 캡쳐
sudo tcpdump -i cilium_vxlanCP 노드에 연결된 터미널로 이동해서 NGINX 서비스의 ClusterIP에 HTTP 요청
curl NGINX_SVC_CLUSTER_IPOR
curl $(kubectl get svc nginx -o=jsonpath='{.spec.clusterIP}')Worker 노드에 연결된 터미널로 이동해서 트래픽 캡쳐 결과 확인 하고
tcpdump프로세스 종료CP 노드에 연결된 터미널로 돌아와서 노드의 IP 주소 확인
ip aCilium을 통해서 생성된 사용자 지정 객체 확인
kubectl get ciliumnodesNGINX 서비스에 연결된 Endpoints 주소로 HTTP 요청
curl NGINX_ENDPOINT_IPOR
curl $(kubectl get ep nginx -o=jsonpath='{.subsets[0].addresses[0].ip}:{.subsets[0].ports[0].port}')NGINX Deployment의 Replica 갯수를 3개로 변경
kubectl scale deployment nginx --replicas=3Pod가 추가로 생성됐는지 확인
kubectl get pod -l app=nginx -o wideNGINX 서비스에 연결된 Endpoints 확인
kubectl get ep nginx
Last updated