Service | Kubernetes - 0 views
-
Each Pod gets its own IP address
- ...23 more annotations...
-
In Kubernetes, a Service is an abstraction which defines a logical set of Pods and a policy by which to access them (sometimes this pattern is called a micro-service).
-
If you're able to use Kubernetes APIs for service discovery in your application, you can query the API server for Endpoints, that get updated whenever the set of Pods in a Service changes.
-
Kubernetes assigns this Service an IP address (sometimes called the "cluster IP"), which is used by the Service proxies
-
A Service can map any incoming port to a targetPort. By default and for convenience, the targetPort is set to the same value as the port field.
-
As many Services need to expose more than one port, Kubernetes supports multiple port definitions on a Service object. Each port definition can have the same protocol, or a different one.
-
Because this Service has no selector, the corresponding Endpoints object is not created automatically. You can manually map the Service to the network address and port where it's running, by adding an Endpoints object manually
-
Kubernetes ServiceTypes allow you to specify what kind of Service you want. The default is ClusterIP
-
NodePort: Exposes the Service on each Node's IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You'll be able to contact the NodePort Service, from outside the cluster, by requesting <NodeIP>:<NodePort>.
-
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. No proxying of any kind is set up.
-
You can also use Ingress to expose your Service. Ingress is not a Service type, but it acts as the entry point for your cluster.
-
If you set the type field to NodePort, the Kubernetes control plane allocates a port from a range specified by --service-node-port-range flag (default: 30000-32767).
-
The default for --nodeport-addresses is an empty list. This means that kube-proxy should consider all available network interfaces for NodePort.
-
you need to take care of possible port collisions yourself. You also have to use a valid port number, one that's inside the range configured for NodePort use.