kubectl create deployment myweb --image=ghcr.io/c1t1d0s7/go-myweb
### 컨테이너를 만드는 명령어
kubectl get deployments,replicasets,pods
### 결과
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/myweb 1/1 1 1 4m40s
NAME DESIRED CURRENT READY AGE
replicaset.apps/myweb-97dbf5749 1 1 1 4m40s
NAME READY STATUS RESTARTS AGE
pod/myweb-97dbf5749-8tq2l 1/1 Running 0 4m40s
kubectl expose deployment myweb --port=80 --protocol=TCP --target-port=8080 --name myweb-svc --type=NodePort
### 쿠버네티스는 포트포워딩이 없고 외부로 포트를 노출시키는 방식임
서비스라는 이름으로 불림
kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 40m
myweb-svc NodePort 10.96.114.201 <none> 80:31891/TCP 5s
### 여기서는 31891번 포트로 연결되어있지만 매번 랜덤하게 30000번대로 결정된다.
크롭창에서 접속
curl 192.168.100.100:31891
### 결과값
Hello World!
myweb-97dbf5749-8tq2l
kubectl scale deployment myweb --replicas=3
### pod의 개수를 3개로 만듬
kubectl get pods
### 결과값
myweb-97dbf5749-8tq2l 1/1 Running 0 12m
myweb-97dbf5749-9bm8l 1/1 Running 0 3m13s
myweb-97dbf5749-n29m2 1/1 Running 0 3m13s
curl 192.168.100.100:31891
kubectl delete service myweb-svc
kubectl delete deployment myweb