Skip to content

Commit

Permalink
update all but logr dependencies (#249)
Browse files Browse the repository at this point in the history
* update all but logr dependencies, compiles but tests fail

* Update build deps

* Fix duplicate import

* Remove deprecated custom reporter

* Downgrade to kubebuilder 2.x and postpone migration

* make svc-postgres-operator-yaml

* use Makefuke for the build in dockerfile, strip binary save 14MB

Co-authored-by: Philipp Eberle <[email protected]>
  • Loading branch information
majst01 and eberlep authored Jul 20, 2021
1 parent ee4b0cb commit 74991b2
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 144 deletions.
19 changes: 3 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,14 @@
FROM golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
COPY . .
RUN make

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/bin/manager .
COPY external/svc-postgres-operator.yaml external/svc-postgres-operator.yaml
USER nonroot:nonroot

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BUILDDATE := $(shell date -Iseconds)
VERSION := $(or ${DOCKER_TAG},latest)

# Postgres operator variables for YAML download
POSTGRES_OPERATOR_VERSION ?= v1.6.1
POSTGRES_OPERATOR_VERSION ?= v1.6.3
POSTGRES_OPERATOR_URL ?= https://raw.githubusercontent.com/zalando/postgres-operator/$(POSTGRES_OPERATOR_VERSION)/manifests
POSTGRES_CRD_URL ?= https://raw.githubusercontent.com/zalando/postgres-operator/$(POSTGRES_OPERATOR_VERSION)/charts/postgres-operator/crds/postgresqls.yaml

Expand All @@ -33,6 +33,7 @@ test: generate fmt vet manifests
# todo: Modify Dockerfile to include the version magic
# Build manager binary
manager: generate fmt vet manifests
CGO_ENABLED=0 \
go build -a -ldflags "-extldflags '-static' \
-X 'github.com/metal-stack/v.Version=$(VERSION)' \
-X 'github.com/metal-stack/v.Revision=$(GITVERSION)' \
Expand Down Expand Up @@ -105,7 +106,7 @@ ifeq (, $(shell which controller-gen))
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.5 ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/database.fits.cloud_postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
controller-gen.kubebuilder.io/version: v0.5.0
creationTimestamp: null
name: postgres.database.fits.cloud
spec:
Expand Down
6 changes: 2 additions & 4 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
cr "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"

Expand Down Expand Up @@ -66,9 +65,8 @@ var (
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
RunSpecs(t,
"Controller Suite")
}

var _ = BeforeSuite(func() {
Expand Down
16 changes: 10 additions & 6 deletions external/svc-postgres-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ items:
cluster_history_entries: "1000"
cluster_labels: application:spilo
cluster_name_label: cluster-name
connection_pooler_image: registry.opensource.zalan.do/acid/pgbouncer:master-14
connection_pooler_image: registry.opensource.zalan.do/acid/pgbouncer:master-16
db_hosted_zone: db.example.com
debug_logging: "true"
docker_image: registry.opensource.zalan.do/acid/spilo-13:2.0-p4
docker_image: registry.opensource.zalan.do/acid/spilo-13:2.0-p7
enable_ebs_gp3_migration: "false"
enable_master_load_balancer: "false"
enable_pgversion_env_var: "true"
enable_replica_load_balancer: "false"
enable_spilo_wal_path_compat: "true"
enable_team_member_deprecation: "false"
enable_teams_api: "false"
external_traffic_policy: Cluster
logical_backup_docker_image: registry.opensource.zalan.do/acid/logical-backup:v1.6.1
logical_backup_docker_image: registry.opensource.zalan.do/acid/logical-backup:v1.6.3
logical_backup_job_prefix: logical-backup-
logical_backup_provider: s3
logical_backup_s3_bucket: my-bucket-url
logical_backup_s3_sse: AES256
logical_backup_schedule: 30 00 * * *
major_version_upgrade_mode: manual
master_dns_name_format: '{cluster}.{team}.{hostedzone}'
pdb_name_format: postgres-{cluster}-pdb
pod_deletion_wait_timeout: 10m
Expand All @@ -42,7 +44,9 @@ items:
resource_check_timeout: 10m
resync_period: 30m
ring_log_lines: "100"
role_deletion_suffix: _deleted
secret_name_template: '{username}.{cluster}.credentials'
spilo_allow_privilege_escalation: "true"
spilo_privileged: "false"
storage_resize_mode: pvc
super_username: postgres
Expand All @@ -52,7 +56,7 @@ items:
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","data":{"api_port":"8080","aws_region":"eu-central-1","cluster_domain":"cluster.local","cluster_history_entries":"1000","cluster_labels":"application:spilo","cluster_name_label":"cluster-name","connection_pooler_image":"registry.opensource.zalan.do/acid/pgbouncer:master-14","db_hosted_zone":"db.example.com","debug_logging":"true","docker_image":"registry.opensource.zalan.do/acid/spilo-13:2.0-p4","enable_ebs_gp3_migration":"false","enable_master_load_balancer":"false","enable_pgversion_env_var":"true","enable_replica_load_balancer":"false","enable_spilo_wal_path_compat":"true","enable_teams_api":"false","external_traffic_policy":"Cluster","logical_backup_docker_image":"registry.opensource.zalan.do/acid/logical-backup:v1.6.1","logical_backup_job_prefix":"logical-backup-","logical_backup_provider":"s3","logical_backup_s3_bucket":"my-bucket-url","logical_backup_s3_sse":"AES256","logical_backup_schedule":"30 00 * * *","master_dns_name_format":"{cluster}.{team}.{hostedzone}","pdb_name_format":"postgres-{cluster}-pdb","pod_deletion_wait_timeout":"10m","pod_label_wait_timeout":"10m","pod_management_policy":"ordered_ready","pod_role_label":"spilo-role","pod_service_account_name":"postgres-pod","pod_terminate_grace_period":"5m","ready_wait_interval":"3s","ready_wait_timeout":"30s","repair_period":"5m","replica_dns_name_format":"{cluster}-repl.{team}.{hostedzone}","replication_username":"standby","resource_check_interval":"3s","resource_check_timeout":"10m","resync_period":"30m","ring_log_lines":"100","secret_name_template":"{username}.{cluster}.credentials","spilo_privileged":"false","storage_resize_mode":"pvc","super_username":"postgres","watched_namespace":"*","workers":"8"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"postgres-operator","namespace":"default"}}
{"apiVersion":"v1","data":{"api_port":"8080","aws_region":"eu-central-1","cluster_domain":"cluster.local","cluster_history_entries":"1000","cluster_labels":"application:spilo","cluster_name_label":"cluster-name","connection_pooler_image":"registry.opensource.zalan.do/acid/pgbouncer:master-16","db_hosted_zone":"db.example.com","debug_logging":"true","docker_image":"registry.opensource.zalan.do/acid/spilo-13:2.0-p7","enable_ebs_gp3_migration":"false","enable_master_load_balancer":"false","enable_pgversion_env_var":"true","enable_replica_load_balancer":"false","enable_spilo_wal_path_compat":"true","enable_team_member_deprecation":"false","enable_teams_api":"false","external_traffic_policy":"Cluster","logical_backup_docker_image":"registry.opensource.zalan.do/acid/logical-backup:v1.6.3","logical_backup_job_prefix":"logical-backup-","logical_backup_provider":"s3","logical_backup_s3_bucket":"my-bucket-url","logical_backup_s3_sse":"AES256","logical_backup_schedule":"30 00 * * *","major_version_upgrade_mode":"manual","master_dns_name_format":"{cluster}.{team}.{hostedzone}","pdb_name_format":"postgres-{cluster}-pdb","pod_deletion_wait_timeout":"10m","pod_label_wait_timeout":"10m","pod_management_policy":"ordered_ready","pod_role_label":"spilo-role","pod_service_account_name":"postgres-pod","pod_terminate_grace_period":"5m","ready_wait_interval":"3s","ready_wait_timeout":"30s","repair_period":"5m","replica_dns_name_format":"{cluster}-repl.{team}.{hostedzone}","replication_username":"standby","resource_check_interval":"3s","resource_check_timeout":"10m","resync_period":"30m","ring_log_lines":"100","role_deletion_suffix":"_deleted","secret_name_template":"{username}.{cluster}.credentials","spilo_allow_privilege_escalation":"true","spilo_privileged":"false","storage_resize_mode":"pvc","super_username":"postgres","watched_namespace":"*","workers":"8"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"postgres-operator","namespace":"default"}}
name: postgres-operator
namespace: default
- apiVersion: v1
Expand Down Expand Up @@ -302,7 +306,7 @@ items:
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"application":"postgres-operator"},"name":"postgres-operator","namespace":"default"},"spec":{"replicas":1,"selector":{"matchLabels":{"name":"postgres-operator"}},"strategy":{"type":"Recreate"},"template":{"metadata":{"labels":{"name":"postgres-operator"}},"spec":{"containers":[{"env":[{"name":"CONFIG_MAP_NAME","value":"postgres-operator"}],"image":"registry.opensource.zalan.do/acid/postgres-operator:v1.6.1","imagePullPolicy":"IfNotPresent","name":"postgres-operator","resources":{"limits":{"cpu":"500m","memory":"500Mi"},"requests":{"cpu":"100m","memory":"250Mi"}},"securityContext":{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":1000}}],"serviceAccountName":"postgres-operator"}}}}
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"application":"postgres-operator"},"name":"postgres-operator","namespace":"default"},"spec":{"replicas":1,"selector":{"matchLabels":{"name":"postgres-operator"}},"strategy":{"type":"Recreate"},"template":{"metadata":{"labels":{"name":"postgres-operator"}},"spec":{"containers":[{"env":[{"name":"CONFIG_MAP_NAME","value":"postgres-operator"}],"image":"registry.opensource.zalan.do/acid/postgres-operator:v1.6.3","imagePullPolicy":"IfNotPresent","name":"postgres-operator","resources":{"limits":{"cpu":"500m","memory":"500Mi"},"requests":{"cpu":"100m","memory":"250Mi"}},"securityContext":{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":1000}}],"serviceAccountName":"postgres-operator"}}}}
labels:
application: postgres-operator
name: postgres-operator
Expand All @@ -323,7 +327,7 @@ items:
- env:
- name: CONFIG_MAP_NAME
value: postgres-operator
image: registry.opensource.zalan.do/acid/postgres-operator:latest
image: registry.opensource.zalan.do/acid/postgres-operator:v1.6.3
imagePullPolicy: IfNotPresent
name: postgres-operator
resources:
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ require (
github.com/go-logr/logr v0.4.0
github.com/metal-stack/firewall-controller v1.0.9
github.com/metal-stack/v v1.0.3
github.com/onsi/ginkgo v1.16.2
github.com/onsi/gomega v1.13.0
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.48.1
github.com/spf13/viper v1.8.0
github.com/zalando/postgres-operator v1.6.2
inet.af/netaddr v0.0.0-20210511181906-37180328850c
k8s.io/api v0.20.6
k8s.io/apiextensions-apiserver v0.20.6
k8s.io/apimachinery v0.20.6
k8s.io/client-go v0.20.6
sigs.k8s.io/controller-runtime v0.8.3
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.14.0
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.49.0
github.com/spf13/viper v1.8.1
github.com/zalando/postgres-operator v1.6.3
inet.af/netaddr v0.0.0-20210718074554-06ca8145d722
k8s.io/api v0.21.3
k8s.io/apiextensions-apiserver v0.21.3
k8s.io/apimachinery v0.21.3
k8s.io/client-go v0.21.3
sigs.k8s.io/controller-runtime v0.9.2
)
Loading

0 comments on commit 74991b2

Please sign in to comment.