Service 类型共有四种 ExternalName, ClusterIP(默认,仅用于集群内部), NodePort(对外), LoadBalancer(基于云平台的Service)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
[root@k8s001 ~]# kubectl explain svc.spec.type KIND: Service VERSION: v1
FIELD: type <string>
DESCRIPTION: type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. "ExternalName" maps to the specified externalName. "ClusterIP" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is "None", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. "NodePort" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. "LoadBalancer" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types