add init-container support
Change-Id: If60105ea8b1403e9bf6e660054ada391b17f091e
diff --git a/README.rst b/README.rst
index 4992bdf..b215c92 100644
--- a/README.rst
+++ b/README.rst
@@ -472,6 +472,35 @@
config:
enabled: true
+initContainers
+--------------
+
+Example pillar:
+
+.. code-block:: bash
+
+ kubernetes:
+ control:
+ service:
+ memcached:
+ init_containers:
+ - name: test-mysql
+ image: busybox
+ command:
+ - sleep
+ - 3600
+ volumes:
+ - name: config
+ mount: /test
+ - name: test-memcached
+ image: busybox
+ command:
+ - sleep
+ - 3600
+ volumes:
+ - name: config
+ mount: /test
+
Volumes
-------
diff --git a/kubernetes/files/rc.yml b/kubernetes/files/rc.yml
index be89492..58105b0 100644
--- a/kubernetes/files/rc.yml
+++ b/kubernetes/files/rc.yml
@@ -12,10 +12,31 @@
metadata:
labels:
app: {{ service.service }}-{{ service.role }}
- {%- if service.hostname is defined %}
annotations:
+ {%- if service.hostname is defined %}
pod.beta.kubernetes.io/hostname: {{ service.hostname }}
{%- endif %}
+ {%- if service.init_containers is defined %}
+ pod.alpha.kubernetes.io/init-containers: '[
+ {%- for container in service.init_containers %}
+ {
+ "name": "{{ container.name }}",
+ "image": "{% if container.registry is defined %}{{ container.registry }}/{%- endif %}{{ container.image }}{%- if container.tag is defined %}:{{ container.tag }}{%- endif %}",
+ "command": [{%- for command in container.command %}"{{ command }}"{% if not loop.last %},{% endif %}{%- endfor %}],
+ {%- if container.volumes is defined %}
+ {%- for volume in container.volumes %}
+ "volumeMounts": [
+ {
+ "name": "{{ volume.name }}",
+ "mountPath": "{{ volume.mount }}"
+ }
+ ]
+ {%- if not loop.last %},{% endif %}{%- endfor %}
+ {%- endif %}
+ }
+ {%- if not loop.last %},{% endif %}{% endfor %}
+ ]'
+ {%- endif %}
spec:
{%- if service.hostNetwork is defined %}
hostNetwork: True