How do I externally access a service with kubernetes NodePort?

前端 未结 3 776
醉话见心
醉话见心 2021-01-14 10:06

I\'ve setup a NodePort service using the following config:

wordpress-service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
          


        
3条回答
  •  耶瑟儿~
    2021-01-14 10:39

    When you define a service as type NodeIP, every node in your cluster will proxy that port to your service. If you nodes are reachable from outside the Kubernetes cluster, you should be able to access the service at nodeIP:nodePort.

    To determine nodeIP of a particular node, you can use either kubectl get no -o yaml or kubectl describe no . The status.Addresses field will be of interest. Generally, you will see fields like HostName, ExternalIP and InternalIP there.

    To determine nodePort of your service, you can use either kubectl get svc wordpress -o yaml or kubectl describe svc wordpress. The spec.ports.nodePort is the port you need.

提交回复
热议问题