1 개요[ | ]
- kubectl expose
Console
Copy
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15s
Console
Copy
$ kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
service "kubernetes-bootcamp" exposed
Console
Copy
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 22s
kubernetes-bootcamp NodePort 10.100.84.34 <none> 8080:31392/TCP 5s
2 실습[ | ]
Console
Copy
$ kubectl create deployment nginx --image=nginx
deployment.apps/nginx created
Console
Copy
$ kubectl get all -l app=nginx
NAME READY STATUS RESTARTS AGE
pod/nginx-65f88748fd-77jm4 1/1 Running 0 16s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1/1 1 1 16s
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-65f88748fd 1 1 1 16s
Console
Copy
$ kubectl expose deployment nginx
error: couldn't find port via --port flag or introspection
See 'kubectl expose -h' for help and examples
Console
Copy
$ kubectl expose deployment nginx --port 80
service/nginx exposed
Console
Copy
$ kubectl get service nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx ClusterIP 10.105.247.20 <none> 80/TCP 3s
Console
Copy
$ kubectl get ep nginx
NAME ENDPOINTS AGE
nginx 192.168.235.135:80 27s
Console
Copy
$ kubectl delete service nginx
service "nginx" deleted
Console
Copy
$ kubectl expose deployment nginx --port 80 --type=NodePort
service/nginx exposed
Console
Copy
$ kubectl get service nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx NodePort 10.96.194.32 <none> 80:32318/TCP 12s
Console
Copy
$ kubectl get ep nginx
NAME ENDPOINTS AGE
nginx 192.168.235.135:80 27s
3 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.