-
Notifications
You must be signed in to change notification settings - Fork 1
General syntax
General information about Ruby and its syntax can be found at https://www.ruby-lang.org/en/documentation/. Although it is not necessary it's highly recommended to have a basic knowledge of Ruby.
To conform with the Ruby naming policies most identifiers that come from Kubernetes, such as resource kinds and resource properties, are translated into the underscore notation. The following table shows the correspondence between Sunstone and Kubernetes identifiers:
Kubernetes identifier | Sunstone identifier |
---|---|
ConfigMap | config_map |
DaemonSet | daemon_set |
hostIPC | host_ipc |
automountServiceAccountName | automount_service_account_name |
Every modifiable property (not marked as Readonly) accepts two forms of changing value - assignment and command. Assigning value is easy and straightforward:
R.deployment(:frontend).replicas = 2
Command version is not much harder by more aesthetic:
R.deployment :frontend do
replicas 2
end
In addition to the getter (object.property
) and setter (object.property = <value>
) methods Boolean properties define two more: question mark and exclamation sign methods.
Question mark method (object.property?
) returns true
if property value is other than nil
or false
. Exclamation sign method (object.property!
) sets property value to true
.
Array properties are read-only - you can not assign new array to those properties - but you can modify content of that arrays using helper methods or push
or <<
methods. For example, to specify container command you can either use command
helper of <<
method:
R.deployment :frontend do
init_container 'check-backend' do
image 'busybox'
image_pull_policy :IfNotPresent
command 'sh', '-c', 'ping -c 1 backend'
end
end
R.deployment :frontend do
init_container 'check-backend' do
image 'busybox', :IfNotPresent
command << 'sh'
command << '-c'
command << 'ping -c 1 backend'
end
end
The latter one is a little bit ugly, but still can be used in some situations.