data engineering

kubernetes HostPort, NodePort, cluster IP

qkqhxla1 2020. 7. 28. 14:23

https://stackoverflow.com/questions/50709001/rancher-2-difference-between-nodeport-hostport-and-cluster-ip


https://rancher.com/docs/rancher/v2.x/en/v1.6-migration/expose-services/


참조.



HostPort (nodes running a pod):

  Similiar to docker, this will open a port on the node on which the pod is running (this allows you to open port   80 on the host). This is pretty easy to setup an run, however:

Don’t specify a hostPort for a Pod unless it is absolutely necessary. When you bind a Pod to a hostPort, it limits the number of places the Pod can be scheduled, because each combination must be unique. If you don’t specify the hostIP and protocol explicitly, Kubernetes will use 0.0.0.0 as the default hostIP and TCP as the default protocol. kubernetes.io

HostPort : 당 팟이 돌아가는 호스트의 포트를 외부로 노출시킴. 꼭 필요하지 않으면 되도록 사용하지 말것.

NodePort (On every node): Is restricted to ports between port 30,000 to ~33,000. This usually only makes sense in combination with an external loadbalancer (in case you want to publish a web-application on port 80)

If you explicitly need to expose a Pod’s port on the node, consider using a NodePort Service before resorting to hostPort. kubernetes.io

NodePort : 30000~33000대 사이의 포트중 하나를 외부로 노출시킴. 외부 로드밸런서에서 내부와 다른 포트로 들어오게 하고 싶을때 조합해서 사용함.(내부에서 연결시 30000번으로 연결해야 하더라도 외부에서 80번으로 들어오게 하고싶을때 사용.) 서비스를 노출해야 할 일이 있으면 HostPort보다 NodePort를 우선적으로 고려한다.


Cluster IP
(Internal only): As the description says, this will open a port only available for internal applications running in the same cluster. A service using this option is accessbile via the internal cluster-ip.

Cluster IP : 내부 통신용으로만 쓰임. 내부 통신용으로 사용하고 싶으면 이걸 사용.

'data engineering' 카테고리의 다른 글

mongodb set ttl  (0) 2020.08.15
kubernetes rancher add helm chart catalogs  (0) 2020.08.03
Vault.  (0) 2020.07.16
kafka set credentials  (0) 2020.07.13
jenkins in kubernetes RBAC, configure master, slave node  (0) 2020.06.29