diff --git a/docker/caso/Dockerfile.j2 b/docker/caso/Dockerfile.j2 new file mode 100644 index 0000000000..355467c624 --- /dev/null +++ b/docker/caso/Dockerfile.j2 @@ -0,0 +1,43 @@ +FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }} +LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}" + +{% block caso_header %}{% endblock %} + +{% import "macros.j2" as macros with context %} + +{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + {% set caso_packages = [ + 'cronie', + ] %} +{% elif base_distro in ['debian', 'ubuntu'] %} + {% set caso_packages = [ + 'cron', + ] %} +{% endif %} + +{{ macros.install_packages(caso_packages | customizable("packages")) }} + +{{ macros.configure_user(name='caso') }} + +{% set caso_pip_packages = [ + 'caso' +] %} + +# NOTE(wszumski:) Upgrade pip, otherwise we hit: ModuleNotFoundError: No module +# named 'setuptools_rust' when install latest cryptography module. Doesn't +# really make sense to use constraints as caso is not tied to an openstack +# release. +RUN mkdir -p /requirements \ + && curl -sSL -o /requirements/upper-constraints.txt https://releases.openstack.org/constraints/upper/{{ openstack_release }} +RUN {{ macros.install_pip(["pip"]) }} + +RUN {{ macros.install_pip(caso_pip_packages | customizable("pip_packages"), constraints = false) }} \ + && mkdir -p /etc/caso \ + && chown -R caso: /etc/caso + +COPY extend_start.sh /usr/local/bin/kolla_extend_start + +RUN touch /usr/local/bin/kolla_caso_extend_start \ + && chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_caso_extend_start + +{% block caso_base_footer %}{% endblock %} diff --git a/docker/caso/extend_start.sh b/docker/caso/extend_start.sh new file mode 100644 index 0000000000..f1f5d7c1ae --- /dev/null +++ b/docker/caso/extend_start.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Create log directory, with appropriate permissions +CASO_LOG_DIR="/var/log/kolla/caso" +if [[ ! -d "$CASO_LOG_DIR" ]]; then + mkdir -p $CASO_LOG_DIR +fi +if [[ $(stat -c %U:%G ${CASO_LOG_DIR}) != "caso:kolla" ]]; then + chown caso:kolla ${CASO_LOG_DIR} +fi +if [[ $(stat -c %a ${CASO_LOG_DIR}) != "755" ]]; then + chmod 755 ${CASO_LOG_DIR} +fi + +. /usr/local/bin/kolla_caso_extend_start diff --git a/docker/prometheus/prometheus-jiralert/Dockerfile.j2 b/docker/prometheus/prometheus-jiralert/Dockerfile.j2 new file mode 100644 index 0000000000..b9c922914f --- /dev/null +++ b/docker/prometheus/prometheus-jiralert/Dockerfile.j2 @@ -0,0 +1,37 @@ +FROM {{ namespace }}/{{ image_prefix }}prometheus-base:{{ tag }} +LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}" + +{% import "macros.j2" as macros with context %} + +{% block prometheus_jiralert_header %}{% endblock %} + +{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + {% set prometheus_jiralert_packages = [ + 'go', + ] %} +{% elif base_distro in ['debian', 'ubuntu'] %} + {% set prometheus_jiralert_packages = [ + 'golang-go', + ] %} +{% endif %} + +{{ macros.install_packages(prometheus_jiralert_packages | customizable("packages")) }} + +{% block prometheus_jiralert_version %} +ARG prometheus_jiralert_version=1.0 +ARG prometheus_jiralert_url=https://github.com/free/jiralert/releases/download/${prometheus_jiralert_version}/jiralert-${prometheus_jiralert_version}.linux-{{debian_arch}}.tar.gz +{% endblock %} + +{% block prometheus_jiralert_install %} +ENV GOPATH=/tmp +RUN curl -sSL -o /tmp/jiralert.tar.gz ${prometheus_jiralert_url} \ + && mkdir /opt/jiralert \ + && tar --strip 1 -xvf /tmp/jiralert.tar.gz -C /opt/jiralert \ + && rm -f /tmp/jiralert.tar.gz \ + && mkdir -p /etc/jiralert +{% endblock %} + +{% block prometheus_jiralert_footer %}{% endblock %} +{% block footer %}{% endblock %} + +USER prometheus diff --git a/docker/prometheus/prometheus-libvirt-exporter/Dockerfile.j2 b/docker/prometheus/prometheus-libvirt-exporter/Dockerfile.j2 new file mode 100644 index 0000000000..ce287db0bb --- /dev/null +++ b/docker/prometheus/prometheus-libvirt-exporter/Dockerfile.j2 @@ -0,0 +1,45 @@ +FROM {{ namespace }}/{{ image_prefix }}prometheus-base:{{ tag }} +LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}" + +{% import "macros.j2" as macros with context %} + +{% block prometheus_libvirt_exporter_header %}{% endblock %} + +{% if base_distro in ['centos', 'oraclelinux', 'rhel'] %} + {% set prometheus_libvirt_exporter_packages = [ + 'go', + 'libvirt-devel', + ] %} +{% elif base_distro in ['debian', 'ubuntu'] %} + {% set prometheus_libvirt_exporter_packages = [ + 'golang-go', + 'libvirt-dev', + ] %} +{% endif %} + +{{ macros.install_packages(prometheus_libvirt_exporter_packages | customizable("packages")) }} + +{% block prometheus_libvirt_exporter_version %} +ARG prometheus_libvirt_exporter_version=v0.2.0 +ARG prometheus_libvirt_exporter_url=https://github.com/kumina/libvirt_exporter/archive/refs/tags/${prometheus_libvirt_exporter_version}.tar.gz +{% endblock %} + +{% block prometheus_libvirt_exporter_install %} +ENV GOPATH=/tmp +RUN curl -sSL -o /tmp/libvirt_exporter.tar.gz ${prometheus_libvirt_exporter_url} \ + && mkdir /tmp/libvirt_exporter \ + && tar --strip 1 -xvf /tmp/libvirt_exporter.tar.gz -C /tmp/libvirt_exporter \ + && cd /tmp/libvirt_exporter \ + && go get -d ./... \ + && go build \ + && install -m 0755 libvirt_exporter /opt/ \ + && rm -rf /tmp/libvirt_exporter* +{% endblock %} + +{% block prometheus_libvirt_exporter_footer %}{% endblock %} +{% block footer %}{% endblock %} + +# TODO: Root level access is currently required to read libvirt metrics. In +# the future we should investigate read only access as a non-root user. See +# https://libvirt.org/auth.html#ACL_server_polkit. +USER root diff --git a/kolla/common/config.py b/kolla/common/config.py index 55aec94126..76f2fe8938 100755 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -1133,7 +1133,11 @@ 'masakari-user': { 'uid': 42485, 'gid': 42485, - } + }, + 'caso-user': { + 'uid': 52400, + 'gid': 52400, + }, } diff --git a/kolla/template/repos.yaml b/kolla/template/repos.yaml index 58724461a4..8cf21f02ef 100644 --- a/kolla/template/repos.yaml +++ b/kolla/template/repos.yaml @@ -49,7 +49,6 @@ rhel: # NOTE(mnasiadka): Erlang repo - Debian Buster/Bullseye needs to use bionic as per RabbitMQ docs debian: - elasticsearch: "deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" erlang: "deb http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main" grafana: "deb https://packages.grafana.com/oss/deb stable main" diff --git a/releasenotes/notes/add-prometheus-libvirt-exporter-8d505dc8b74f8625.yaml b/releasenotes/notes/add-prometheus-libvirt-exporter-8d505dc8b74f8625.yaml new file mode 100644 index 0000000000..2f85a5b94d --- /dev/null +++ b/releasenotes/notes/add-prometheus-libvirt-exporter-8d505dc8b74f8625.yaml @@ -0,0 +1,4 @@ +--- +features: + - Added a container image for Prometheus libvirt exporter, to be used + for monitoring deployments which provide VMs with libvirt.