zalando / postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
https://postgres-operator.readthedocs.io/
MIT License
4.37k stars 980 forks source link

fix: move to scratch docker image #2705

Open slimm609 opened 3 months ago

slimm609 commented 3 months ago

This updates several components in order to switch to scratch images. The move to scratch is to reduce additional OS dependencies and also added ldflags to remove golang debug symbols.

This resulted in a reduction from 96.6MB to 54.9MB for the release image

This also removes all other files except for the operator itself and the ca-certificates. This is the new image structure

                                   ├── etc
drwxr-xr-x         0:0     214 kB  │   └── ssl
drwxr-xr-x         0:0     214 kB  │       └── certs
-rw-r--r--         0:0     214 kB  │           └── ca-certificates.crt
-rwxr-xr-x         0:0      55 MB  └── postgres-operator

Switched off of golang-alpine image because of issues with alpine images as well as the alpine golang image being experimental. https://hub.docker.com/_/golang declares "This variant is highly experimental, and not officially supported by the Go project" There are several issues with alpine due to musl as well

are some examples. golang:$ver is the supported version

This required some additional changes to fix the e2e tests, mainly replacing the kubectl exec for curl and wget and replacing it with port-forward and using python requests instead. This method does not require curl or wget to be included in the operator image.

Ran e2e tests to numerous times to confirm all the changes worked.