728x90
# pod 생성
kubectl create deployment np-pods --image=sysnet4admin/echo-hname
# nodeport 실습
vi nodeport.yaml
# nodeport.yaml
apiVersion: v1
kind: Service
metadata:
name: np-svc
spec:
selector:
app: np-pods
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
nodePort: 30000
type: NodePort
kubectl create -f nodeport.yaml
# node 수 3개
kubectl scale deployment np-pods --replicas=3
# np-pod와 같이 묶임
kubectl expose deployment np-pods --type=NodePort --name=np-svc-v2 --port=80
ubuntu@ip-172-31-8-104:~$ k get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 105m
np-svc NodePort 10.100.116.82 <none> 80:30000/TCP 39m
np-svc-v2 NodePort 10.100.203.222 <none> 80:32465/TCP 72s
# 삭제(순서대로 안하면 다시 살아남)
kubectl delete deployment np-pods
kubectl delete services np-svc
kubectl delete services np-svc-v2
728x90
'Bootcamp' 카테고리의 다른 글
[Kubernetes] Ingress 2 (0) | 2024.02.07 |
---|---|
[Kubernetes] Ingress (0) | 2024.02.06 |
[Kubernetes] Rolling Updte (0) | 2024.02.05 |
[AWS] kubectl 연습 (0) | 2024.02.05 |
[Kubernetes] 쿠버네티스 마스터 설정하기 (1) | 2024.02.01 |