-
Notifications
You must be signed in to change notification settings - Fork 1
Container
R.deployment :backend do
container do
image 'tutum/hello-world'
end
endSets up main container of deployment with tutum/hello-world image.
| 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 |
| TODO: lifecycle | lifecycle | Lifecycle |
| liveness_probe | livenessProbe | Probe |
| name | name | String |
| ports | ports | Array of ContainerPort |
| readiness_probe | readinessProbe | Probe |
| TODO: resources | resources | ResourceRequirements |
| TODO: security_context | securityContext | SecurityContext |
| stdin | stdin | Boolean |
| stdin_once | stdinOnce | Boolean |
| termination_message_path | terminationMessagePath | String |
| termination_message_policy | terminationMessagePolicy | String |
| tty | tty | Boolean |
| TODO: volume_devices | volumeDevices | Array of VolumeDevice |
| volume_mounts | volumeMounts | Array of VolumeMounts |
| working_dir | workingDir | String |
Passing list of values adds them to the args array:
R.deployment :backend do
container do
args '-v', '1', '-l', 42
end
endPassing list of values adds them to the command array:
R.deployment :backend do
container do
command '/bin/sh', '-c', 'ls -al'
end
endA complex helper to manipulate container's environment-oriented properties: env and env_from.
Key-value pairs passed to add are converted into name and value properties of EnvVar objects and added to env array:
R.deployment :backend do
container do
environment do
add DB_NAME: 'backend', DB_USER: 'postgres'
end
end
endAdds a specified key from the specified ConfigMap as an environment variable with the specified name to the env array:
R.scope :backend do
R.config_map do
set DB_NAME: 'database'
end
R.deployment do
container do
environment do
# Adds a value of the key 'DATABASE' from the ConfigMap 'db' as an environment
# variable 'DB_NAME' without failing if it is doesn't exists
add_config_map_key :DB_NAME, :db, key: :DATABASE, optional: true
# Adds a value of the key 'DB_NAME' from the ConfigMap 'backend' as an environment
# variable 'DB_NAME' failing if it is doesn't exists
add_config_map_key :DB_NAME, :backend, key: :DB_NAME
# The same as above, but the ConfigMap's key name is defaulted to the environment
# variable name (which is 'DB_NAME')
add_config_map_key :DB_NAME, :backend
# The same as above, but the ConfigMap's key name is defaulted to the environment
# variable name (which is 'DB_NAME') and the name of the ConfigMap itself is defaulted
# to the name of the current scope (which is 'backend')
add_config_map_key :DB_NAME
end
end
end
endAdds a specified key from the specified Secret as an environment variable with the specified name to the env array:
R.scope :backend do
R.secret do
set DB_PASSWORD: 'supersecret'
end
R.deployment do
container do
environment do
# Adds a value of the key 'PASSWORD' from the Secret 'db' as an environment
# variable 'DB_PASSWORD' without failing if it is doesn't exists
add_secret_key :DB_PASSWORD, :db, key: :PASSWORD, optional: true
# Adds a value of the key 'DB_PASSWORD' from the Secret 'backend' as an environment
# variable 'DB_PASSWORD' failing if it is doesn't exists
add_secret_key :DB_PASSWORD, :backend, key: :DB_PASSWORD
# The same as above, but the ConfigMap's key name is defaulted to the environment
# variable name (which is 'DB_PASSWORD')
add_secret_key :DB_PASSWORD, :backend
# The same as above, but the ConfigMap's key name is defaulted to the environment
# variable name (which is 'DB_PASSWORD') and the name of the ConfigMap itself is defaulted
# to the name of the current scope (which is 'backend')
add_secret_key :DB_PASSWORD
end
end
end
endAdds an environment variable with the reference to the property of the current object to the env array:
R.deployment :backend do
container do
environment do
add_field :KUBERNETES_POD_NAME, 'metadata.name'
end
end
endThere is an optional last argument, api_version which can be used to alter the version of the schema the
field path is written in terms of.
Adds an environment variable with the reference to the current (or specified) container's resource field to the env array:
R.deployment :backend do
container do
environment do
# Reference resource field from the same container
add_resource_field :KUBERNETES_MEMORY_LIMITS, 'limits.memory'
end
end
container :sidecar do
environment do
# Reference resource field from the main container with the divisor 1m
add_resource_field :KUBERNETES_CPU_REQUESTS, 'requests.cpu',
container_name: :main, divisor: '1m'
end
end
endAdds a reference to the specified ConfigMap to the env_from array:
R.scope :backend do
R.config_map do
set DEBUG: 'true'
end
R.deployment do
container do
environment do
# Reference 'backend' ConfigMap
use_config_map :backend
# Reference ConfigMap with the same name as the current scope
use_config_map
# Reference 'diagnostics' ConfigMap, prefix all keys with 'DIAGNOSTICS_' and
# do not fail, if that ConfigMap is doesn't exists
use_config_map :diagnostics, optional: true, prefix: 'DIAGNOSTICS_'
end
end
end
endAdds a reference to the specified Secret to the env_from array:
R.scope :backend do
R.secret do
set ROOT_PASSWORD: 'supersecret'
end
R.deployment do
container do
environment do
# Reference 'backend' Secret
use_secret :backend
# Reference Secret with the same name as the current scope
use_secret
# Reference 's3' Secret, prefix all keys with 'S3_' and
# do not fail, if that Secret is doesn't exists
use_secret :s3, optional: true, prefix: 'S3_'
end
end
end
end