migrated to 2 containers

This commit is contained in:
2020-07-05 15:19:09 +02:00
parent 0edc02eb37
commit a7e6d9ce90
4 changed files with 11 additions and 9 deletions

View File

@@ -12,4 +12,4 @@ RUN set -ex; \
echo '[client]\nhost=localhost\nuser=prometheus\npassword=prom01\n' >/etc/prometheus-mysql-exporter
EXPOSE 9104
CMD ["prometheus-mysql-exporter", "--config.my-cnf", "/etc/prometheus-mysql-exporter"]
CMD ["prometheus-mysqld-exporter", "--config.my-cnf", "/etc/prometheus-mysql-exporter"]

View File

@@ -51,7 +51,6 @@ RUN set -ex; \
pwgen \
tzdata \
xz-utils \
prometheus-mysqld-exporter \
; \
rm -rf /var/lib/apt/lists/*
@@ -94,11 +93,12 @@ RUN set -ex; \
| xargs -rt -0 sed -Ei 's/^(bind-address|log)/#&/'; \
# don't reverse lookup hostnames, they are usually another container
echo '[mysqld]\nskip-host-cache\nskip-name-resolve' > /etc/mysql/conf.d/docker.cnf; \
echo '[client]\nhost=localhost\nuser=prometheus\npassword=prom01\n' >/etc/prometheus-mysql-exporter
apt-get clean -y;
VOLUME /var/lib/mysql
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 9104 3306
EXPOSE 3306
CMD ["mysqld"]

View File

@@ -252,10 +252,6 @@ docker_setup_db() {
docker_process_sql --database=mysql <<<"CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;"
fi
docker_process_sql --database=mysql <<<"CREATE USER 'prometheus'@'127.0.0.1' IDENTIFIED BY 'prom01' ;"
docker_process_sql --database=mysql <<<"GRANT ALL ON *.* TO 'prometheus'@'127.0.0.1' ;"
docker_process_sql --database=mysql <<<"FLUSH PRIVILEGES ;"
if [ -n "$MYSQL_USER" ] && [ -n "$MYSQL_PASSWORD" ]; then
mysql_note "Creating user ${MYSQL_USER}"
docker_process_sql --database=mysql <<<"CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;"
@@ -341,7 +337,6 @@ _main() {
echo
fi
fi
/usr/bin/prometheus-mysqld-exporter --config.my-cnf /etc/prometheus-mysql-exporter&
exec "$@"
}

View File

@@ -31,6 +31,7 @@ spec:
containers:
- image: docker-registry.lan/mariadb:arm64
name: mariadb
imagePullPolicy: Always
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
@@ -41,6 +42,12 @@ spec:
volumeMounts:
- name: mariadb-persistent-storage
mountPath: /var/lib/mysql
- image: docker-registry.lan/mariadb-prometheus-exporter:arm64
name: mariadb-prometheus-exporter
imagePullPolicy: Always
ports:
- containerPort: 9104
name: metrics
volumes:
- name: mariadb-persistent-storage
persistentVolumeClaim: