From 96ea01bee4821fe1f41f0121bc3ed0bbcf034284 Mon Sep 17 00:00:00 2001 From: Kostiantyn Nemchenko Date: Mon, 3 Dec 2018 16:46:25 +0200 Subject: [PATCH] Fix kubernetes demo files (#885) - Update postgres docker image to the latest 11 version. - Remove empty lines inside the `RUN` command to make the Dockerfile compatible with future docker versions. - Set the `PATRONI_KUBERNETES_POD_IP` environment variable, which is required when _use_endpoints_ is enabled. Otherwise, the `KeyError` is raised [here](https://github.com/zalando/patroni/blob/master/patroni/dcs/kubernetes.py#L95). - Set `EDITOR` environment variable to make configuration changes via `patronictl edit-config`. --- kubernetes/Dockerfile | 13 ++++--------- kubernetes/entrypoint.sh | 6 +++--- .../templates/template_patroni_ephemeral.yml | 2 +- .../templates/template_patroni_persistent.yaml | 2 +- kubernetes/patroni_k8s.yaml | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/kubernetes/Dockerfile b/kubernetes/Dockerfile index 04993773..9a973a83 100644 --- a/kubernetes/Dockerfile +++ b/kubernetes/Dockerfile @@ -1,4 +1,4 @@ -FROM postgres:10 +FROM postgres:11 MAINTAINER Alexander Kukushkin RUN export DEBIAN_FRONTEND=noninteractive \ @@ -7,23 +7,18 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get upgrade -y \ && apt-cache depends patroni | sed -n -e 's/.* Depends: \(python3-.\+\)$/\1/p' \ | grep -Ev '^python3-(sphinx|etcd|consul|kazoo|kubernetes)' \ - | xargs apt-get install -y curl jq locales git python3-pip python3-wheel \ - + | xargs apt-get install -y vim-tiny curl jq locales git python3-pip python3-wheel \ ## Make sure we have a en_US.UTF-8 locale available && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \ - && pip3 install setuptools \ && pip3 install 'git+https://github.com/zalando/patroni.git#egg=patroni[kubernetes]' \ - && PGHOME=/home/postgres \ && mkdir -p $PGHOME \ && chown postgres $PGHOME \ && sed -i "s|/var/lib/postgresql.*|$PGHOME:/bin/bash|" /etc/passwd \ - # Set permissions for OpenShift && chmod 775 $PGHOME \ && chmod 664 /etc/passwd \ - # Clean up && apt-get remove -y git python3-pip python3-wheel \ && apt-get autoremove -y \ @@ -33,7 +28,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \ ADD entrypoint.sh / EXPOSE 5432 8008 -ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 EDITOR=/usr/bin/editor USER postgres WORKDIR /home/postgres -CMD ["/bin/bash", "/entrypoint.sh"] \ No newline at end of file +CMD ["/bin/bash", "/entrypoint.sh"] diff --git a/kubernetes/entrypoint.sh b/kubernetes/entrypoint.sh index d023689d..1803301e 100755 --- a/kubernetes/entrypoint.sh +++ b/kubernetes/entrypoint.sh @@ -20,11 +20,11 @@ bootstrap: - data-checksums pg_hba: - host all all 0.0.0.0/0 md5 - - host replication ${PATRONI_REPLICATION_USERNAME} ${POD_IP}/16 md5 + - host replication ${PATRONI_REPLICATION_USERNAME} ${PATRONI_KUBERNETES_POD_IP}/16 md5 restapi: - connect_address: '${POD_IP}:8008' + connect_address: '${PATRONI_KUBERNETES_POD_IP}:8008' postgresql: - connect_address: '${POD_IP}:5432' + connect_address: '${PATRONI_KUBERNETES_POD_IP}:5432' authentication: superuser: password: '${PATRONI_SUPERUSER_PASSWORD}' diff --git a/kubernetes/openshift-example/templates/template_patroni_ephemeral.yml b/kubernetes/openshift-example/templates/template_patroni_ephemeral.yml index 1b68ec62..12a252d8 100644 --- a/kubernetes/openshift-example/templates/template_patroni_ephemeral.yml +++ b/kubernetes/openshift-example/templates/template_patroni_ephemeral.yml @@ -108,7 +108,7 @@ objects: spec: containers: - env: - - name: POD_IP + - name: PATRONI_KUBERNETES_POD_IP valueFrom: fieldRef: apiVersion: v1 diff --git a/kubernetes/openshift-example/templates/template_patroni_persistent.yaml b/kubernetes/openshift-example/templates/template_patroni_persistent.yaml index 46252aa5..bc0a5a33 100644 --- a/kubernetes/openshift-example/templates/template_patroni_persistent.yaml +++ b/kubernetes/openshift-example/templates/template_patroni_persistent.yaml @@ -108,7 +108,7 @@ objects: spec: containers: - env: - - name: POD_IP + - name: PATRONI_KUBERNETES_POD_IP valueFrom: fieldRef: apiVersion: v1 diff --git a/kubernetes/patroni_k8s.yaml b/kubernetes/patroni_k8s.yaml index fd0e4926..c1a8c7b0 100644 --- a/kubernetes/patroni_k8s.yaml +++ b/kubernetes/patroni_k8s.yaml @@ -28,7 +28,7 @@ spec: - mountPath: /home/postgres/pgdata name: pgdata env: - - name: POD_IP + - name: PATRONI_KUBERNETES_POD_IP valueFrom: fieldRef: fieldPath: status.podIP