postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

fix: move to scratch docker image

Open slimm609 opened this issue 1 year ago • 0 comments

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.

  • removed docker/build_operator.sh which was no longer used after https://github.com/zalando/postgres-operator/pull/2665/files
  • since both the image and the k8s manifests reference the user id of 1000:1000, there is no need to pre-create the user or to even have a passwd file in the image, if the user was set to pgo:pgo then this would require the passwd file to be able to map the name to an id.
  • update kubectl version to match the kind version used for testing
  • updated e2e tests to automatically build image if it doesn't exist during pipeline tests
  • update kubernetes python library to a valid version. the referenced version was not valid during build and not listed in https://pypi.org/project/kubernetes/#history

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

slimm609 avatar Jul 29 '24 23:07 slimm609