Pod port

The array defined in pod.spec.containers[].ports provides a list of ports exposed by the container. You really don't need to specify this list-even if it is empty, as long as your container is listening on ports, they can still be used for network access. This just provides some additional information for Kubernetes

Service ports

The service.spec.ports list of the service configures which requests to the service port are forwarded to which ports on its pod. A successful request can be sent from outside the cluster to the IP address of the node and the nodePort of the service, forwarded to the port of the service, targetPort, and received by the pod on

kind: Service
apiVersion: v1
metadata:
  name: port-example-svc
spec:
  # Make the service externally visible via the node
  type: NodePort

  ports:
    # Which port on the node is the service available through?
    -nodePort: 31234

    # Inside the cluster, what port does the service expose?
    -port: 8080

    # Which port do pods selected by this service expose?
    -targetPort:

  selector:
    # ...

nodePort

This setting makes the service visible outside the Kubernetes cluster through the node's IP address and the port number declared in this attribute. The service must also be of type NodePort (if this field is not specified, Kubernetes will automatically assign a node port)

port

Expose services on designated ports inside the cluster. In other words, the service becomes visible on this port, and requests made to this port are sent to the pod selected by the service

targetPort

This is the port on the pod to which the request is sent. Your application needs to listen for network requests on this port for the service to work

点赞(0)

评论列表 共有 0 评论

暂无评论

微信服务号

微信客服

淘宝店铺

support@elephdev.com

发表
评论
Go
顶部