Skip to content

Service

Gregory Nickonov edited this page Mar 4, 2019 · 1 revision

Quick start

R.service :frontend do
  match_labels component: :frontend

  expose_default_http_port
end

Match Pods with label component equal to frontend and load balance traffic through TCP port 80.

Service

Kubernetes Documentation

Sunstone property Kubernetes property Type
metadata metadata Kubernetes Object Metadata
spec spec ServiceSpec

match_labels

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
end

That will generate the following YAML:

apiVersion: core/v1
kind: Service
metadata:
  name: backend
spec:
  selector:
    matchLabels:
      feature: main
      component: backend

expose_default_http_port

Add TCP port 80 with name http to the list of exposed ports (shortcut to spec.add_port 80, name: 'http').

ServiceSpec

Kubernbetes Documentation

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

add_port

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`
end

add_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

ServicePort

Kubernetes Documentation

Sunstone property Kubernetes property Type
name name String
node_port nodePort Integer
port port Integer
protocol protocol String
target_port targetPort String or Integer

SessionAffinityConfig

Kubernetes Documentation

Sunstone property Kubernetes property Type
client_ip clientIP ClientIPConfig

ClientIPConfig

Kubernetes Documentation

Sunstone property Kubernetes property Type
timeout_seconds timeoutSeconds Integer
Clone this wiki locally