Skip to content

PodSpec

Gregory Nickonov edited this page Apr 2, 2019 · 11 revisions

Quick Start

R.deployment :backend do
  pod_spec do
    hostname :backend
    restart_policy :OnFailure

    container do
      image 'tutum/hello-world'
    end
  end
end

PodSpec

Kubernetes Documentation

Property Kubernetes property Type
active_deadline_seconds activeDeadlineSeconds Integer
affinity affinity Affinity
automount_service_account_token automountServiceAccountToken Boolean
dns_config dnsConfig PodDNSConfig
dns_policy dnsPolicy String
enable_service_links enableServiceLinks Boolean
host_aliases hostAliases Array of HostAlias
host_ipc hostIPC Boolean
host_network hostNetwork Boolean
host_pid hostPID Boolean
hostname hostname String
node_name nodeName String
node_selector nodeSelector Hash
priority priority Integer
priority_class_name priorityClassName String
readiness_gates readinessGates Array of PodReadinessGate
restart_policy restartPolicy String
runtime_class_name runtimeClassName String
security_context securityContext PodSecurityContext
scheduler_name schedulerName String
service_account_name serviceAccountName String
share_process_namespace shareProcessNamespace Boolean
subdomain subdomain String
termination_grace_period_seconds terminationGracePeriodSeconds Integer
tolerations tolerations Array of Toleration
image_pull_secrets imagePullSecrets Array of LocalObjectReference
containers containers Array of Container
init_containers initContainers Array of Container
volumes volumes VolumeArray

image_pull_secrets

This property receives a list of resource names in its command form. For example, to add a reference to the secret named image-pull-secret use the following code:

R.deployment :frontend do
  pod_spec.image_pull_secrets 'image-pull-secret'
end

There is also an image_pull_secret alias of image_pull_secrets, solely for aesthetic purposes when you add a single secret.

container

Used to access named container in Pod. If the name is not specified, the default name main is implied. Can be used as an accessor or a block context:

R.deployment :frontend do
  # Deployment will have a side-container named log-forwared with the specified image
  container('log-forwarded').image 'myregistry/tools/log-forwarder:1.0'
end

R.deployment :backend do
  # Main container for the deployment will have the specified image
  container do
    image 'myregistry/app/backend:8a49cf71'

    environment do
      add SECRET_KEY: 'supersecret'
    end
  end
end

Refer to the Container section for the details of the Container implementation.

host_alias

Adds a new alias with the specified IP address and list of host names into the host_aliases array:

R.deployment :backend do
  pod_spec do
    host_alias '1.2.3.4', 'db', 'mydb', 'currentdb'
  end
end

init_container

The same as container, but for the initialization containers. Name is mandatory.

R.deployment :backend do
  pod_spec do
    init_container 'wait-for-database' do
      # Define how to wait for database
    end
  end
end

node_selector

Calling node_selector and passing the set of key-value pairs assigns those pairs to the node selector:

R.deployment :backend do
  pod_spec do
    node_selector kind: :backends, stage: :production
  end
end

While subsequent calls to node_selector helper will add (or overwrite) corresponding key-value pairs, calling node_selector! will replace existing set of labels.

readiness_gates

Helper to add specified readiness condition types to the readiness_gates array:

R.deployment :backend do
  pod_spec do
    readiness_gates :Ready, :Mounted
  end
end

For the aesthetic purposes an alias readiness_gate is provided.

toleration

Helper to create and provide for initialization new Toleration item, which is then added to tolerations array:

R.deployment :backend do
  pod_spec do
    toleration do
      # Setup new toleration
    end
  end
end

PodDNSConfig

Kubernetes Documentation

Property Kubernetes property Type
nameservers nameservers Array of String
options options Array of PodDNSConfigOption
searches searches Array of String

nameservers

With optional values passed adds those values to the nameservers array. For aesthetic purposes an alias nameserver is provided:

R.deployment :backend do
  pod_spec.dns_config do
    nameservers '8.8.8.8', '2.2.2.2'
    nameserver '4.4.4.4'
  end
end

option

Helper to creates, initialize with optional block and adds new option into the options array:

R.deployment :backend do
  pod_spec.dns_config do
    option :ndots, '2'
  end
end

searches

With optional values passed adds those values to the searches arrat. For aesthetic purposes an alias search is provided:

R.deployment :backend do
  pod_spec.dns_config do
    searches 'alfa.example.org', 'beta.example.org'
    nameserver 'gamma.example.org'
  end
end

PodDNSConfigOptions

Kubernetes Documentation

Property Kubernetes property Type
name name String
value value String

HostAlias

Kubernetes Documentation

Property Kubernetes property Type
host_names hostnames Array of String
ip ip String

PodReadinessGate

Kubernetes Documentation

Property Kubernetes property Type
condition_type conditionType String

PodSecurityContext

Kubernetes Documentation

Property Kubernetes property Type
fs_group fsGroup Integer
run_as_group runAsGroup Integer
run_as_non_root runAsNonRoot Boolean
run_as_user runAsUser Integer
se_linux_options seLinuxOptions SELinuxOptions
supplemental_groups supplementalGroups Array of Integer
sysctls sysctls Array of Sysctl

sysctls

Passing set of key-value pairs to the sysctls helper (or sysctl alias) method will convert them into the instances of Sysctl and add them to the sysctls array:

R.deployment :backend do
  pod_spec.security_context do
    sysctl 'fs.file-max': '64000'
  end
end

SELinuxOptions

Kubernetes Documentation

Property Kubernetes property Type
level level String
role role String
type type String
user user String

Sysctl

Kubernetes Documentation

Property Kubernetes property Type
name name String
value value String

Toleration

Kubernetes Documentation

Property Kubernetes property Type
effect effect String
key key String
operator operator String
toleration_seconds tolerationSeconds Integer
value value String