debian/ubuntu: introduce 'debian_arch' variable

Many images have 'if x86_64 then amd64 elif aarch64 then arm64' check to
comply with Debian like architecture names in several projects.

This patch creates 'debian_arch' variable which can be used in all
Docker files (similar to 'base_arch' one).

All required images got converted to use it.

Change-Id: I9c5e6f13d6c9b24fe323408512bd5aef290111ad
This commit is contained in:
Marcin Juszkiewicz 2019-01-09 16:42:17 +01:00
parent dc20a3a0b6
commit ab679adcbf
17 changed files with 29 additions and 75 deletions

View File

@ -21,15 +21,7 @@ ENV JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk/
'elasticsearch',
] %}
{% if base_arch == 'x86_64' %}
ENV java_arch=amd64
{% elif base_arch == 'aarch64' %}
ENV java_arch=arm64
{% else %}
ENV java_arch={{ base_arch }}
{% endif %}
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-${java_arch}/
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-{{debian_arch}}/
{% endif %}

View File

@ -46,20 +46,12 @@ RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
RUN {{ macros.install_pip(helm_repository_pip_packages | customizable("pip_packages"), constraints = false) }}
{% if base_arch == 'x86_64' %}
ENV helm_arch=amd64
{% elif base_arch == 'aarch64' %}
ENV helm_arch=arm64
{% else %}
ENV helm_arch={{ base_arch }}
{% endif %}
{% block helm_repository_install_kubernetes_helm %}
# TODO(mandre) check for file integrity instead of downloading from an HTTPS source
RUN curl -Lo /tmp/helm-v${helm_version}-linux-${helm_arch}.tar.gz https://storage.googleapis.com/kubernetes-helm/helm-v${helm_version}-linux-${helm_arch}.tar.gz \
&& sudo tar --strip-components 1 -C /usr/bin linux-${helm_arch}/helm -zxvf /tmp/helm-v${helm_version}-linux-${helm_arch}.tar.gz \
RUN curl -Lo /tmp/helm-v${helm_version}-linux-{{debian_arch}}.tar.gz https://storage.googleapis.com/kubernetes-helm/helm-v${helm_version}-linux-{{debian_arch}}.tar.gz \
&& sudo tar --strip-components 1 -C /usr/bin linux-{{debian_arch}}/helm -zxvf /tmp/helm-v${helm_version}-linux-{{debian_arch}}.tar.gz \
&& sudo chmod 755 /usr/bin/helm \
&& rm /tmp/helm-v${helm_version}-linux-${helm_arch}.tar.gz
&& rm /tmp/helm-v${helm_version}-linux-{{debian_arch}}.tar.gz
{% endblock %}
RUN useradd --user-group --create-home --home-dir /home/helm helm \

View File

@ -3,16 +3,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
ENV KUBERNETES_VERSION=v1.11.1
{% if base_arch == 'x86_64' %}
ENV KUBE_ARCH=amd64
{% elif base_arch == 'aarch64' %}
ENV KUBE_ARCH=arm64
{% else %}
RUN echo 'Kubernetes images not yet available for {{ base_arch }}' \
&& /bin/false
{% endif %}
ENV KUBERNETES_DOWNLOAD_ROOT=https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/${KUBE_ARCH}
ENV KUBERNETES_DOWNLOAD_ROOT=https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/{{debian_arch}}
{% block kube_base_header %}{% endblock %}

View File

@ -20,15 +20,7 @@ ENV JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk/
'logrotate'
] %}
{% if base_arch == 'x86_64' %}
ARG java_arch=amd64
{% elif base_arch == 'aarch64' %}
ARG java_arch=arm64
{% else %}
ARG java_arch={{ base_arch }}
{% endif %}
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-${java_arch}/
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-{{debian_arch}}/
{% endif %}

View File

@ -75,21 +75,11 @@ RUN apt-get update \
{% endmacro %}
{% macro install_kubectl() %}
{% if base_arch == 'x86_64' %}
ENV KUBE_ARCH=amd64
{% elif base_arch == 'aarch64' %}
ENV KUBE_ARCH=arm64
{% else %}
RUN echo 'There is no "kubectl" binary for {{ base_arch }}' \
&& /bin/false
{% endif %}
# TODO(mandre) check for file integrity instead of downloading from an HTTPS source
RUN curl -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.5.4/bin/linux/${KUBE_ARCH}/kubectl \
RUN curl -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.5.4/bin/linux/{{debian_arch}}/kubectl \
&& chmod 755 /usr/bin/kubectl
{% endmacro %}
{% macro install_fluent_plugins(plugins) -%}
{% if plugins is defined and plugins|length > 0 -%}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] -%}

View File

@ -29,15 +29,7 @@ ENV JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk/
'maven',
] %}
{% if base_arch == 'x86_64' %}
ARG java_arch=amd64
{% elif base_arch == 'aarch64' %}
ARG java_arch=arm64
{% else %}
ARG java_arch={{ base_arch }}
{% endif %}
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-${java_arch}/
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-{{debian_arch}}/
{% endif %}

View File

@ -8,7 +8,7 @@ ENV prometheus_alertmanager_version=0.14.0
{% endblock %}
{% block prometheus_alertmanager_install %}
RUN curl -sSL -o /tmp/prometheus_alertmanager.tar.gz https://github.com/prometheus/alertmanager/releases/download/v${prometheus_alertmanager_version}/alertmanager-${prometheus_alertmanager_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -sSL -o /tmp/prometheus_alertmanager.tar.gz https://github.com/prometheus/alertmanager/releases/download/v${prometheus_alertmanager_version}/alertmanager-${prometheus_alertmanager_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/prometheus_alertmanager.tar.gz -C /opt/ \
&& rm -f /tmp/prometheus_alertmanager.tar.gz \
&& ln -s /opt/alertmanager* /opt/prometheus_alertmanager

View File

@ -7,14 +7,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{{ macros.configure_user(name='prometheus') }}
{% if base_arch == 'x86_64' %}
ENV prometheus_arch=amd64
{% elif base_arch == 'aarch64' %}
ENV prometheus_arch=arm64
{% else %}
ENV prometheus_arch={{ base_arch }}
{% endif %}
COPY extend_start.sh /usr/local/bin/kolla_extend_start
RUN chmod 755 /usr/local/bin/kolla_extend_start

View File

@ -8,7 +8,7 @@ ENV blackbox_exporter_version=0.12.0
{% endblock %}
{% block prometheus_blackbox_exporter_install %}
RUN curl -sSL -o /tmp/blackbox_exporter.tar.gz https://github.com/prometheus/blackbox_exporter/releases/download/v${blackbox_exporter_version}/blackbox_exporter-${blackbox_exporter_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -sSL -o /tmp/blackbox_exporter.tar.gz https://github.com/prometheus/blackbox_exporter/releases/download/v${blackbox_exporter_version}/blackbox_exporter-${blackbox_exporter_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/blackbox_exporter.tar.gz -C /opt/ \
&& rm -f /tmp/blackbox_exporter.tar.gz \
&& ln -s /opt/blackbox_exporter* /opt/blackbox_exporter

View File

@ -8,7 +8,7 @@ ENV haproxy_exporter_version=0.7.1
{% endblock %}
{% block haproxy_exporter_install %}
RUN curl -sSL -o /tmp/haproxy_exporter.tar.gz https://github.com/prometheus/haproxy_exporter/releases/download/v${haproxy_exporter_version}/haproxy_exporter-${haproxy_exporter_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -sSL -o /tmp/haproxy_exporter.tar.gz https://github.com/prometheus/haproxy_exporter/releases/download/v${haproxy_exporter_version}/haproxy_exporter-${haproxy_exporter_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/haproxy_exporter.tar.gz -C /opt/ \
&& rm -f /tmp/haproxy_exporter.tar.gz \
&& ln -s /opt/haproxy_exporter* /opt/haproxy_exporter

View File

@ -8,7 +8,7 @@ ENV memcached_exporter_version=0.4.1
{% endblock %}
{% block prometheus_memcached_exporter_install %}
RUN curl -sSL -o /tmp/memcached_exporter.tar.gz https://github.com/prometheus/memcached_exporter/releases/download/v${memcached_exporter_version}/memcached_exporter-${memcached_exporter_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -sSL -o /tmp/memcached_exporter.tar.gz https://github.com/prometheus/memcached_exporter/releases/download/v${memcached_exporter_version}/memcached_exporter-${memcached_exporter_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/memcached_exporter.tar.gz -C /opt/ \
&& rm -f /tmp/memcached_exporter.tar.gz \
&& ln -s /opt/memcached_exporter* /opt/memcached_exporter

View File

@ -8,7 +8,7 @@ ENV mysqld_exporter_version=0.10.0
{% endblock %}
{% block mysqld_exporter_install %}
RUN curl -ssL -o /tmp/mysqld_exporter.tar.gz https://github.com/prometheus/mysqld_exporter/releases/download/v${mysqld_exporter_version}/mysqld_exporter-${mysqld_exporter_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -ssL -o /tmp/mysqld_exporter.tar.gz https://github.com/prometheus/mysqld_exporter/releases/download/v${mysqld_exporter_version}/mysqld_exporter-${mysqld_exporter_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/mysqld_exporter.tar.gz -C /opt/ \
&& rm -f /tmp/mysqld_exporter.tar.gz \
&& ln -s /opt/mysqld_exporter* /opt/mysqld_exporter

View File

@ -8,7 +8,7 @@ ENV node_exporter_version=0.14.0
{% endblock %}
{% block node_exporter_install %}
RUN curl -sSL -o /tmp/node_exporter.tar.gz https://github.com/prometheus/node_exporter/releases/download/v${node_exporter_version}/node_exporter-${node_exporter_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -sSL -o /tmp/node_exporter.tar.gz https://github.com/prometheus/node_exporter/releases/download/v${node_exporter_version}/node_exporter-${node_exporter_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/node_exporter.tar.gz -C /opt/ \
&& rm -f /tmp/node_exporter.tar.gz \
&& ln -s /opt/node_exporter* /opt/node_exporter

View File

@ -8,7 +8,7 @@ ENV prometheus_openstack_exporter_version=0.0.5
{% endblock %}
{% block prometheus_openstack_exporter_install %}
RUN curl -sSL -o /tmp/prometheus_openstack_exporter.tar.gz https://github.com/Linaro/openstack-exporter/releases/download/v${prometheus_openstack_exporter_version}/openstack-exporter-${prometheus_openstack_exporter_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -sSL -o /tmp/prometheus_openstack_exporter.tar.gz https://github.com/Linaro/openstack-exporter/releases/download/v${prometheus_openstack_exporter_version}/openstack-exporter-${prometheus_openstack_exporter_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/prometheus_openstack_exporter.tar.gz -C /opt/ \
&& rm -f /tmp/prometheus_openstack_exporter.tar.gz \
&& ln -s /opt/openstack-exporter* /opt/openstack-exporter

View File

@ -8,7 +8,7 @@ ENV prometheus_version=1.7.1
{% endblock %}
{% block prometheus_server_install %}
RUN curl -sSL -o /tmp/prometheus.tar.gz https://github.com/prometheus/prometheus/releases/download/v${prometheus_version}/prometheus-${prometheus_version}.linux-${prometheus_arch}.tar.gz \
RUN curl -sSL -o /tmp/prometheus.tar.gz https://github.com/prometheus/prometheus/releases/download/v${prometheus_version}/prometheus-${prometheus_version}.linux-{{debian_arch}}.tar.gz \
&& tar xvf /tmp/prometheus.tar.gz -C /opt/ \
&& rm -f /tmp/prometheus.tar.gz \
&& ln -s /opt/prometheus* /opt/prometheus \

View File

@ -679,6 +679,11 @@ class KollaWorker(object):
self.install_type = conf.install_type
self.tag = conf.tag
self.base_arch = conf.base_arch
self.debian_arch = self.base_arch
if self.base_arch == 'aarch64':
self.debian_arch = 'arm64'
elif self.base_arch == 'x86_64':
self.debian_arch = 'amd64'
self.images = list()
rpm_setup_config = ([repo_file for repo_file in
conf.rpm_setup_config if repo_file is not None])
@ -900,6 +905,7 @@ class KollaWorker(object):
'base_distro_tag': self.base_tag,
'base_arch': self.base_arch,
'base_package_type': self.base_package_type,
'debian_arch': self.debian_arch,
'supported_distro_release': supported_distro_release,
'install_metatype': self.install_metatype,
'image_prefix': self.image_prefix,

View File

@ -0,0 +1,7 @@
---
features:
- |
Add `debian_arch` variable which can be used in Dockerfile.j2 files instead
of checking architecture names. For 'x86-64' it goes for 'amd64' and uses
'arm64' on 'aarch64' architecture. This is handy for fetching external
release files.