From 46255dd4b16eccd34b9f53fc5e3dc32eaa62ce55 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Tue, 8 Aug 2017 11:43:59 +0200 Subject: [PATCH] Add a kube_tag label to control the k8s containers to pull Separate the tag from which to pull from the kubernetes version. With the current state the tag and the version happen to be the the same. But, it is not decided yet in the fedoraproject how the images are going to be tag. Finally, operators might want to try their own container images with custom tags. Depends-On: Icddb8ed1598f2ba1f782622f86fb6083953c3b3f Implements: blueprint run-kube-as-container Change-Id: I4c4bc055d7df5e65aede93464bff51e6d5971504 --- .../fragments/configure-kubernetes-master.sh | 10 +++++----- .../fragments/configure-kubernetes-minion.sh | 4 ++-- .../kubernetes/fragments/write-heat-params-master.yaml | 1 + .../kubernetes/fragments/write-heat-params.yaml | 1 + magnum/drivers/heat/k8s_fedora_template_def.py | 4 ++++ .../k8s_fedora_atomic_v1/templates/kubecluster.yaml | 7 +++++++ .../k8s_fedora_atomic_v1/templates/kubemaster.yaml | 5 +++++ .../k8s_fedora_atomic_v1/templates/kubeminion.yaml | 5 +++++ .../k8s_fedora_ironic_v1/templates/kubecluster.yaml | 7 +++++++ .../k8s_fedora_ironic_v1/templates/kubemaster.yaml | 5 +++++ .../templates/kubeminion_software_configs.yaml | 5 +++++ magnum/tests/unit/drivers/test_template_definition.py | 8 ++++++-- 12 files changed, 53 insertions(+), 9 deletions(-) diff --git a/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-master.sh b/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-master.sh index 775fd889cd..d793e02d98 100644 --- a/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-master.sh +++ b/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-master.sh @@ -4,11 +4,11 @@ echo "configuring kubernetes (master)" -atomic install --storage ostree --system --system-package=no --name=kubelet docker.io/openstackmagnum/kubernetes-kubelet:${KUBE_VERSION} -atomic install --storage ostree --system --system-package=no --name=kube-proxy docker.io/openstackmagnum/kubernetes-proxy:${KUBE_VERSION} -atomic install --storage ostree --system --system-package=no --name=kube-apiserver docker.io/openstackmagnum/kubernetes-apiserver:${KUBE_VERSION} -atomic install --storage ostree --system --system-package=no --name=kube-controller-manager docker.io/openstackmagnum/kubernetes-controller-manager:${KUBE_VERSION} -atomic install --storage ostree --system --system-package=no --name=kube-scheduler docker.io/openstackmagnum/kubernetes-scheduler:${KUBE_VERSION} +atomic install --storage ostree --system --system-package=no --name=kubelet docker.io/openstackmagnum/kubernetes-kubelet:${KUBE_TAG} +atomic install --storage ostree --system --system-package=no --name=kube-proxy docker.io/openstackmagnum/kubernetes-proxy:${KUBE_TAG} +atomic install --storage ostree --system --system-package=no --name=kube-apiserver docker.io/openstackmagnum/kubernetes-apiserver:${KUBE_TAG} +atomic install --storage ostree --system --system-package=no --name=kube-controller-manager docker.io/openstackmagnum/kubernetes-controller-manager:${KUBE_TAG} +atomic install --storage ostree --system --system-package=no --name=kube-scheduler docker.io/openstackmagnum/kubernetes-scheduler:${KUBE_TAG} sed -i ' /^KUBE_ALLOW_PRIV=/ s/=.*/="--allow-privileged='"$KUBE_ALLOW_PRIV"'"/ diff --git a/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-minion.sh b/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-minion.sh index 0fc9794d49..861cdec2d5 100644 --- a/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-minion.sh +++ b/magnum/drivers/common/templates/kubernetes/fragments/configure-kubernetes-minion.sh @@ -4,8 +4,8 @@ echo "configuring kubernetes (minion)" -atomic install --storage ostree --system --system-package=no --name=kubelet docker.io/openstackmagnum/kubernetes-kubelet:${KUBE_VERSION} -atomic install --storage ostree --system --system-package=no --name=kube-proxy docker.io/openstackmagnum/kubernetes-proxy:${KUBE_VERSION} +atomic install --storage ostree --system --system-package=no --name=kubelet docker.io/openstackmagnum/kubernetes-kubelet:${KUBE_TAG} +atomic install --storage ostree --system --system-package=no --name=kube-proxy docker.io/openstackmagnum/kubernetes-proxy:${KUBE_TAG} CERT_DIR=/etc/kubernetes/certs PROTOCOL=https diff --git a/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params-master.yaml b/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params-master.yaml index c6a0049e06..4cdab1c71d 100644 --- a/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params-master.yaml +++ b/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params-master.yaml @@ -38,6 +38,7 @@ write_files: HTTPS_PROXY="$HTTPS_PROXY" NO_PROXY="$NO_PROXY" WAIT_CURL="$WAIT_CURL" + KUBE_TAG="$KUBE_TAG" KUBE_VERSION="$KUBE_VERSION" KUBE_DASHBOARD_VERSION="$KUBE_DASHBOARD_VERSION" TRUSTEE_USER_ID="$TRUSTEE_USER_ID" diff --git a/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params.yaml b/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params.yaml index 21f1b42645..33fbd3a0b7 100644 --- a/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params.yaml +++ b/magnum/drivers/common/templates/kubernetes/fragments/write-heat-params.yaml @@ -36,6 +36,7 @@ write_files: HTTPS_PROXY="$HTTPS_PROXY" NO_PROXY="$NO_PROXY" WAIT_CURL="$WAIT_CURL" + KUBE_TAG="$KUBE_TAG" KUBE_VERSION="$KUBE_VERSION" TRUSTEE_USER_ID="$TRUSTEE_USER_ID" TRUSTEE_PASSWORD="$TRUSTEE_PASSWORD" diff --git a/magnum/drivers/heat/k8s_fedora_template_def.py b/magnum/drivers/heat/k8s_fedora_template_def.py index f580bc9449..cfe81d567e 100644 --- a/magnum/drivers/heat/k8s_fedora_template_def.py +++ b/magnum/drivers/heat/k8s_fedora_template_def.py @@ -79,6 +79,10 @@ class K8sFedoraTemplateDefinition(k8s_template_def.K8sTemplateDefinition): 'docker_volume_type', CONF.cinder.default_docker_volume_type) extra_params['docker_volume_type'] = docker_volume_type + kube_tag = cluster_template.labels.get('kube_tag') + if kube_tag: + extra_params['kube_tag'] = kube_tag + return super(K8sFedoraTemplateDefinition, self).get_params(context, cluster_template, cluster, extra_params=extra_params, diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml index 7805d3e255..9ecd5ec53f 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml @@ -313,6 +313,11 @@ parameters: type: string description: url for keystone + kube_tag: + type: string + description: tag of the k8s containers used to provision the kubernetes cluster + default: v1.7.4 + kube_version: type: string description: version of kubernetes used for kubernetes cluster @@ -504,6 +509,7 @@ resources: http_proxy: {get_param: http_proxy} https_proxy: {get_param: https_proxy} no_proxy: {get_param: no_proxy} + kube_tag: {get_param: kube_tag} kube_version: {get_param: kube_version} kube_dashboard_version: {get_param: kube_dashboard_version} trustee_user_id: {get_param: trustee_user_id} @@ -567,6 +573,7 @@ resources: http_proxy: {get_param: http_proxy} https_proxy: {get_param: https_proxy} no_proxy: {get_param: no_proxy} + kube_tag: {get_param: kube_tag} kube_version: {get_param: kube_version} trustee_user_id: {get_param: trustee_user_id} trustee_username: {get_param: trustee_username} diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml index 3de313949d..8271b52359 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml @@ -206,6 +206,10 @@ parameters: type: string description: no proxies for docker + kube_tag: + type: string + description: tag of the k8s containers used to provision the kubernetes cluster + kube_version: type: string description: version of kubernetes used for kubernetes cluster @@ -322,6 +326,7 @@ resources: "$HTTP_PROXY": {get_param: http_proxy} "$HTTPS_PROXY": {get_param: https_proxy} "$NO_PROXY": {get_param: no_proxy} + "$KUBE_TAG": {get_param: kube_tag} "$KUBE_VERSION": {get_param: kube_version} "$KUBE_DASHBOARD_VERSION": {get_param: kube_dashboard_version} "$WAIT_CURL": {get_attr: [master_wait_handle, curl_cli]} diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml index 06cfab6132..f16ef0e893 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubeminion.yaml @@ -169,6 +169,10 @@ parameters: type: string description: no proxies for docker + kube_tag: + type: string + description: tag of the k8s containers used to provision the kubernetes cluster + kube_version: type: string description: version of kubernetes used for kubernetes cluster @@ -269,6 +273,7 @@ resources: $HTTP_PROXY: {get_param: http_proxy} $HTTPS_PROXY: {get_param: https_proxy} $NO_PROXY: {get_param: no_proxy} + $KUBE_TAG: {get_param: kube_tag} $KUBE_VERSION: {get_param: kube_version} $WAIT_CURL: {get_attr: [minion_wait_handle, curl_cli]} $TRUSTEE_USER_ID: {get_param: trustee_user_id} diff --git a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubecluster.yaml b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubecluster.yaml index 1ccfd2193c..f8b274e225 100644 --- a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubecluster.yaml +++ b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubecluster.yaml @@ -316,6 +316,11 @@ parameters: type: string description: url for keystone + kube_tag: + type: string + description: tag of the k8s containers used to provision the kubernetes cluster + default: v1.7.4 + kube_version: type: string description: version of kubernetes used for kubernetes cluster @@ -477,6 +482,7 @@ resources: http_proxy: {get_param: http_proxy} https_proxy: {get_param: https_proxy} no_proxy: {get_param: no_proxy} + kube_tag: {get_param: kube_tag} kube_version: {get_param: kube_version} kube_dashboard_version: {get_param: kube_dashboard_version} trustee_user_id: {get_param: trustee_user_id} @@ -560,6 +566,7 @@ resources: http_proxy: {get_param: http_proxy} https_proxy: {get_param: https_proxy} no_proxy: {get_param: no_proxy} + kube_tag: {get_param: kube_tag} kube_version: {get_param: kube_version} trustee_user_id: {get_param: trustee_user_id} trustee_username: {get_param: trustee_username} diff --git a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubemaster.yaml b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubemaster.yaml index ef89b11c60..f976e1710c 100644 --- a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubemaster.yaml +++ b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubemaster.yaml @@ -190,6 +190,10 @@ parameters: type: string description: no proxies for docker + kube_tag: + type: string + description: tag of the k8s containers used to provision the kubernetes cluster + kube_version: type: string description: version of kubernetes used for kubernetes cluster @@ -286,6 +290,7 @@ resources: "$HTTP_PROXY": {get_param: http_proxy} "$HTTPS_PROXY": {get_param: https_proxy} "$NO_PROXY": {get_param: no_proxy} + "$KUBE_TAG": {get_param: kube_tag} "$KUBE_VERSION": {get_param: kube_version} "$KUBE_DASHBOARD_VERSION": {get_param: kube_dashboard_version} "$WAIT_CURL": {get_param: wc_curl_cli} diff --git a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion_software_configs.yaml b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion_software_configs.yaml index f1955a716c..42d26dfba4 100644 --- a/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion_software_configs.yaml +++ b/magnum/drivers/k8s_fedora_ironic_v1/templates/kubeminion_software_configs.yaml @@ -124,6 +124,10 @@ parameters: type: string description: no proxies for docker + kube_tag: + type: string + description: tag of the k8s containers used to provision the kubernetes cluster + kube_version: type: string description: version of kubernetes used for kubernetes cluster @@ -207,6 +211,7 @@ resources: $HTTP_PROXY: {get_param: http_proxy} $HTTPS_PROXY: {get_param: https_proxy} $NO_PROXY: {get_param: no_proxy} + $KUBE_TAG: {get_param: kube_tag} $KUBE_VERSION: {get_param: kube_version} $WAIT_CURL: {get_param: wc_curl_cli} $TRUSTEE_DOMAIN_ID: {get_param: trustee_domain_id} diff --git a/magnum/tests/unit/drivers/test_template_definition.py b/magnum/tests/unit/drivers/test_template_definition.py index 890474db3c..3aed2bdbb3 100644 --- a/magnum/tests/unit/drivers/test_template_definition.py +++ b/magnum/tests/unit/drivers/test_template_definition.py @@ -270,6 +270,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase): 'docker_volume_type') etcd_volume_size = mock_cluster_template.labels.get( 'etcd_volume_size') + kube_tag = mock_cluster_template.labels.get('kube_tag') k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition() @@ -293,7 +294,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase): 'username': 'fake_user', 'tenant_name': 'fake_tenant', 'magnum_url': mock_osc.magnum_url.return_value, - 'region_name': mock_osc.cinder_region_name.return_value}} + 'region_name': mock_osc.cinder_region_name.return_value, + 'kube_tag': kube_tag}} mock_get_params.assert_called_once_with(mock_context, mock_cluster_template, mock_cluster, @@ -350,6 +352,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase): 'docker_volume_type') etcd_volume_size = mock_cluster_template.labels.get( 'etcd_volume_size') + kube_tag = mock_cluster_template.labels.get('kube_tag') k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition() @@ -375,7 +378,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseTemplateDefinitionTestCase): 'magnum_url': mock_osc.magnum_url.return_value, 'region_name': mock_osc.cinder_region_name.return_value, 'loadbalancing_protocol': 'HTTP', - 'kubernetes_port': 8080}} + 'kubernetes_port': 8080, + 'kube_tag': kube_tag}} mock_get_params.assert_called_once_with(mock_context, mock_cluster_template, mock_cluster,