If you're using Kerbi, you probably enjoy Ruby in YAML, a.k.a ERB. This guide covers the most useful methods available to you inside your .yaml.erb files.
Most of the methods here come from , which is documented .
Public and Custom Mixer API methods
In addition to the methods listed in the next sections, you have access to:
Every public method from the (e.g values, file(), etc...), except #push()
Any custom methods you define in your Mixer subclass, including those included from modules
See both in action below with file() and ingress_enabled?():
<% if ingress_enabled? %>
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations: <%= embed(file("ingress-annotations")) %>
spec:
#...
<% end %>
The embed() and embed_array() methods convert, respectively, a Hash and an Array<Hash>, into an appropriately indented String that can be embedded into a YAML file.
apiVersion: networking.k8s.io/v1
kind: Pod
metadata:
name: minimal-ingress
annotations: <%= embed({foo: "bar"}) %>
spec:
restartPolicy: Never
containers: <%= embed_array(dir("containers")) %>
Both methods assume that what you're trying to embed should appear as far "right" as possible. If this is not what you need, you can pass the optional indent: Integer option. If the indent is wrong, e.g it is too small, YAML parsing will raise an exception and templating will fail.
Embedding items into a List
If you have a YAML-defined list and need to add individual items, the best known way to do this (although this is not ideal), is to call embed_array() with an explicit indent: Integer that you find by counting, or more realistically by trial and error.