OpenShift Service Definition: Difference between revisions
(→ports) |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 20: | Line 20: | ||
'''spec''': | '''spec''': | ||
'''type''': <font color=SandyBrown>ClusterIP</font> | '''type''': <font color=SandyBrown>ClusterIP</font> | ||
[[#ports|ports]]: | '''[[#ports|ports]]''': | ||
- name: web | - name: web | ||
port: 3000 | '''[[#port|port]]''': <font color=SandyBrown>3000</font> | ||
protocol: TCP | protocol: TCP | ||
targetPort: 3000 | '''[[#targetPort|targetPort]]''': <font color=SandyBrown>3000</font> | ||
'''<span id='spec.selector'></span>selector''': | '''<span id='spec.selector'></span>selector''': | ||
<font color=SandyBrown>pod_selector_label_name_1</font>: <font color=SandyBrown> pod_selector_value_1</font> | <font color=SandyBrown>pod_selector_label_name_1</font>: <font color=SandyBrown> pod_selector_value_1</font> | ||
Line 40: | Line 40: | ||
===ports=== | ===ports=== | ||
The list of ports that are exposed by this service. | The list of [[OpenShift_Service_Concepts#Ports|ports]] that are exposed by this service. | ||
====port==== | |||
The port that will be exposed by this service. This is part of the service's address, and it should be used by the service's clients to connect to it. This is '''not''' the [[#targetPort|backend pod's port]] - though it can have the same value as the backend pod's port. | |||
====targetPort==== | |||
The backend pod's port number or name. This port will be used by the service to access the pod targeted by it. The number must be in the range 1 - 65535. The name must be a IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). The field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field. |
Latest revision as of 23:10, 26 February 2018
External
Internal
Example
apiVersion: v1 kind: Service metadata: annotations: description: The Gogs server's http port labels: app: gogs name: gogs spec: type: ClusterIP ports: - name: web port: 3000 protocol: TCP targetPort: 3000 selector: pod_selector_label_name_1: pod_selector_value_1 pod_selector_label_name_2: pod_selector_value_2 sessionAffinity: None
Elements
spec
selector
If this selector is included in the service's definition, the EndpointsController associates this service with the endpoints of pods that match the selector. The labels are applied to pods by the deployment configuration 'spec.template.metadata.labels'.
ports
The list of ports that are exposed by this service.
port
The port that will be exposed by this service. This is part of the service's address, and it should be used by the service's clients to connect to it. This is not the backend pod's port - though it can have the same value as the backend pod's port.
targetPort
The backend pod's port number or name. This port will be used by the service to access the pod targeted by it. The number must be in the range 1 - 65535. The name must be a IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). The field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field.