The Service specification is fairly simple, documented for version 1.8 at https://kubernetes.io/docs/api-reference/v1.8/#service-v1-core. All resources within Kubernetes can be defined declaratively, which we will look at in more depth in Chapter 4, Declarative Infrastructure. Resources can also be defined using YAML as well as JSON. To look at the details of what can be included with a Service resource, we will look at the YAML specification for it. The core of the specification includes a name, a selector for the Pods that provide the service, and ports associated with the services.
For example, a simple service declaration for our flask Pod might be:
kind: ServiceapiVersion: v1metadata: name: servicespec: selector: ...