Ensure all containers have imagePullPolicy

This PS adds the imagePullPolicy to all containers
and provides a test to ensure it is always there.

Implements: blueprint image-pull-policy

Change-Id: I9a94e3a1ab909dcea0960b490aa57a5432780961
This commit is contained in:
Kevin Fox 2017-01-30 19:35:46 -08:00
parent e8b988469e
commit d350e0a156
36 changed files with 69 additions and 1 deletions

View File

@ -84,6 +84,7 @@ spec:
{{- if $localVals.haproxy }}
- name: haproxy
image: {{ include "haproxy_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
command:
- /bin/bash
- -c
@ -127,6 +128,7 @@ spec:
{{- end }}
- name: main
image: "{{ .imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
{{- if $localVals.haproxy }}
lifecycle:
preStop:

View File

@ -1,4 +1,5 @@
{{- define "common_create_db_job" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -22,6 +23,7 @@ spec:
restartPolicy: OnFailure
containers:
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: "creating-{{ .serviceName }}-database"
command: ["sh", "-c"]
args:
@ -44,6 +46,7 @@ spec:
name: database-password
key: password
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: "creating-{{ .serviceName }}-user-and-permissions"
command: ["sh", "-c"]
args:

View File

@ -1,4 +1,5 @@
{{- define "common_create_keystone_endpoint" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $region := include "kolla_val_get_str" (dict "key" "region" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -29,6 +30,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command: ["sh", "-xec"]
args:

View File

@ -1,4 +1,5 @@
{{- define "common_create_keystone_service" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $region := include "kolla_val_get_str" (dict "key" "region" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -29,6 +30,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command: ["sh", "-xec"]
args:

View File

@ -1,4 +1,5 @@
{{- define "common_create_keystone_user" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $region := include "kolla_val_get_str" (dict "key" "region" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -28,6 +29,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command: ["sh", "-xec"]
args:

View File

@ -1,4 +1,5 @@
{{- define "common_delete_db_job" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -22,6 +23,7 @@ spec:
restartPolicy: OnFailure
containers:
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: "deleting-{{ .serviceName }}-database"
command: ["sh", "-c"]
args:
@ -45,6 +47,7 @@ spec:
name: database-password
key: password
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: "deleting-{{ .serviceName }}-user"
command: ["sh", "-c"]
args:

View File

@ -1,4 +1,5 @@
{{- define "common_delete_keystone_service" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $region := include "kolla_val_get_str" (dict "key" "region" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -29,6 +30,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command: ["sh", "-xec"]
args:

View File

@ -1,4 +1,5 @@
{{- define "common_delete_keystone_user" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $region := include "kolla_val_get_str" (dict "key" "region" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -28,6 +29,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: {{ include "kolla_toolbox_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command: ["sh", "-xec"]
args:

View File

@ -25,9 +25,11 @@
{{- $_ := set $c1 "retKey" "kube_logger" }}
{{- $_ := include "kolla_val_get_raw" $c1 }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" .searchPath "Values" .Values ) }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- if $localVals.kube_logger }}
- name: logging
image: {{ include "fluentd_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
volumeMounts:
- mountPath: {{ $containerConfigDirectory }}
name: logging-config

View File

@ -1,4 +1,5 @@
{{- define "common_manage_db_job" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" .searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" .searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" .searchPath "Values" .Values ) }}
@ -17,6 +18,7 @@ spec:
restartPolicy: OnFailure
containers:
- image: {{ .imageFull | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: "main"
volumeMounts:
{{ include "common_volume_mounts" . | indent 12 }}

View File

@ -43,6 +43,7 @@ spec:
containers:
- name: main
image: "{{ .imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
volumeMounts:
{{- include "common_volume_mounts" . | indent 12 }}
- mountPath: {{ $containerConfigDirectory }}

View File

@ -5,6 +5,7 @@
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" $searchPath "Values" .Values ) }}
{{- $netHostTrue := true }}
@ -22,6 +23,7 @@ spec:
restartPolicy: Never
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command:
- /bin/bash

View File

@ -5,6 +5,7 @@
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" $searchPath "Values" .Values ) }}
{{- $netHostTrue := true }}
@ -30,6 +31,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -72,6 +72,7 @@ spec:
containers:
- name: main
image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
- mountPath: /var/lib/kolla-kubernetes/event

View File

@ -88,6 +88,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
env:
{{- include "common_env_vars" $env | indent 12 }}

View File

@ -94,6 +94,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -115,6 +115,7 @@ spec:
{{- if $localVals.haproxy }}
- name: haproxy
image: {{ include "haproxy_image_full" . | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
command:
- /bin/bash
- -c
@ -153,6 +154,7 @@ spec:
{{- end }}
- name: main
image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
{{- if $localVals.haproxy }}
lifecycle:
preStop:

View File

@ -33,6 +33,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: {{ $imageFull | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
env:
{{- include "common_bootstrap_env_vars" $env | indent 12 }}

View File

@ -1,5 +1,4 @@
{{- $searchPath := ":global.kolla.helm-repo.deployment:global.kolla.helm-repo.all:global.kolla.all" }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" $searchPath "Values" .Values ) }}
{{- $replicas := include "kolla_val_get_str" (dict "key" "replicas" "searchPath" $searchPath "Values" .Values ) }}
@ -100,6 +99,7 @@ spec:
containers:
- name: main
image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}
{{- if $persistent }}

View File

@ -37,6 +37,7 @@ spec:
containers:
- name: main
image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
volumeMounts:
{{- include "common_volume_mounts" $env | indent 10 }}
- mountPath: {{ $containerConfigDirectory }}

View File

@ -56,6 +56,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -16,6 +16,7 @@
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" $searchPath "Values" .Values ) }}
{{- $resourceName := "keystone" }}
{{- $netHostTrue := false }}
{{- $podTypeBootstrap := true }}
@ -41,6 +42,7 @@ spec:
restartPolicy: OnFailure
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
command: ["sh", "-c", "mkdir -p /var/log/kolla/keystone; sudo -E kolla_set_configs;
kolla_keystone_bootstrap admin

View File

@ -7,6 +7,7 @@
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" $searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" $searchPath "Values" .Values ) }}
@ -22,6 +23,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}

View File

@ -7,6 +7,7 @@
{{- $_ := set $c "imageName" "image_full" }}
{{- $_ := set $c "tagName" "image_tag" }}
{{- $imageFull := include "kolla_build_image_full" $c }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" $searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorKey := include "kolla_val_get_str" (dict "key" "selector_key" "searchPath" $searchPath "Values" .Values ) }}
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" $searchPath "Values" .Values ) }}
@ -33,6 +34,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
lifecycle:
preStop:

View File

@ -19,6 +19,7 @@
{{- $selectorValue := include "kolla_val_get_str" (dict "key" "selector_value" "searchPath" $searchPath "Values" .Values ) }}
{{- $port := include "kolla_val_get_str" (dict "key" "port" "searchPath" $searchPath "Values" .Values ) }}
{{- $containerConfigDirectory := include "kolla_val_get_str" (dict "key" "container_config_directory" "searchPath" $searchPath "Values" .Values ) }}
{{- $imagePullPolicy := include "kolla_val_get_str" (dict "key" "image_pull_policy" "searchPath" $searchPath "Values" .Values ) }}
{{- if $localVals.enabled }}
apiVersion: extensions/v1beta1
kind: Deployment
@ -39,6 +40,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $memcachedImageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}

View File

@ -109,6 +109,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: {{ $imageFull | quote }}
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -118,6 +118,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -133,6 +133,7 @@ spec:
{{- end }}
containers:
- name: main
imagePullPolicy: {{ $imagePullPolicy | quote }}
image: "{{ $imageFull }}"
securityContext:
privileged: true

View File

@ -97,6 +97,7 @@ spec:
containers:
- name: main
image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
command:
- /bin/bash
- -c

View File

@ -59,6 +59,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -99,6 +99,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -27,6 +27,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}

View File

@ -55,6 +55,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
volumeMounts:
{{- include "common_volume_mounts" $env | indent 12 }}

View File

@ -62,6 +62,7 @@ spec:
{{ $selectorKey }}: {{ $selectorValue | quote }}
containers:
- image: "{{ $imageFull }}"
imagePullPolicy: {{ $imagePullPolicy | quote }}
name: main
securityContext:
privileged: true

View File

@ -24,6 +24,11 @@ def _isdir(path, entry):
class TestK8sTemplatesTest(base.BaseTestCase):
def _validate_image_pull_policy(self, package, pod):
for container in pod['spec']['containers']:
if 'imagePullPolicy' not in container:
raise Exception("imagePullPolicy not in %s" % package)
def test_validate_templates(self):
srcdir = os.environ['HELMDIR']
helmbin = os.environ['HELMBIN']
@ -59,3 +64,10 @@ class TestK8sTemplatesTest(base.BaseTestCase):
if e.args[0] not in m:
raise
json.loads(js)
pod = None
try:
pod = y['spec']['template']
except Exception:
pass
if pod:
self._validate_image_pull_policy(package, pod)

View File

@ -0,0 +1,4 @@
---
features:
- |
Image pull policy can now be set for all containerns.