[11] Deployment & Expose the Service

❓Deploy and Service

Reference

docs에서 nodeport검색

Service

실습

[user@console ~]$ kubectl config use-context k8s

[user@console ~]$ kubectl get deployment front-end

[user@console ~]$ kubectl get deployment front-end -o yaml > front-end.yaml

[user@console ~]$ vi front-end.yaml

기존 파일에 밑의 내용 추가

spec:
  containers:
  - image: nginx
		name: http
#여기까지가 기존내용, 아래 내용 전부 넣기
    ports:
      - containerPort: 80
        name: http

---
apiVersion: v1
kind: Service
metadata:
  name: front-end-svc
spec:
	type: NodePort
  selector:
    run: nginx
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: http

:wq

# 충돌되지 않도록 삭제 후 생성
[user@console ~]$ kubectl delete deployment front-end

[user@console ~]$ kubectl apply -f front-end.yaml

기출문제 (31번)

Create a deployment as follows: Name: nginx-random Exposed via a service nginx-random Ensure that the service & pod are accessible via their respective DNS records.

The container(s) within any pod(s) running as a part of this deployment should use the nginx Image.

Next, use the utility nslookup to look up the DNS records of the service & pod and write the output to /opt/KUNW00601/service.dns and /opt/KUNW00601/pod.dns respectively.

기출문제 (63번)

Create and configure the service front-end-service so it's accessible through NodePort and routes to the existing pod named front-end.


Revision #1
Created 31 May 2023 00:05:19 by 와지
Updated 20 June 2023 13:20:12 by 와지