-
Notifications
You must be signed in to change notification settings - Fork 1
Service
Gregory Nickonov edited this page Mar 4, 2019
·
1 revision
R.service :frontend do
match_labels component: :frontend
expose_default_http_port
endMatch Pods with label component equal to frontend and load balance traffic through TCP port 80.
| Sunstone property | Kubernetes property | Type |
|---|---|---|
| metadata | metadata | Kubernetes Object Metadata |
| spec | spec | ServiceSpec |
match_labels adds one or more labels to the spec.selector property, binding service to Pods with the same set of labels:
R.service :backend do
match_labels feature: :main, component: :backend
endThat will generate the following YAML:
apiVersion: core/v1
kind: Service
metadata:
name: backend
spec:
selector:
matchLabels:
feature: main
component: backendAdd TCP port 80 with name http to the list of exposed ports (shortcut to spec.add_port 80, name: 'http').
| Sunstone property | Kubernetes property | Type |
|---|---|---|
| cluster_ip | clusterIP | String |
| external_ips | externalIPs | Array of String |
| external_name | externalName | String |
| external_traffic_policy | externalTrafficPolicy | String |
| health_check_node_port | healthCheckNodePort | Integer |
| load_balancer_ip | loadBalancerIP | String |
| load_balancer_source_ranges | loadBalancerSourceRanges | Array of String |
| ports | ports | Array of ServicePort |
| publish_not_ready_addresses | publishNotReadyAddresses | Boolean |
| selector | selector | String key to String value map |
| session_affinity | sessionAffinity | String |
| session_affinity_config | sessionAffinityConfig | SessionAffinityConfig |
| type | type | String |
Adds a port with the specified number to the list of exposed ports. You can also specify additional options: name, node_port, target_port and protocol.
R.service :database do
spec.add_port 5432, name: 'postgres`
endadd_port optionally can be used with the block to configure service port properties:
R.service :database do
spec.add_port 5432 do
name 'postgres'
end
end| Sunstone property | Kubernetes property | Type |
|---|---|---|
| name | name | String |
| node_port | nodePort | Integer |
| port | port | Integer |
| protocol | protocol | String |
| target_port | targetPort | String or Integer |
| Sunstone property | Kubernetes property | Type |
|---|---|---|
| client_ip | clientIP | ClientIPConfig |
| Sunstone property | Kubernetes property | Type |
|---|---|---|
| timeout_seconds | timeoutSeconds | Integer |