October 2019
Intermediate to advanced
520 pages
13h 5m
English
Services are used to group Pods into a single endpoint. As we know, Pods come and go. A service has a stable IP address, and so requests can be sent to it and forwarded to a Pod. What algorithm is used to perform the forwarding depends on the type of service. We will have a look at each type of service in the next section. Let's take a look at a simple definition of a service. Here, we are using a kind value of Service.
As we mentioned previously, you can use a selector in the service definition and a label in the Pod definition to assign the Pod to a service.
The following is a simple service definition:
apiVersion: v1kind: Servicemetadata: name: service-demospec: selector: app: myapp ports: - protocol: TCP port: 80 targetPort: ...
Read now
Unlock full access