From 72434789e7a32c9c0815464aa7697232b89e6009 Mon Sep 17 00:00:00 2001 From: muicoder Date: Thu, 31 Aug 2023 18:45:10 +0800 Subject: [PATCH] AIO for master Signed-off-by: muicoder --- .github/workflows/action.yml | 92 +++++++++++++++++++++++++++++++ .github/workflows/syncImages.yml | 68 +++++++++++++++++++++++ .github/workflows/syncSpilo.yaml | 40 ++++++++++++++ Makefile | 4 +- charts/postgres-operator.chart | 29 ++++++++++ docker/Dockerfile | 21 ++----- docker/pooler.Dockerfile | 21 +++++++ docker/syncImages.sh | 30 ++++++++++ docker/syncSpiloExt.sh | 27 +++++++++ hack/rename-codegen.sh | 59 ++++++++++++++++++++ hack/update-codegen.sh | 4 +- kubectl-pg/build.sh | 8 +-- kubectl-pg/cmd/root.go | 4 +- kubectl-pg/cmd/version.go | 2 +- kubectl-pg/go.mod | 2 + logical-backup/Dockerfile | 4 +- pkg/cluster/cluster.go | 15 +---- pkg/cluster/k8sres.go | 2 + pkg/cluster/resources.go | 14 ++++- pkg/cluster/sync.go | 3 + pkg/controller/operator_config.go | 3 + 21 files changed, 408 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/action.yml create mode 100644 .github/workflows/syncImages.yml create mode 100644 .github/workflows/syncSpilo.yaml create mode 100644 charts/postgres-operator.chart create mode 100644 docker/pooler.Dockerfile create mode 100755 docker/syncImages.sh create mode 100644 docker/syncSpiloExt.sh create mode 100755 hack/rename-codegen.sh diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml new file mode 100644 index 000000000..c422ab1c5 --- /dev/null +++ b/.github/workflows/action.yml @@ -0,0 +1,92 @@ +env: + OEM: ${{ inputs.oem }} +jobs: + logical-backup: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: logical-backup + file: logical-backup/Dockerfile + platforms: linux/amd64,linux/arm64 + provenance: false + pull: true + push: true + sbom: false + tags: ${{ secrets.DOCKERHUB_USERNAME }}/logical-backup:latest + pgbouncer: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + file: docker/pooler.Dockerfile + platforms: linux/amd64,linux/arm64 + provenance: false + pull: true + push: true + sbom: false + tags: ${{ secrets.DOCKERHUB_USERNAME }}/pgbouncer:latest + postgres-operator: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: "~1.22" + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + - name: Building + run: make deps && make codegen && hack/rename-codegen.sh && for ta in amd64 arm64; do go env -w GOARCH=$ta && make local && kubectl-pg/build.sh $PWD/build/kubectl-pg && mv build docker/$ta; done;tree docker + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: docker + platforms: linux/amd64,linux/arm64 + provenance: false + pull: true + push: true + sbom: false + tags: ${{ secrets.DOCKERHUB_USERNAME }}/postgres-operator:${{ env.OEM }} +name: buildImage +on: + workflow_dispatch: + inputs: + oem: + default: sensoro + description: OEM + required: true + type: string diff --git a/.github/workflows/syncImages.yml b/.github/workflows/syncImages.yml new file mode 100644 index 000000000..d25728f34 --- /dev/null +++ b/.github/workflows/syncImages.yml @@ -0,0 +1,68 @@ +jobs: + module: + needs: + - versions + runs-on: ubuntu-latest + steps: + - id: version + name: build + run: | + buildah version + date >"$(hostname)" + until sudo curl -sL "https://github.com/nicholasdille/buildah-static/releases/download/$(curl -fsSL "https://api.github.com/repos/nicholasdille/buildah-static/releases/latest" | yq .tag_name)/buildah-amd64.tar.gz" | tar -C ~ -xz "bin/buildah" --strip-components=1; do + sleep "$(($(grep -v ^$ -c "$(hostname)") * 2))s" + date >>"$(hostname)" + done + if ~/buildah inspect "ghcr.io/zalando/${{ matrix.module }}:${{ matrix.version }}" >/dev/null; then + echo "FROM ghcr.io/zalando/${{ matrix.module }}:${{ matrix.version }}" >Dockerfile + echo "platforms=linux/amd64,linux/arm64" >>$GITHUB_OUTPUT + else + echo "FROM registry.opensource.zalan.do/acid/${{ matrix.module }}:${{ matrix.version }} AS pgbouncer" >Dockerfile + echo "platforms=linux/amd64" >>$GITHUB_OUTPUT + fi + case ${{ matrix.module }} in + pgbouncer) + echo "RUN sed -i -E 's~(_tls_sslmode =).+~\1 prefer~g;s~(_tls_protocols =).+~\1 all~;s~(^stats_users_.+)~#\1~' /etc/pgbouncer/pgbouncer.ini.tmpl" >>Dockerfile + echo "FROM registry.opensource.zalan.do/acid/${{ matrix.module }}:${{ matrix.version }}" >>Dockerfile + echo "COPY --from=pgbouncer /etc/pgbouncer/pgbouncer.ini.tmpl /etc/pgbouncer/pgbouncer.ini.tmpl" >>Dockerfile + ;; + esac + ~/buildah version + cat Dockerfile + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + platforms: ${{ steps.version.outputs.platforms }} + provenance: false + pull: true + push: true + sbom: false + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.module }}:${{ matrix.version }} + strategy: + matrix: ${{ fromJson(needs.versions.outputs.matrix) }} + versions: + outputs: + matrix: ${{ steps.versions.outputs.matrix }} + runs-on: ubuntu-latest + steps: + - id: versions + name: versions + run: | + echo IyEvdXNyL2Jpbi9lbnYgc2gKCnNldCAtZQoKcmVhZG9ubHkgcmVnaXN0cnk9InJlZ2lzdHJ5Lm9wZW5zb3VyY2UuemFsYW4uZG8iCnJlYWRvbmx5IFJFR0lTVFJZPSIkezE6LSR7UkVHSVNUUlk6LWRvY2tlci5pb319IgpyZWFkb25seSByZXBvc2l0b3J5PSJhY2lkIgpyZWFkb25seSBSRVBPU0lUT1JZPSIkezI6LSR7UkVQT1NJVE9SWTotbGlicmFyeX19IgoKY2FjaGUoKSB7CiAgY2FzZSAkUkVHSVNUUlkgaW4KICBkb2NrZXIuaW8pCiAgICBjaGVja191cmw9Imh0dHBzOi8vaHViLmRvY2tlci5jb20vdjIvcmVwb3NpdG9yaWVzLyRSRVBPU0lUT1JZLyRhcnRpZmFjdC90YWdzLyRpbWFnZV90YWciCiAgICA7OwogIGVzYWMKICBpZiAhIGN1cmwgLXNTTCAiJGNoZWNrX3VybCIgfCB5cSAtQ2VQICcuaW1hZ2VzW10uYXJjaGl0ZWN0dXJlJyA+L2Rldi9udWxsIDI+JjE7IHRoZW4KICAgIGVjaG8gIiAgLSBtb2R1bGU6ICRhcnRpZmFjdCIKICAgIGVjaG8gIiAgICB2ZXJzaW9uOiAkaW1hZ2VfdGFnIgogIGZpCn0KCmVjaG8gaW5jbHVkZTogPnZlcnNpb25zCgp2ZXJzaW9uPSQoY3VybCAtZnNTTCAiaHR0cHM6Ly9hcGkuZ2l0aHViLmNvbS9yZXBvcy96YWxhbmRvL3Bvc3RncmVzLW9wZXJhdG9yL3JlbGVhc2VzL2xhdGVzdCIgfCB5cSAtZSAudGFnX25hbWUpCmZvciBhcnRpZmFjdCBpbiAkKGN1cmwg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FkIC1yIG1ham9yOyBkbwogICAgICBncmVwICJeJG1ham9yLSIgIiRhcnRpZmFjdCIgfCB0YWlsIC1uIDEgfCB3aGlsZSByZWFkIC1yIGltYWdlX3RhZzsgZG8KICAgICAgICBlY2hvICIkYXJ0aWZhY3Q6JGltYWdlX3RhZyIKICAgICAgICBjYWNoZSA+PnZlcnNpb25zCiAgICAgIGRvbmUKICAgIGRvbmUKICAgIDs7CiAgKikKICAgIGltYWdlX3RhZz0kKGN1cmwgLS1zaWxlbnQgLVggR0VUIC0taGVhZGVyICdBY2NlcHQ6IGFwcGxpY2F0aW9uL2pzb24nICJodHRwczovLyRyZWdpc3RyeS90ZWFtcy8kcmVwb3NpdG9yeS9hcnRpZmFjdHMvJGFydGlmYWN0L3RhZ3MiIHwganEgLXIgIi5bXS5uYW1lIiB8IGdyZXAgLXZFICIuKy1nLisiIHwKICAgICAgZ3JlcCAiJHZlcnNpb24iKQogICAgZWNobyAiJGFydGlmYWN0OiRpbWFnZV90YWciCiAgICBjYWNoZSA+PnZlcnNpb25zCiAgICA7OwogIGVzYWMKICBlY2hvCmRvbmUKCmlmICEgZ3JlcCB2ZXJzaW9uOiB2ZXJzaW9ucyA+L2Rldi9udWxsIDI+JjE7IHRoZW4KICBjYXQgPDxFT0YgPnZlcnNpb25zCmluY2x1ZGU6CiAgLSBtb2R1bGU6IHBvc3RncmVzLW9wZXJhdG9yCiAgICB2ZXJzaW9uOiAkdmVyc2lvbgpFT0YKZmkK | base64 -d | bash -s -- docker.io ${{ secrets.DOCKERHUB_USERNAME }} + yq -CP versions + echo "matrix=$(yq -oj versions | jq -rc)" >>$GITHUB_OUTPUT +name: syncImages +on: + schedule: + - cron: '30 */1 * * *' + workflow_dispatch: diff --git a/.github/workflows/syncSpilo.yaml b/.github/workflows/syncSpilo.yaml new file mode 100644 index 000000000..5b14a0da8 --- /dev/null +++ b/.github/workflows/syncSpilo.yaml @@ -0,0 +1,40 @@ +env: + IV: ${{ inputs.imageVersion }} +jobs: + spilo: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + - id: build + name: build + run: | + echo "FROM $IV" >Dockerfile + echo 'RUN curl -fsSL https://github.com/${{ secrets.DOCKERHUB_USERNAME }}/postgres-operator/raw/action/docker/syncSpiloExt.sh | sh' >>Dockerfile + echo "imageVersion=${IV##*/}" >>$GITHUB_OUTPUT + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + platforms: linux/amd64,linux/arm64 + provenance: false + pull: true + push: true + sbom: false + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.build.outputs.imageVersion }} +name: syncSpilo +on: + workflow_dispatch: + inputs: + imageVersion: + default: ghcr.io/zalando/spilo-16:3.3-p1 + description: https://github.com/orgs/zalando/packages?repo_name=spilo + required: true + type: string diff --git a/Makefile b/Makefile index 3b7ae4ede..c05550b4b 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ GITHEAD = $(shell git rev-parse --short HEAD) GITURL = $(shell git config --get remote.origin.url) GITSTATUS = $(shell git status --porcelain || echo "no changes") SOURCES = cmd/main.go -VERSION ?= $(shell git describe --tags --always --dirty) +VERSION ?= $(shell git describe --tags --always HEAD^) DIRS := cmd pkg PKG := `go list ./... | grep -v /vendor/` @@ -65,7 +65,7 @@ docker: ${DOCKERDIR}/${DOCKERFILE} echo "Tag ${TAG}" echo "Version ${VERSION}" echo "CDP tag ${CDP_TAG}" - echo "git describe $(shell git describe --tags --always --dirty)" + echo "git describe $(shell git describe --tags --always HEAD^)" docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)$(DEBUG_FRESH)$(DEBUG_POSTFIX)" -f "${DOCKERDIR}/${DOCKERFILE}" --build-arg VERSION="${VERSION}" . indocker-race: diff --git a/charts/postgres-operator.chart b/charts/postgres-operator.chart new file mode 100644 index 000000000..c72277aaf --- /dev/null +++ b/charts/postgres-operator.chart @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e + +readonly d_old=acid.zalan.do +readonly o_old=zalando.org +readonly oem=zalan +readonly OEM="${OEM:-$oem}" +echo "OEM: $OEM" +readonly d_new="acid.$OEM.do" +if [ "$OEM" = $oem ]; then + readonly o_new="${oem}do.org" +else + readonly o_new="${OEM}.sre" +fi +echo "$d_old=>$d_new" +echo "$o_old=>$o_new" +toFU() { + local str firstLetter otherLetter + str=$1 + firstLetter=$(echo "${str:0:1}" | awk '{print toupper($0)}') + otherLetter=${str:1} + echo "$firstLetter$otherLetter" +} +if [ "$OEM" != $oem ]; then + grep -rl $oem | grep .y\*ml$ | grep -v ui/ | while read -r f; do + sed "s~$d_old~$d_new~g;s~$o_old~$o_new~g;s~registry.opensource.zalan.do/acid~docker.io/muicoder~g;s~ghcr.io/zalando~ghcr.io/muicoder~g;s~Zalando~$(toFU "$OEM")~g;s~zalando~$OEM~g" <"$f" >"$f.bak" && mv "$f.bak" "$f" + done +fi diff --git a/docker/Dockerfile b/docker/Dockerfile index b0808c3bc..e44cf0b7a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,22 +1,9 @@ -ARG BASE_IMAGE=registry.opensource.zalan.do/library/alpine-3:latest -FROM golang:1.22-alpine AS builder -ARG VERSION=latest - -COPY . /go/src/github.com/zalando/postgres-operator -WORKDIR /go/src/github.com/zalando/postgres-operator - -RUN GO111MODULE=on go mod vendor \ - && CGO_ENABLED=0 go build -o build/postgres-operator -v -ldflags "-X=main.version=${VERSION}" cmd/main.go - -FROM ${BASE_IMAGE} -LABEL maintainer="Team ACID @ Zalando " -LABEL org.opencontainers.image.source="https://github.com/zalando/postgres-operator" - +FROM alpine:3.16 +ARG TARGETARCH # We need root certificates to deal with teams api over https -RUN apk -U upgrade --no-cache \ - && apk add --no-cache curl ca-certificates +RUN apk --no-cache add curl ca-certificates -COPY --from=builder /go/src/github.com/zalando/postgres-operator/build/* / +COPY $TARGETARCH/* / RUN addgroup -g 1000 pgo RUN adduser -D -u 1000 -G pgo -g 'Postgres Operator' pgo diff --git a/docker/pooler.Dockerfile b/docker/pooler.Dockerfile new file mode 100644 index 000000000..5aa25ffc7 --- /dev/null +++ b/docker/pooler.Dockerfile @@ -0,0 +1,21 @@ +FROM alpine:3.16 AS builder +# Inspiration from https://github.com/edoburu/docker-pgbouncer/blob/master/Dockerfile +RUN apk add --no-cache autoconf automake c-ares-dev curl gcc libc-dev libevent-dev libtool make openssl-dev pkgconf-dev && \ + curl -sL https://www.pgbouncer.org/downloads/files/1.23.0/pgbouncer-1.23.0.tar.gz | tar -xzv && \ + cd pgbouncer-* && \ + curl -sL https://github.com/pgbouncer/pgbouncer/archive/refs/heads/master.tar.gz | tar -xzv --strip-components=1 && \ + ./configure --prefix=/usr/local && make && make install && ls -lt +FROM registry.opensource.zalan.do/acid/pgbouncer:master-32 AS pgbouncer +RUN sed -i -E 's~(_tls_sslmode =).+~\1 prefer~g;s~(_tls_protocols =).+~\1 all~;s~(^stats_users_.+)~# \1~' /etc/pgbouncer/pgbouncer.ini.tmpl +FROM scratch AS cache +COPY --from=builder /usr/local/bin/pgbouncer /bin/pgbouncer +COPY --from=pgbouncer /entrypoint.sh /entrypoint.sh +COPY --from=pgbouncer /etc/pgbouncer/auth_file.txt.tmpl /etc/pgbouncer/auth_file.txt.tmpl +COPY --from=pgbouncer /etc/pgbouncer/pgbouncer.ini.tmpl /etc/pgbouncer/pgbouncer.ini.tmpl +FROM alpine:3.16 +COPY --from=cache / / +RUN apk --no-cache add libevent openssl c-ares gettext ca-certificates postgresql-client && \ + addgroup -S pgbouncer && adduser -S pgbouncer && mkdir -p /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer && \ + chown -R pgbouncer:pgbouncer /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer /etc/ssl/certs +USER pgbouncer:pgbouncer +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/syncImages.sh b/docker/syncImages.sh new file mode 100755 index 000000000..3be2ddaae --- /dev/null +++ b/docker/syncImages.sh @@ -0,0 +1,30 @@ +#! /bin/sh + +set -e + +if ! buildah version 2>/dev/null; then + date >"$(hostname)" + until sudo curl -fsSL "https://github.com/nicholasdille/buildah-static/releases/download/$(curl -fsSL "https://api.github.com/repos/nicholasdille/buildah-static/releases/latest" | grep tag_name | awk -F\" '{print $(NF-1)}')/buildah-$( + case $(uname -m) in + x86_64) + echo amd64 + ;; + aarch64) + echo arm64 + ;; + esac + ).tar.gz" | tar xz -C /usr/bin --no-same-owner --strip-components=1 "bin/buildah"; do + sleep "$(($(grep -v ^$ -c "$(hostname)") * 2))s" + date >>"$(hostname)" + done + rm "$(hostname)" +fi + +REGISTRY=docker.io +REPOSITORY=muicoder +{ + echo postgres-operator:action + echo logical-backup:action +} | while read -r repository; do + echo IyEvYmluL3NoCgpSRUdJU1RSWT0ke1JFR0lTVFJZOi1kb2NrZXIuaW99ClJFUE9TSVRPUlk9JHtSRVBPU0lUT1JZOi1tdWljb2Rlcn0KCkNNRD0kKGlmIHNlYWxvcyA+L2Rldi9udWxsOyB0aGVuIGVjaG8gc2VhbG9zOyBlbGlmIGJ1aWxkYWggPi9kZXYvbnVsbDsgdGhlbiBlY2hvIGJ1aWxkYWg7IGZpKQpNRj0ibWY6JChkYXRlICslRikiCgptYW5pZmVzdCgpIHsKICByZXBvc2l0b3J5PSQxCiAgdGFncz0kMgogIHRhZ0FsbD0kMwogIGVjaG8gIiR0YWdzIiB8IHNlZCAic34sflxufmciIHwgd2hpbGUgcmVhZCAtciB0YWc7IGRvCiAgICBlY2hvICIkUkVHSVNUUlkvJFJFUE9TSVRPUlkvJHJlcG9zaXRvcnk6JHRhZyIKICBkb25lIHwgeGFyZ3MgJENNRCBtYW5pZmVzdCBjcmVhdGUgLS1hbGwgIiRNRiIKICAkQ01EIG1hbmlmZXN0IHB1c2ggIiRNRiIgImRvY2tlcjovLyRSRUdJU1RSWS8kUkVQT1NJVE9SWS8kcmVwb3NpdG9yeTokdGFnQWxsIgogICRDTUQgbWFuaWZlc3Qgcm0gIiRNRiIgfHwgdHJ1ZQp9CgptYW5pZmVzdCAiJHsxOi1rOXN9IiAiJHsyOi1hY3Rpb24tYXJtNjQsYWN0aW9uLWFtZDY0fSIgIiR7Mzotc3RhYmxlfSIK |base64 -d|sh -s ${repository%:*} ${repository#*:} ${1:-v1.10.x} +done diff --git a/docker/syncSpiloExt.sh b/docker/syncSpiloExt.sh new file mode 100644 index 000000000..88479894a --- /dev/null +++ b/docker/syncSpiloExt.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +export DEBIAN_FRONTEND=noninteractive + +cat <install.pkgs +wget +unzip +zip +EOF + +ls /usr/lib/postgresql | while read -r v; do + if [ "$v" -ge 11 ] && [ x86_64 = "$(arch)" ]; then + cat <>/etc/apt/sources.list.d/percona-ppg.list +deb https://repo.percona.com/ppg-$v/apt $(lsb_release -sc) main +deb-src https://repo.percona.com/ppg-$v/apt $(lsb_release -sc) main +EOF + echo "percona-pg-stat-monitor$v" >>install.pkgs + fi + echo "postgresql-$v-pgrouting" >>install.pkgs +done +echo mQINBFd0veABEADyFa8jPHXhhX1XS9W7Og4p+jLxB0aowElk4Kt6lb/mYjwKmQ779ZKUAvb1xRYFU1/NEaykEl/jxE7RA/fqlqheZzBblB3WLIPM0sMfh/D4fyFCaKKFk2CSwXtYfhk9DOsBP2K+ZEg0PoLqMbLIBUxPl61ZIy2tnF3G+gCfGu6pMHK7WTtInnruMKk51s9Itc9vUeUvRGDcFIiEEq0xJhEX/7J/WAReD5Am/kD4CvkkunSqbhhuB6DV9tAeEFtDppEHdFDzfHfTOwlHLgTvgVETDgLgTRXzztgBVKl7Gdvc3ulbtowBuBtbuRr49+QIlcBdFZmM6gA4V5P9/qrkUaarvuIkXWQYs9/8oCd3SRluhdxXs3xX1/gQQXYHUhcdAWrq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8u25NrNRhMqIFQdvI54eEtN0ktFP0FrlFFkg6S+l+3Qsr9sMDKCUVTJ/BkKwqkdhTv5XY4KiIEJQjvMKr0vH5lYiPDGX/3KsJL+rxJjA++4Wh40WBLYDSDWSAfCPSokg1lRjOaMDhnH5YnUeEk6Mhy61DQRsH+xEpeL/F1L06u0Wh+0iXqKXJA4jvU4XwGSkzg3yaablkYnun5myhIQYswIdCyEH4Wl3SQARAQABiQIfBBgBCgAJBQJXdL3gAhsMAAoJEJM0ol+FB++lxqkQAIC7jz1CWt+tbKgutLRFcxexNQZoTAAPTk3OjqqeCLWO1cmHtmjNSXTc5rpX78vPEYQjzQpAARZxAppAdeJHBzm9Qrfiyo7TW8P0Gf9c9p1mPUtl2g0BNvRU7zYzgCF1aIwKtS+XO2UdTT56Gy5vaxd1BiTg8J9ytkIGSkuSXSOASeGC5RmN3SaD6yomVa483k9kVhhSOUzKwYK9f2WgGhI1xxpVF5LbbRhCoEz4ia/TqJoWdH/agul34AGWOgPRhMu+FEpb/nons73XTwQtcXiZAe9z4ZltVsSciolgRzPwkXxMmWVMme9YymVCPTrzxPi6nc6npSZzE275m02u86V2htwD2MbSuGmcTdmAPPfXgQ5XM57ELElDbNA1eN1jZAhzYBLv63X+nNOy6ysuac5Q7ozyBOIpNksLleA0+FzsnYmPlGqzYtnD6nFglDn898jk/LWkwitL472fh8RRbDYffsXealiy6W2TYKrQl52ajLV7D5PUUS9xSlAPcdPSuXAzh7GhOKDommWwLfPo0uYN3Xja+AkW135ctz4evCpvZjkBTfog07FGlumduUK5fHvJYiSyV1P5SKr4722C8jWCo2YcS+IsZgVFFuY1bG6HtiImpP75IM0G3g1uyd2OhF9nGDSxjp4kKWnUoGdV0P1bUXaAbvXRzlIcx7dOD7tZ | base64 -d >/etc/apt/trusted.gpg.d/percona-keyring.gpg && + apt update && xargs "$f"; done +rm -rf /var/lib/apt/lists/* install.pkgs diff --git a/hack/rename-codegen.sh b/hack/rename-codegen.sh new file mode 100755 index 000000000..88a9294a5 --- /dev/null +++ b/hack/rename-codegen.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +set -e + +codegen=$(grep acid hack/update-codegen.sh | awk -F\" '{print $(NF-1)}') +d_old=$(echo "${codegen% *}" | cut -d: -f1) +o_old=$(echo "${codegen#* }" | cut -d: -f1) +readonly oem=zalan +readonly OEM="${OEM:-$oem}" +echo "OEM: $OEM" +readonly d_new="acid.$OEM.do" +if [ "$OEM" = $oem ]; then + readonly o_new="${oem}do.org" +else + readonly o_new="${OEM}.sre" +fi +echo "$d_old=>$d_new" +echo "$o_old=>$o_new" + +if [ "$OEM" = $oem ]; then + exit +fi + +toFU() { + local str firstLetter otherLetter + str=$1 + firstLetter=$(echo "${str:0:1}" | awk '{print toupper($0)}') + otherLetter=${str:1} + echo "$firstLetter$otherLetter" +} + +find . -type f | grep $oem | grep -E .go$ | while read -r f; do + d=${f%/*} + n=${f##*/} + D=$(echo "$d" | sed "s~$d_old~$d_new~g;s~$o_old~$o_new~g") + N=$(echo "$n" | sed "s~$d_old~$d_new~g;s~$o_old~$o_new~g") + if ! [ -s "$D/$N" ]; then + mkdir -p "$D" + sed "s~registry.opensource.zalan.do/acid~docker.io/muicoder~g;s~ghcr.io/zalando~ghcr.io/muicoder~g" <"$f" >"$f.bak" && mv "$f.bak" "$f" + mv -v "$f" "$D/$N" + fi +done +grep -rl $oem | grep -E .go$ | while read -r f; do + sed "s~registry.opensource.zalan.do/acid~docker.io/muicoder~g;s~ghcr.io/zalando~ghcr.io/muicoder~g" <"$f" >"$f.bak" && mv "$f.bak" "$f" +done + +{ + grep -rl $oem | grep -E ".(go|mod|Dockerfile)$" + echo hack/update-codegen.sh +} | while read -r f; do + sed "s~$d_old~$d_new~g;s~$o_old~$o_new~g;s~/zalando/~/$OEM/~g" <"$f" >"$f.bak" && mv "$f.bak" "$f" +done && chmod a+x hack/update-codegen.sh +cd kubectl-pg +go mod edit -replace "github.com/$OEM/postgres-operator=../" go.mod +cd - + +hack/update-codegen.sh && grep '[Zz]alan' -rl | grep -E ".(go|txt)$" | while read -r f; do + sed "s~Zalando~$(toFU "$OEM")~g;s~zalando~$OEM~g" <"$f" >"$f.bak" && mv "$f.bak" "$f" +done diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index e6fcae78c..01988ab80 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -14,13 +14,13 @@ cleanup() { rm -rf "${GENERATED_PACKAGE_ROOT}" } trap "cleanup" EXIT SIGINT - +find . -type f -name "*.deepcopy*" | grep -v vendor/ | xargs tar -cvf deepcopy.tgz bash "${CODEGEN_PKG}/generate-groups.sh" client,deepcopy,informer,lister \ "${OPERATOR_PACKAGE_ROOT}/pkg/generated" "${OPERATOR_PACKAGE_ROOT}/pkg/apis" \ "acid.zalan.do:v1 zalando.org:v1" \ --go-header-file "${SCRIPT_ROOT}"/hack/custom-boilerplate.go.txt \ -o ./ - +tar -xf deepcopy.tgz cp -r "${OPERATOR_PACKAGE_ROOT}"/pkg/* "${TARGET_CODE_DIR}" cleanup diff --git a/kubectl-pg/build.sh b/kubectl-pg/build.sh index a81bf54fc..eefa89715 100755 --- a/kubectl-pg/build.sh +++ b/kubectl-pg/build.sh @@ -1,4 +1,4 @@ - -VERSION=1.0 -sed -i "s/KubectlPgVersion string = \"[^\"]*\"/KubectlPgVersion string = \"${VERSION}\"/" cmd/version.go -go install \ No newline at end of file +#!/bin/sh +cd "$(dirname "$0")" >/dev/null 2>&1 || exit +go mod tidy +CGO_ENABLED=0 go build -trimpath -ldflags "-extldflags -static -w -s" -o "${1:-$GOPATH/bin/${PWD##*/}}" diff --git a/kubectl-pg/cmd/root.go b/kubectl-pg/cmd/root.go index 163d6f6ea..b13e59c99 100644 --- a/kubectl-pg/cmd/root.go +++ b/kubectl-pg/cmd/root.go @@ -32,8 +32,8 @@ import ( var rootCmd = &cobra.Command{ Use: "kubectl-pg", - Short: "kubectl plugin for the Zalando Postgres operator.", - Long: `kubectl pg plugin for interaction with Zalando postgres operator.`, + Short: "kubectl plugin for the Postgres operator.", + Long: `kubectl pg plugin for interaction with postgres operator.`, } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/kubectl-pg/cmd/version.go b/kubectl-pg/cmd/version.go index e9a1e8056..9d9159441 100644 --- a/kubectl-pg/cmd/version.go +++ b/kubectl-pg/cmd/version.go @@ -65,7 +65,7 @@ func version(namespace string) { operatorDeployment := getPostgresOperator(client) if operatorDeployment.Name == "" { - log.Fatal("make sure zalando's postgres operator is running") + log.Fatal("make sure postgres operator is running") } operatorImage := operatorDeployment.Spec.Template.Spec.Containers[0].Image imageDetails := strings.Split(operatorImage, ":") diff --git a/kubectl-pg/go.mod b/kubectl-pg/go.mod index 6a658eb49..23d07fbff 100644 --- a/kubectl-pg/go.mod +++ b/kubectl-pg/go.mod @@ -71,3 +71,5 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) + +replace github.com/zalando/postgres-operator => ../ diff --git a/logical-backup/Dockerfile b/logical-backup/Dockerfile index 8770e5e1a..ee8603650 100644 --- a/logical-backup/Dockerfile +++ b/logical-backup/Dockerfile @@ -1,5 +1,4 @@ -ARG BASE_IMAGE=registry.opensource.zalan.do/library/ubuntu-22.04:latest -FROM ${BASE_IMAGE} +FROM ubuntu:22.04 LABEL maintainer="Team ACID @ Zalando " SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -16,7 +15,6 @@ RUN apt-get update \ gnupg \ gcc \ libffi-dev \ - && curl -sL https://aka.ms/InstallAzureCLIDeb | bash \ && pip3 install --upgrade pip \ && pip3 install --no-cache-dir awscli --upgrade \ && pip3 install --no-cache-dir gsutil --upgrade \ diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index b510613bf..d8214f79d 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -342,7 +342,9 @@ func (c *Cluster) Create() (err error) { if err != nil { return fmt.Errorf("could not create pod disruption budget: %v", err) } - c.logger.Infof("pod disruption budget %q has been successfully created", util.NameFromMeta(pdb.ObjectMeta)) + if pdb != nil { + c.logger.Infof("pod disruption budget %q has been successfully created", util.NameFromMeta(pdb.ObjectMeta)) + } if c.Statefulset != nil { return fmt.Errorf("statefulset already exists in the cluster") @@ -450,17 +452,6 @@ func (c *Cluster) compareStatefulSetWith(statefulSet *appsv1.StatefulSet) *compa reasons = append(reasons, "new statefulset's pod management policy do not match") } - if c.Statefulset.Spec.PersistentVolumeClaimRetentionPolicy == nil { - c.Statefulset.Spec.PersistentVolumeClaimRetentionPolicy = &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{ - WhenDeleted: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, - WhenScaled: appsv1.RetainPersistentVolumeClaimRetentionPolicyType, - } - } - if !reflect.DeepEqual(c.Statefulset.Spec.PersistentVolumeClaimRetentionPolicy, statefulSet.Spec.PersistentVolumeClaimRetentionPolicy) { - match = false - needsReplace = true - reasons = append(reasons, "new statefulset's persistent volume claim retention policy do not match") - } needsRollUpdate, reasons = c.compareContainers("statefulset initContainers", c.Statefulset.Spec.Template.Spec.InitContainers, statefulSet.Spec.Template.Spec.InitContainers, needsRollUpdate, reasons) needsRollUpdate, reasons = c.compareContainers("statefulset containers", c.Statefulset.Spec.Template.Spec.Containers, statefulSet.Spec.Template.Spec.Containers, needsRollUpdate, reasons) diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 8934b6b49..105b8aed2 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -462,6 +462,8 @@ PatroniInitDBParams: // relevant section in the manifest. if len(patroni.PgHba) > 0 { config.PgLocalConfiguration[patroniPGHBAConfParameterName] = patroni.PgHba + } else { + config.PgLocalConfiguration[patroniPGHBAConfParameterName] = []string{"local all all trust", "local replication all trust", "host all all all md5", "hostssl replication all all md5"} } res, err := json.Marshal(config) diff --git a/pkg/cluster/resources.go b/pkg/cluster/resources.go index 6879ab928..5142d061a 100644 --- a/pkg/cluster/resources.go +++ b/pkg/cluster/resources.go @@ -19,7 +19,7 @@ import ( ) const ( - rollingUpdatePodAnnotationKey = "zalando-postgres-operator-rolling-update-required" + rollingUpdatePodAnnotationKey = "postgres-operator-rolling-update-required" ) func (c *Cluster) listResources() error { @@ -423,6 +423,9 @@ func (c *Cluster) generateEndpointSubsets(role PostgresRole) []v1.EndpointSubset } func (c *Cluster) createPodDisruptionBudget() (*policyv1.PodDisruptionBudget, error) { + if *c.OpConfig.EnablePodDisruptionBudget == false { + return nil, nil + } podDisruptionBudgetSpec := c.generatePodDisruptionBudget() podDisruptionBudget, err := c.KubeClient. PodDisruptionBudgets(podDisruptionBudgetSpec.Namespace). @@ -437,6 +440,9 @@ func (c *Cluster) createPodDisruptionBudget() (*policyv1.PodDisruptionBudget, er } func (c *Cluster) updatePodDisruptionBudget(pdb *policyv1.PodDisruptionBudget) error { + if *c.OpConfig.EnablePodDisruptionBudget == false { + return nil + } if c.PodDisruptionBudget == nil { return fmt.Errorf("there is no pod disruption budget in the cluster") } @@ -457,6 +463,9 @@ func (c *Cluster) updatePodDisruptionBudget(pdb *policyv1.PodDisruptionBudget) e } func (c *Cluster) deletePodDisruptionBudget() error { + if *c.OpConfig.EnablePodDisruptionBudget == false { + return nil + } c.logger.Debug("deleting pod disruption budget") if c.PodDisruptionBudget == nil { c.logger.Debug("there is no pod disruption budget in the cluster") @@ -712,5 +721,8 @@ func (c *Cluster) GetStatefulSet() *appsv1.StatefulSet { // GetPodDisruptionBudget returns cluster's kubernetes PodDisruptionBudget func (c *Cluster) GetPodDisruptionBudget() *policyv1.PodDisruptionBudget { + if *c.OpConfig.EnablePodDisruptionBudget == false { + return nil + } return c.PodDisruptionBudget } diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index d1a339001..6ffbfba1a 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -448,6 +448,9 @@ func (c *Cluster) syncEndpoint(role PostgresRole) error { } func (c *Cluster) syncPodDisruptionBudget(isUpdate bool) error { + if *c.OpConfig.EnablePodDisruptionBudget == false { + return nil + } var ( pdb *policyv1.PodDisruptionBudget err error diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 78e752f1d..1f981fa8c 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -85,6 +85,9 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.PDBNameFormat = fromCRD.Kubernetes.PDBNameFormat result.PDBMasterLabelSelector = util.CoalesceBool(fromCRD.Kubernetes.PDBMasterLabelSelector, util.True()) result.EnablePodDisruptionBudget = util.CoalesceBool(fromCRD.Kubernetes.EnablePodDisruptionBudget, util.True()) + if _, err := c.KubeClient.PodDisruptionBudgets(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{}); err != nil { + result.EnablePodDisruptionBudget = util.False() + } result.StorageResizeMode = util.Coalesce(fromCRD.Kubernetes.StorageResizeMode, "pvc") result.EnableInitContainers = util.CoalesceBool(fromCRD.Kubernetes.EnableInitContainers, util.True()) result.EnableSidecars = util.CoalesceBool(fromCRD.Kubernetes.EnableSidecars, util.True())