"Kubectl expose"의 두 판 사이의 차이

 
(같은 사용자의 중간 판 5개는 보이지 않습니다)
1번째 줄: 1번째 줄:
{{소문자}}
==개요==
==개요==
;kubectl expose
;kubectl expose
19번째 줄: 20번째 줄:
==실습==
==실습==
<source lang='console'>
<source lang='console'>
master:~$ kubectl create deployment nginx --image=nginx
$ kubectl create deployment nginx --image=nginx
deployment.apps/nginx created
deployment.apps/nginx created
</source>
</source>
<source lang='console'>
<source lang='console'>
master:~$ kubectl get all -l app=nginx
$ kubectl get all -l app=nginx
NAME                        READY  STATUS    RESTARTS  AGE
NAME                        READY  STATUS    RESTARTS  AGE
pod/nginx-65f88748fd-77jm4  1/1    Running  0          16s
pod/nginx-65f88748fd-77jm4  1/1    Running  0          16s
34번째 줄: 35번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master:~$ kubectl expose deployment nginx  
$ kubectl expose deployment nginx  
error: couldn't find port via --port flag or introspection
error: couldn't find port via --port flag or introspection
See 'kubectl expose -h' for help and examples
See 'kubectl expose -h' for help and examples
</source>
</source>
<source lang='console'>
<source lang='console'>
master:~$ kubectl expose deployment nginx --port 80
$ kubectl expose deployment nginx --port 80
service/nginx exposed
service/nginx exposed
</source>
</source>
<source lang='console'>
<source lang='console'>
master:~$ kubectl get all -l app=nginx
$ kubectl get service nginx
NAME                         READY  STATUS   RESTARTS  AGE
NAME    TYPE        CLUSTER-IP      EXTERNAL-IP  PORT(S)  AGE
pod/nginx-65f88748fd-77jm4  1/1    Running  0          2m50s
nginx  ClusterIP  10.105.247.20  <none>        80/TCP    3s
 
</source>
NAME            TYPE        CLUSTER-IP      EXTERNAL-IP  PORT(S)  AGE
<source lang='console'>
service/nginx  ClusterIP  10.105.247.20  <none>        80/TCP    3s
$ kubectl get ep nginx
 
NAME   ENDPOINTS            AGE
NAME                    READY  UP-TO-DATE  AVAILABLE  AGE
nginx  192.168.235.135:80   27s
deployment.apps/nginx   1/1    1            1          2m50s
 
NAME                               DESIRED  CURRENT  READY  AGE
replicaset.apps/nginx-65f88748fd   1        1        1      2m50s
</source>
</source>
<source lang='console'>
<source lang='console'>
master:~$ kubectl delete service/nginx
$ kubectl delete service nginx
service "nginx" deleted
service "nginx" deleted
</source>
</source>
<source lang='console'>
<source lang='console'>
master:~$ kubectl expose deployment nginx --port 80 --type=NodePort
$ kubectl expose deployment nginx --port 80 --type=NodePort
service/nginx exposed
service/nginx exposed
</source>
</source>
<source lang='console'>
<source lang='console'>
master:~$ kubectl get all -l app=nginx
$ kubectl get service nginx
NAME                         READY  STATUS   RESTARTS  AGE
NAME    TYPE      CLUSTER-IP    EXTERNAL-IP  PORT(S)        AGE
pod/nginx-65f88748fd-77jm4  1/1    Running  0          4m41s
nginx  NodePort  10.96.194.32   <none>        80:32318/TCP  12s
 
</source>
NAME            TYPE      CLUSTER-IP    EXTERNAL-IP  PORT(S)        AGE
<source lang='console'>
service/nginx  NodePort  10.96.18.173   <none>        80:31506/TCP  5s
$ kubectl get ep nginx
 
NAME   ENDPOINTS            AGE
NAME                    READY  UP-TO-DATE  AVAILABLE  AGE
nginx  192.168.235.135:80   27s
deployment.apps/nginx   1/1    1            1          4m41s
 
NAME                               DESIRED  CURRENT  READY  AGE
replicaset.apps/nginx-65f88748fd   1        1        1      4m41s
</source>
</source>


83번째 줄: 76번째 줄:
* [[kubectl describe]]
* [[kubectl describe]]
* [[kubectl]]
* [[kubectl]]
* [[k8s 서비스]]
* [[Dockerfile EXPOSE]]
* [[Dockerfile EXPOSE]]


[[분류: kubectl]]
[[분류: kubectl]]

2019년 5월 29일 (수) 13:37 기준 최신판

1 개요[ | ]

kubectl expose
$ kubectl get services
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   15s
$ kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
service "kubernetes-bootcamp" exposed
$ 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 실습[ | ]

$ kubectl create deployment nginx --image=nginx
deployment.apps/nginx created
$ 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
$ kubectl expose deployment nginx 
error: couldn't find port via --port flag or introspection
See 'kubectl expose -h' for help and examples
$ kubectl expose deployment nginx --port 80
service/nginx exposed
$ kubectl get service nginx
NAME    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
nginx   ClusterIP   10.105.247.20   <none>        80/TCP    3s
$ kubectl get ep nginx
NAME    ENDPOINTS            AGE
nginx   192.168.235.135:80   27s
$ kubectl delete service nginx
service "nginx" deleted
$ kubectl expose deployment nginx --port 80 --type=NodePort
service/nginx exposed
$ kubectl get service nginx
NAME    TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
nginx   NodePort   10.96.194.32   <none>        80:32318/TCP   12s
$ kubectl get ep nginx
NAME    ENDPOINTS            AGE
nginx   192.168.235.135:80   27s

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}