Skip to content

Container

Gregory Nickonov edited this page Mar 13, 2019 · 19 revisions

Quick Start

R.deployment :backend do
  container do
    image 'tutum/hello-world'
  end
end

Sets up main container of deployment with tutum/hello-world image.

Container

Kubernetes Documentation

Property Kubernetes property Type
args args Array of String
command command Array of String
env env Array of EnvVar
env_from envFrom Array of EnvFromSource
image image String
image_pull_policy imagePullPolicy String
lifecycle lifecycle Lifecycle
liveness_probe livenessProbe Probe
name name String
ports ports Array of ContainerPort
readiness_probe readinessProbe Probe
resources resources ResourceRequirements
security_context securityContext SecurityContext
stdin stdin Boolean
stdin_once stdinOnce Boolean
termination_message_path terminationMessagePath String
termination_message_policy terminationMessagePolicy String
tty tty Boolean
volume_devices volumeDevices Array of VolumeDevice
volume_mounts volumeMounts Array of VolumeMount
working_dir workingDir String

args

Passing list of values adds them to the args array:

R.deployment :backend do
  container do
    args '-v', '1', '-l', 42
  end
end

command

Passing list of values adds them to the command array:

R.deployment :backend do
  container do
    command '/bin/sh', '-c', 'ls -al'
  end
end

environment

A complex helper to manipulate container's environment-oriented properties env and env_from. Available methods are described in Container Environment Helper.

expose_port

Adds a port information to the ports array:

R.deployment :backend do
  container do
    expose_port 80, host_ip: '0.0.0.0', host_port: 8080, name: :http, protocol: :TCP
  end
end

expose_default_http_port

A shortcut for exposing container's port 80 with the name 'http:

R.deployment :backend do
  container do
    expose_default_http_port
  end
end

image

With arguments passed sets image and optionally sets image pull policy for the container:

R.deployment :backend do
  container do
    # Specify image 
    image 'myregistry.com/backend:latest'

    # Specify image and image pull policy
    image 'myregistry.com/backend:latest', :IfNotExists
  end
end

mount_device

Adds a VolumeDevice with the specified parameters to the volume_devices array:

R.deployment :backend do
  container do
    mount_device :data, '/data'
  end
end

mount_volume

Adds a VolumeMount with the specified parameters to the volume_mounts array:

R.deployment :backend do
  container do
    # Mount volume 'appsettings' at path '/etc/config'
    mount_device :data, '/data'

    # Mount volume 'appsettings' at path '/etc/config' marking it as readonly
    mount_volume :appsettings, '/etc/config', readonly: true

    # Mount volume 'appsettings' at path '/etc/config' marking it as readonly
    mount_volume :appsettings, '/etc/config', readonly: true

    # Mount volume 'appsettings' at path '/etc/config' marking it as readonly,
    # specifying mount propagation mode and root inside the volume
    mount_volume :appsettings, '/etc/config', readonly: true,
                 mount_propagation: :MountPropagationNone, sub_path: '/data'
  end
end

ContainerPort

Kubernetes Documentation

Property Kubernetes property Type
container_port containerPort Integer
host_ip hostIP String
host_port hostPort Integer
name name String
protocol protocol String

Lifecycle

Kubernetes Documentation

Property Kubernetes property Type
post_start postStart Handler
pre_stop preStop Handler

Handler

Kubernetes Documentation

Property Kubernetes property Type
exec exec ExecAction
http_get httpGet HTTPGetAction
tcp_socket tcpSocket TCPSocketAction

Handler also provides all helpers defined by an ActionsOwner.

VolumeDevice

Kubernetes Documentation

Property Kubernetes property Type
device_path devicePath String
name name String

VolumeMount

Kubernetes Documentation

Property Kubernetes property Type
mount_path mountPath String
mount_propagation mountPropagation String
name name String
readonly readOnly Boolean
sub_path subPath String

SecurityContext

Kubernetes Documentation

Property Kubernetes property Type
allow_privilege_escalation allowPrivilegeEscalation Boolean
capabilities capabilities Capabilities
privileged privileged Boolean
proc_mount procMount String
readonly_root_filesystem readOnlyRootFilesystem Boolean
run_as_group runAsGroup Integer
run_as_non_root runAsNonRoot Boolean
run_as_user runAsUser Integer
se_linux_options seLinuxOptions SELinuxOptions

Capabilities

Kubernetes Documentation

Property Kubernetes property Type
add add Array of String
drop drop Array of String

add

When list of values is passed add adds them to the add array:

container do
  security_context.capabilities.add 'A', 'B', 'C'
end

drop

When list of values is passed drop adds them to the drop array:

container do
  security_context.capabilities.drop 'A', 'B', 'C'
end

Clone this wiki locally