<aside> 💡 예제) 다음과 같은 결과가 도출되도록 ‘단일’ 매니페스트 파일을 구성 후 해당 디플로이먼트가 30500 노드포트로 배포될 수 있도록 하시오. 이미지는 192.168.0.195:5000/hgninx를 사용.
</aside>
<aside> 💡 예제) 192.168.0.195:5000/hnginx라는 이미지는 호스트 네임을 출력하는 간단한 nginx컨테이너 이미지이다. 해당 이미지를 통해 app: hnginx라는 label을 갖는 pod 레플리카 셋을 3으로 구성한 후 np-rep-svc라는 서비스를 통해 해당 레플리카 셋을 노드 포트(:32767)로 연결 시켜보세요! 단일 yml로!
</aside>
**root@master:~# cp test.yml np-rep-svc.yml
root@master:~# vi np-rep-svc.yml
###
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: hnginx
spec:
selector:
matchLabels:
app: nginx
replicas: 3
template:
metadata:
name: hnginx
labels:
app: nginx
spec:
containers:
- name: np-rep-container
image: 192.168.0.195:5000/hnginx
---
apiVersion: v1
kind: Service
metadata:
name: np-rep-svc
spec:
selector:
app: nginx
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
nodePort: 32767
type: NodePort
###
root@master:~# kubectl create -f np-rep-svc.yml
replicaset.apps/hnginx created
service/np-rep-svc created
root@master:~# kubectl get pod,rs,svc
NAME READY STATUS RESTARTS AGE
pod/hnginx-kld4d 1/1 Running 0 4s
pod/hnginx-ww5fx 1/1 Running 0 4s
pod/hnginx-xcjh9 1/1 Running 0 4s
NAME DESIRED CURRENT READY AGE
replicaset.apps/hnginx 3 3 3 4s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15h
service/np-rep-svc NodePort 10.98.251.142 <none> 80:32767/TCP 4s 80:32767/TCP 44s
root@master:~# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hnginx-kld4d 1/1 Running 0 6m6s 10.10.235.151 worker1 <none> <none>
hnginx-ww5fx 1/1 Running 0 6m6s 10.10.189.94 worker2 <none> <none>
hnginx-xcjh9 1/1 Running 0 6m6s 10.10.189.95 worker2 <none> <none>
root@master:~# curl 10.98.251.142:80
hnginx-kld4d
root@master:~# curl 10.98.251.142:80
hnginx-ww5fx
root@master:~# curl 10.98.251.142:80
hnginx-xcjh9
root@master:~# curl 10.10.235.151:80
hnginx-kld4d
root@master:~# curl 10.10.189.94:80
hnginx-ww5fx
root@master:~# curl 10.10.189.95:80
hnginx-xcjh9
root@master:~# curl localhost:32767
hnginx-kld4d
root@master:~# curl localhost:32767
hnginx-xcjh9
root@master:~# curl localhost:32767
hnginx-ww5fx
root@master:~# curl 211.183.3.110:32767
hnginx-kld4d
root@master:~# curl 211.183.3.110:32767
hnginx-xcjh9
root@master:~# curl 211.183.3.110:32767
hnginx-ww5fx
root@master:~# curl 211.183.3.120:32767
hnginx-kld4d
root@master:~# curl 211.183.3.120:32767
hnginx-xcjh9
root@master:~# curl 211.183.3.120:32767
hnginx-ww5fx
root@master:~# kubectl delete pod,rs,service --all
pod "hnginx-kld4d" deleted
pod "hnginx-ww5fx" deleted
pod "hnginx-xcjh9" deleted
replicaset.apps "hnginx" deleted
service "kubernetes" deleted
service "np-rep-svc" deleted**
v1
쿠버네티스에서 발행한 첫 stable release API
(대부분의 api가 포함되어 있음)
apps/v1 : 쿠버네티스의 common API 모음, Deployment, RollingUpdate, ReplicaSet을 포함
kubectl create namespace kakao --dry-run=client -o yaml > kakao-ns.yml
#kakao 라는 네임스페이스 매니페스트 파일 생성
#드라이로 만들어서 실제 네임스페이스가 생성은 안되었는데
kakao-ns.yml 파일 얻어낼 수 있다
vi kakao-ns.yml 들어가서 아래 사진처럼 수정하기