From 0cf61dfb7412f05fd98f597f3f451e3f1dcd8c08 Mon Sep 17 00:00:00 2001 From: Sergey Filatov Date: Tue, 31 Jul 2018 11:51:07 +0300 Subject: [PATCH] Add prometheus & grafana container image tags To upgrade cluster we need to be able to set image tags so this change adds to labels for corresponding containers Task: 23314 Story: 2003171 Change-Id: I4cd0270a69fb889c59bdb28966821adb11fd0292 --- doc/source/user/index.rst | 2 +- .../fragments/enable-prometheus-monitoring.sh | 4 ++-- .../fragments/write-heat-params-master.yaml | 2 ++ magnum/drivers/heat/k8s_fedora_template_def.py | 4 +++- .../k8s_fedora_atomic_v1/templates/kubecluster.yaml | 12 ++++++++++++ .../k8s_fedora_atomic_v1/templates/kubemaster.yaml | 10 ++++++++++ .../tests/unit/drivers/test_template_definition.py | 12 ++++++++++++ ...rafana_prometheus_tag_label-78540ea106677485.yaml | 5 +++++ 8 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/grafana_prometheus_tag_label-78540ea106677485.yaml diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst index 5ae5b45e44..dcbd246f91 100644 --- a/doc/source/user/index.rst +++ b/doc/source/user/index.rst @@ -1075,7 +1075,7 @@ _`container_infra_prefix` Images that must be mirrored: * docker.io/coredns/coredns:1.0.1 - * docker.io/grafana/grafana:latest + * docker.io/grafana/grafana:5.1.5 * docker.io/openstackmagnum/kubernetes-apiserver * docker.io/openstackmagnum/kubernetes-controller-manager * docker.io/openstackmagnum/kubernetes-kubelet diff --git a/magnum/drivers/common/templates/kubernetes/fragments/enable-prometheus-monitoring.sh b/magnum/drivers/common/templates/kubernetes/fragments/enable-prometheus-monitoring.sh index 84283bb63e..3eb770ef37 100644 --- a/magnum/drivers/common/templates/kubernetes/fragments/enable-prometheus-monitoring.sh +++ b/magnum/drivers/common/templates/kubernetes/fragments/enable-prometheus-monitoring.sh @@ -220,7 +220,7 @@ spec: serviceAccountName: prometheus containers: - name: prometheus - image: ${CONTAINER_INFRA_PREFIX:-docker.io/prom/}prometheus:v1.8.2 + image: ${CONTAINER_INFRA_PREFIX:-docker.io/prom/}prometheus:${PROMETHEUS_TAG} args: - '-storage.local.retention=6h' - '-storage.local.memory-chunks=500000' @@ -314,7 +314,7 @@ spec: role: db spec: containers: - - image: ${CONTAINER_INFRA_PREFIX:-docker.io/grafana/}grafana:4.6.3 + - image: ${CONTAINER_INFRA_PREFIX:-docker.io/grafana/}grafana:${GRAFANA_TAG} imagePullPolicy: Always name: grafana env: 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 cd99025b2e..23a22ed550 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 @@ -76,3 +76,5 @@ write_files: OCTAVIA_ENABLED="$OCTAVIA_ENABLED" KUBE_SERVICE_ACCOUNT_KEY="$KUBE_SERVICE_ACCOUNT_KEY" KUBE_SERVICE_ACCOUNT_PRIVATE_KEY="$KUBE_SERVICE_ACCOUNT_PRIVATE_KEY" + PROMETHEUS_TAG="$PROMETHEUS_TAG" + GRAFANA_TAG="$GRAFANA_TAG" diff --git a/magnum/drivers/heat/k8s_fedora_template_def.py b/magnum/drivers/heat/k8s_fedora_template_def.py index 51145c01bc..f1aa235313 100644 --- a/magnum/drivers/heat/k8s_fedora_template_def.py +++ b/magnum/drivers/heat/k8s_fedora_template_def.py @@ -109,7 +109,9 @@ class K8sFedoraTemplateDefinition(k8s_template_def.K8sTemplateDefinition): 'calico_tag', 'calico_cni_tag', 'calico_kube_controllers_tag', 'calico_ipv4pool', 'etcd_tag', 'flannel_tag', - 'cloud_provider_enabled'] + 'cloud_provider_enabled', + 'prometheus_tag', + 'grafana_tag'] for label in label_list: label_value = cluster.labels.get(label) diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml index bacc15a09b..0f7ff3da0b 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubecluster.yaml @@ -494,6 +494,16 @@ parameters: description: Enable or disable the openstack kubernetes cloud provider default: true + prometheus_tag: + type: string + description: tag of the prometheus container + default: v1.8.2 + + grafana_tag: + type: string + description: tag of grafana container + default: 5.1.5 + resources: ###################################################################### @@ -718,6 +728,8 @@ resources: octavia_enabled: {get_param: octavia_enabled} kube_service_account_key: {get_param: kube_service_account_key} kube_service_account_private_key: {get_param: kube_service_account_private_key} + prometheus_tag: {get_param: prometheus_tag} + grafana_tag: {get_param: grafana_tag} ###################################################################### diff --git a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml index 7ed4b17ae5..dfe6eddb78 100644 --- a/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml +++ b/magnum/drivers/k8s_fedora_atomic_v1/templates/kubemaster.yaml @@ -391,6 +391,14 @@ parameters: type: boolean description: Enable or disable the openstack kubernetes cloud provider + prometheus_tag: + type: string + description: tag of prometheus container + + grafana_tag: + type: string + description: tag of grafana container + resources: master_wait_handle: @@ -501,6 +509,8 @@ resources: "$OCTAVIA_ENABLED": {get_param: octavia_enabled} "$KUBE_SERVICE_ACCOUNT_KEY": {get_param: kube_service_account_key} "$KUBE_SERVICE_ACCOUNT_PRIVATE_KEY": {get_param: kube_service_account_private_key} + "$PROMETHEUS_TAG": {get_param: prometheus_tag} + "$GRAFANA_TAG": {get_param: grafana_tag} install_openstack_ca: type: OS::Heat::SoftwareConfig diff --git a/magnum/tests/unit/drivers/test_template_definition.py b/magnum/tests/unit/drivers/test_template_definition.py index 1024a134f4..edbf9dc85e 100644 --- a/magnum/tests/unit/drivers/test_template_definition.py +++ b/magnum/tests/unit/drivers/test_template_definition.py @@ -373,6 +373,10 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase): 'cloud_provider_enabled') service_cluster_ip_range = mock_cluster.labels.get( 'service_cluster_ip_range') + prometheus_tag = mock_cluster.labels.get( + 'prometheus_tag') + grafana_tag = mock_cluster.labels.get( + 'grafana_tag') k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition() @@ -423,6 +427,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase): 'kube_service_account_key': 'public_key', 'kube_service_account_private_key': 'private_key', 'portal_network_cidr': service_cluster_ip_range, + 'prometheus_tag': prometheus_tag, + 'grafana_tag': grafana_tag, }} mock_get_params.assert_called_once_with(mock_context, mock_cluster_template, @@ -546,6 +552,10 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase): 'cloud_provider_enabled') service_cluster_ip_range = mock_cluster.labels.get( 'service_cluster_ip_range') + prometheus_tag = mock_cluster.labels.get( + 'prometheus_tag') + grafana_tag = mock_cluster.labels.get( + 'grafana_tag') k8s_def = k8sa_tdef.AtomicK8sTemplateDefinition() @@ -598,6 +608,8 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase): 'kube_service_account_key': 'public_key', 'kube_service_account_private_key': 'private_key', 'portal_network_cidr': service_cluster_ip_range, + 'prometheus_tag': prometheus_tag, + 'grafana_tag': grafana_tag, }} mock_get_params.assert_called_once_with(mock_context, mock_cluster_template, diff --git a/releasenotes/notes/grafana_prometheus_tag_label-78540ea106677485.yaml b/releasenotes/notes/grafana_prometheus_tag_label-78540ea106677485.yaml new file mode 100644 index 0000000000..4f5dd94b1f --- /dev/null +++ b/releasenotes/notes/grafana_prometheus_tag_label-78540ea106677485.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add 'grafana_tag' and 'prometheus_tag' labels for the k8s_fedora_atomic driver. + Grafana defaults to 5.1.5 and Prometheus defaults to v1.8.2.