Kubernetes Service Manifest: Difference between revisions
No edit summary |
|||
Line 20: | Line 20: | ||
function: front-end # Label selector, the service is looking for | function: front-end # Label selector, the service is looking for | ||
# pods with the label "function=front-end" | # pods with the label "function=front-end" | ||
ports: | [[#ports|ports]]: | ||
- port: 80 | - port: 80 | ||
targetPort: 8080 | targetPort: 8080 | ||
Line 34: | Line 34: | ||
Optional element. If not specified, it is assumed to be "[[Kubernetes Service Concepts#ClusterIP_Service|ClusterIP]]". | Optional element. If not specified, it is assumed to be "[[Kubernetes Service Concepts#ClusterIP_Service|ClusterIP]]". | ||
==selector== | ==selector== | ||
The service will select the associated pods based on the labels specified in this selector. Also see: {{Internal|Kubernetes_Service_Concepts#Associating_a_Service_with_Pods|Service Concepts - Associating a Service with Pods}} | |||
==ports== | ==ports== | ||
The element contains an array of ports that will exposed by the service. A port is specified by the following elements: | |||
===port=== | |||
The port exposed by the service externally. This is the port the service will be available on, and the value will be used by the external clients connecting to the service. | |||
===targetPort=== | |||
The port exposed by the pods associated with the service. The service will forward requests over connections opened with this port as target. | |||
==publishNotReadyAddresses== | ==publishNotReadyAddresses== |
Revision as of 00:34, 20 September 2020
External
Internal
Example
apiVersion: v1 kind: Service metadata: name: blue labels: size: large spec: type: ClusterIP selector: function: front-end # Label selector, the service is looking for # pods with the label "function=front-end" ports: - port: 80 targetPort: 8080 protocol: TP
.metadata Elements
labels
The labels declared here apply to the service instance itself, they have no relationship to the target pods' labels, which are declared in the spec selector. Also see:
.spec Elements
type
Optional element. If not specified, it is assumed to be "ClusterIP".
selector
The service will select the associated pods based on the labels specified in this selector. Also see:
ports
The element contains an array of ports that will exposed by the service. A port is specified by the following elements:
port
The port exposed by the service externally. This is the port the service will be available on, and the value will be used by the external clients connecting to the service.
targetPort
The port exposed by the pods associated with the service. The service will forward requests over connections opened with this port as target.