cp http-go-deploy.yaml http-np-deploy.yaml
nano http-np-deploy.yaml
apiVersion: v1
kind: Service
metadata:
name: http-go-np
spec:
type: NodePort # default는 ClusterIp
selector:
run: http-go
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30001 # default는 랜덤
kubectl create -f http-np-deploy.yaml
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
http-go-np NodePort 10.108.10.79 <none> 80:30001/TCP 99s
http-go-svc ClusterIP 10.108.3.150 <none> 80/TCP 22h
kubernetes ClusterIP 10.108.0.1 <none> 443/TCP 5d8h
my-service ClusterIP 10.108.2.92 <none> 80/TCP 22h
방화벽 열기
gcloud compute firewall-rules create http-go-svc-rule --allow=tcp:30001
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl get pods --show-labels=true
NAME READY STATUS RESTARTS AGE LABELS
bash 1/1 Running 0 22h run=bash
http-go 1/1 Running 0 22h run=http-go
http-go-85cf4fd86b-7wcn8 1/1 Running 0 23h pod-template-hash=85cf4fd86b,run=http-go
http-go-85cf4fd86b-8qh56 1/1 Running 0 23h pod-template-hash=85cf4fd86b,run=http-go
http-go-85cf4fd86b-ktv6b 1/1 Running 0 23h pod-template-hash=85cf4fd86b,run=http-go
http-go-85cf4fd86b-s2t45 1/1 Running 0 23h pod-template-hash=85cf4fd86b,run=http-go
http-go-85cf4fd86b-wx5sv 1/1 Running 0 23h pod-template-hash=85cf4fd86b,run=http-go
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
gke-my-first-cluster-1-default-pool-a0f2cf43-20cx Ready <none> 5d8h v1.27.2-gke.2100 10.128.0.5 35.232.215.24 Ubuntu 22.04.2 LTS 5.15.0-1033-gke containerd://1.7.0
gke-my-first-cluster-1-default-pool-a0f2cf43-m3k4 Ready <none> 5d8h v1.27.2-gke.2100 10.128.0.4 35.202.160.16 Ubuntu 22.04.2 LTS 5.15.0-1033-gke containerd://1.7.0
gke-my-first-cluster-1-default-pool-a0f2cf43-zs3g Ready <none> 5d8h v1.27.2-gke.2100 10.128.0.6 34.170.117.155 Ubuntu 22.04.2 LTS 5.15.0-1033-gke containerd://1.7.0
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 35.232.215.24:30001
Welcome! http-go-85cf4fd86b-s2t45
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 35.232.215.24:30001
Welcome! http-go-85cf4fd86b-8qh56
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 35.232.215.24:30001
Welcome! http-go-85cf4fd86b-s2t45
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 35.202.160.16:30001
Welcome! http-go-85cf4fd86b-ktv6b
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 35.202.160.16:30001
Welcome! http-go-85cf4fd86b-s2t45
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 35.202.160.16:30001
Welcome! http-go-85cf4fd86b-s2t45
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 34.170.117.155:30001
Welcome! http-go-85cf4fd86b-7wcn8
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 34.170.117.155:30001
Welcome! http-go-85cf4fd86b-wx5sv
imkunyoung@cloudshell:~/kubeservice (k8s-inflearn)$ curl 34.170.117.155:30001
Welcome! http-go-85cf4fd86b-7wcn8
Reference: