k8s service

Service:

 “Service” is an abstraction which defines a logical set of Pods and a policy by which to access them.  The logical set of Pods is defined by lable selector. 

  • Service will be assigned an IP address (“cluster IP”), which is used by the service proxies.
  • Service can map an incoming port to any targetPort. (By default the targetPort will be set to the same value as the port field and it can defined as a string.)

There are 4 types of service

  • ClusterIP – Exposes the service on a cluster-internal IP. Service is only reachable from within the cluster. This is the default Typeo
  • NodePort – Exposes the service on each Node’s IP at a static port. A ClusterIP service (example below it is 10.106.1.12), to which the NodePort service will route, is automatically created. You’ll be able to contact the NodePort service, from outside the cluster, by using “<NodeIP>:<NodePort>”.  In yaml file, Port is  mandoary, by default port = target port.  It using selector and lable to recognise the pods it connect.
  •   using selector 
  • LoadBalancer – Exposes the service externally using a cloud provider’s load balancer. NodePort and ClusterIP services, to which the external load balancer will route, are automatically created.
  • ExternalName – Maps the service to the contents of the externalName field (e.g. foo.bar.example.com), by returning a CNAME record with its value.

k8s network https://www.youtube.com/watch?v=WwQ62OyCNz4

猜你喜欢

转载自www.cnblogs.com/anyu686/p/11300846.html
今日推荐