Skip to content

Commit c356365

Browse files
Version updates (#591)
* Updates * Update firewall-controller deps * make svc-postgres-operator-yaml * Update deployment based on updated defaults * Modify securityContext after major upgrade * Update go * make svc-postgres-operator-yaml * Modify securityContext after major upgrade * Update github actions * Move from deprecated pointer package to ptr * Remove unused var * Simplify * Downgrade before cherry-pick * update github actions --------- Co-authored-by: Ulrich Schreiner <[email protected]>
1 parent 6a34d0e commit c356365

File tree

13 files changed

+341
-722
lines changed

13 files changed

+341
-722
lines changed

.github/workflows/pull_request.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212
docker_registry_token: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616

1717
- name: Ensure Go Version
18-
uses: actions/setup-go@v4
18+
uses: actions/setup-go@v5
1919
with:
2020
go-version-file: 'go.mod'
2121

2222
- name: Lint
23-
uses: golangci/golangci-lint-action@v4
23+
uses: golangci/golangci-lint-action@v6
2424
with:
2525
args: -p bugs -p unused --timeout=5m
2626

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG baseImage="golang:1.22"
1+
ARG baseImage="golang:1.24"
22
# Build the manager binary
33
FROM ${baseImage} as builder
44

@@ -18,7 +18,7 @@ RUN make
1818

1919
# Start obj-cache
2020
# https://medium.com/windmill-engineering/tips-tricks-for-making-your-golang-container-builds-10x-faster-4cc618a43827
21-
FROM golang:1.22 as obj-cache
21+
FROM golang:1.24 as obj-cache
2222
COPY --from=builder /root/.cache /root/.cache
2323

2424
# Use distroless as minimal base image to package the manager binary

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
1919
CONTROLLER_TOOLS_VERSION ?= v0.14.0
2020

2121
# Postgres operator variables for YAML download
22-
POSTGRES_OPERATOR_VERSION ?= v1.11.0
22+
POSTGRES_OPERATOR_VERSION ?= v1.14.0
2323
POSTGRES_OPERATOR_URL ?= https://raw.githubusercontent.com/zalando/postgres-operator/$(POSTGRES_OPERATOR_VERSION)/manifests
2424
POSTGRES_CRD_URL ?= https://raw.githubusercontent.com/zalando/postgres-operator/$(POSTGRES_OPERATOR_VERSION)/charts/postgres-operator/crds/postgresqls.yaml
2525

@@ -238,8 +238,11 @@ localkube-teardown:
238238
kind delete cluster --name svc
239239

240240
localkube-install-crd-servicemonitor:
241-
kubectl apply --kubeconfig ./kubeconfig-svc -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
242-
kubectl apply --kubeconfig ./kubeconfig-svc -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.45.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
241+
kubectl apply --kubeconfig ./kubeconfig-svc -f https://raw.githubusercontent.com/prometheus-community/helm-charts/refs/tags/kube-prometheus-stack-65.5.1/charts/kube-prometheus-stack/charts/crds/crds/crd-servicemonitors.yaml
242+
kubectl apply --kubeconfig ./kubeconfig-svc -f https://raw.githubusercontent.com/prometheus-community/helm-charts/refs/tags/kube-prometheus-stack-65.5.1/charts/kube-prometheus-stack/charts/crds/crds/crd-podmonitors.yaml
243+
244+
localkube-install-crd-certmanager:
245+
kubectl apply --kubeconfig ./kubeconfig-svc -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.4/cert-manager.crds.yaml
243246

244247
localkube-reinstall-postgreslet: localkube-load-image
245248
# helm repo add metal-stack https://helm.metal-stack.io # stable repo

api/v1/postgres_types.go

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
"regexp"
1818

19-
firewall "github.com/metal-stack/firewall-controller/api/v1"
19+
firewall "github.com/metal-stack/firewall-controller/v2/api/v1"
2020
zalando "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
2121
corev1 "k8s.io/api/core/v1"
2222
networkingv1 "k8s.io/api/networking/v1"
@@ -27,7 +27,7 @@ import (
2727
"k8s.io/apimachinery/pkg/types"
2828
"k8s.io/apimachinery/pkg/util/intstr"
2929
"k8s.io/apimachinery/pkg/util/yaml"
30-
"k8s.io/utils/pointer"
30+
"k8s.io/utils/ptr"
3131
"sigs.k8s.io/controller-runtime/pkg/client"
3232
)
3333

@@ -370,13 +370,9 @@ func (p *Postgres) ToSharedSvcLB(lbIP string, lbPort int32, enableStandbyLeaderS
370370

371371
lbsr := []string{}
372372
if p.HasSourceRanges() {
373-
for _, src := range p.Spec.AccessList.SourceRanges {
374-
lbsr = append(lbsr, src)
375-
}
376-
}
377-
for _, scsr := range standbyClustersSourceRanges {
378-
lbsr = append(lbsr, scsr)
373+
lbsr = append(lbsr, p.Spec.AccessList.SourceRanges...)
379374
}
375+
lbsr = append(lbsr, standbyClustersSourceRanges...)
380376
if len(lbsr) == 0 {
381377
// block by default
382378
lbsr = append(lbsr, "255.255.255.255/32")
@@ -467,13 +463,9 @@ func (p *Postgres) ToDedicatedSvcLB(lbIP string, lbPort int32, standbyClustersSo
467463

468464
lbsr := []string{}
469465
if p.HasSourceRanges() {
470-
for _, src := range p.Spec.AccessList.SourceRanges {
471-
lbsr = append(lbsr, src)
472-
}
473-
}
474-
for _, scsr := range standbyClustersSourceRanges {
475-
lbsr = append(lbsr, scsr)
466+
lbsr = append(lbsr, p.Spec.AccessList.SourceRanges...)
476467
}
468+
lbsr = append(lbsr, standbyClustersSourceRanges...)
477469
if len(lbsr) == 0 {
478470
// block by default
479471
lbsr = append(lbsr, "255.255.255.255/32")
@@ -703,10 +695,10 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor
703695
setSharedBufferSize(z.Spec.PostgresqlParam.Parameters, p.Spec.Size.SharedBuffer)
704696

705697
z.Spec.Resources = &zalando.Resources{}
706-
z.Spec.Resources.ResourceRequests.CPU = pointer.String(p.Spec.Size.CPU)
707-
z.Spec.Resources.ResourceRequests.Memory = pointer.String(p.Spec.Size.Memory)
708-
z.Spec.Resources.ResourceLimits.CPU = pointer.String(p.Spec.Size.CPU)
709-
z.Spec.Resources.ResourceLimits.Memory = pointer.String(p.Spec.Size.Memory)
698+
z.Spec.Resources.ResourceRequests.CPU = ptr.To(p.Spec.Size.CPU)
699+
z.Spec.Resources.ResourceRequests.Memory = ptr.To(p.Spec.Size.Memory)
700+
z.Spec.Resources.ResourceLimits.CPU = ptr.To(p.Spec.Size.CPU)
701+
z.Spec.Resources.ResourceLimits.Memory = ptr.To(p.Spec.Size.Memory)
710702
z.Spec.TeamID = p.generateTeamID()
711703
z.Spec.Volume.Size = p.Spec.Size.StorageSize
712704
z.Spec.Volume.StorageClass = sc
@@ -719,7 +711,7 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor
719711

720712
// required with image ermajn/postgres-operator:v1.6.0-20-g1cc71663-dirty
721713
// see https://github.com/fi-ts/postgreslet/issues/293
722-
z.Spec.EnableConnectionPooler = pointer.Bool(false)
714+
z.Spec.EnableConnectionPooler = ptr.To(false)
723715

724716
prefix := alphaNumericRegExp.ReplaceAllString(string(p.Spec.Tenant), "")
725717
prefix = strings.ToLower(prefix)
@@ -779,7 +771,7 @@ func (p *Postgres) ToUnstructuredZalandoPostgresql(z *zalando.Postgresql, c *cor
779771
S3Endpoint: rbs.S3Endpoint,
780772
S3AccessKeyId: rbs.S3AccessKey,
781773
S3SecretAccessKey: rbs.S3SecretKey,
782-
S3ForcePathStyle: pointer.Bool(true),
774+
S3ForcePathStyle: ptr.To(true),
783775
}
784776
} else {
785777
// if we don't set the clone block, remove it completely

controllers/postgres_controller.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
batchv1 "k8s.io/api/batch/v1"
2828
corev1 "k8s.io/api/core/v1"
2929
"k8s.io/client-go/tools/record"
30-
"k8s.io/utils/pointer"
30+
"k8s.io/utils/ptr"
3131

32-
firewall "github.com/metal-stack/firewall-controller/api/v1"
32+
firewall "github.com/metal-stack/firewall-controller/v2/api/v1"
3333
coreosv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
3434
networkingv1 "k8s.io/api/networking/v1"
3535
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -634,13 +634,10 @@ func (r *PostgresReconciler) updatePodEnvironmentSecret(log logr.Logger, ctx con
634634
}
635635

636636
var s *corev1.Secret
637-
ns := types.NamespacedName{
638-
Name: operatormanager.PodEnvCMName,
639-
Namespace: p.ToPeripheralResourceNamespace(),
640-
}
637+
ns := p.ToPeripheralResourceNamespace()
641638

642-
if s, err = r.OperatorManager.CreateOrGetPodEnvironmentSecret(ctx, ns.Namespace); err != nil {
643-
return fmt.Errorf("error while accessing the pod environment secret %v: %w", ns.Namespace, err)
639+
if s, err = r.OperatorManager.CreateOrGetPodEnvironmentSecret(ctx, ns); err != nil {
640+
return fmt.Errorf("error while accessing the pod environment secret %v: %w", ns, err)
644641
}
645642

646643
s.Data = data
@@ -1089,7 +1086,7 @@ func (r *PostgresReconciler) checkAndUpdatePatroniReplicationConfig(log logr.Log
10891086
r.recorder.Eventf(s, "Warning", "Error", "failed to get referenced sync standby: %v", err)
10901087
synchronousStandbyApplicationName = nil
10911088
} else {
1092-
synchronousStandbyApplicationName = pointer.String(s.ToPeripheralResourceName())
1089+
synchronousStandbyApplicationName = ptr.To(s.ToPeripheralResourceName())
10931090
}
10941091
// compare the actual value with the expected value
10951092
if synchronousStandbyApplicationName == nil {
@@ -1217,7 +1214,7 @@ func (r *PostgresReconciler) httpPatchPatroni(log logr.Logger, ctx context.Conte
12171214
r.recorder.Eventf(s, "Warning", "Error", "failed to get referenced sync standby: %v", err)
12181215
synchronousStandbyApplicationName = nil
12191216
} else {
1220-
synchronousStandbyApplicationName = pointer.String(s.ToPeripheralResourceName())
1217+
synchronousStandbyApplicationName = ptr.To(s.ToPeripheralResourceName())
12211218
}
12221219
}
12231220
// enable sync replication
@@ -1693,7 +1690,7 @@ func (r *PostgresReconciler) createOrUpdatePatroniPodMonitor(ctx context.Context
16931690

16941691
pm.Spec.PodMetricsEndpoints = []coreosv1.PodMetricsEndpoint{
16951692
{
1696-
Port: podMonitorPort,
1693+
Port: ptr.To(podMonitorPort),
16971694
},
16981695
}
16991696
pm.Spec.NamespaceSelector = coreosv1.NamespaceSelector{
@@ -1920,6 +1917,10 @@ func (r *PostgresReconciler) ensureInitDBJob(log logr.Logger, ctx context.Contex
19201917
j.Name = ns.Name
19211918
j.Namespace = ns.Namespace
19221919

1920+
var uid int64 = 101
1921+
var gid int64 = 101
1922+
var ttl int32 = 180
1923+
19231924
var backOffLimit int32 = 99
19241925
j.Spec = batchv1.JobSpec{
19251926
Template: corev1.PodTemplateSpec{
@@ -1951,12 +1952,12 @@ func (r *PostgresReconciler) ensureInitDBJob(log logr.Logger, ctx context.Contex
19511952
},
19521953
},
19531954
SecurityContext: &corev1.SecurityContext{
1954-
AllowPrivilegeEscalation: pointer.Bool(false),
1955-
Privileged: pointer.Bool(false),
1956-
ReadOnlyRootFilesystem: pointer.Bool(true),
1957-
RunAsNonRoot: pointer.Bool(true),
1958-
RunAsUser: pointer.Int64(101),
1959-
RunAsGroup: pointer.Int64(101),
1955+
AllowPrivilegeEscalation: ptr.To(false),
1956+
Privileged: ptr.To(false),
1957+
ReadOnlyRootFilesystem: ptr.To(true),
1958+
RunAsNonRoot: ptr.To(true),
1959+
RunAsUser: ptr.To(uid),
1960+
RunAsGroup: ptr.To(gid),
19601961
Capabilities: &corev1.Capabilities{
19611962
Drop: []corev1.Capability{"ALL"},
19621963
},
@@ -1988,7 +1989,7 @@ func (r *PostgresReconciler) ensureInitDBJob(log logr.Logger, ctx context.Contex
19881989
},
19891990
},
19901991
BackoffLimit: &backOffLimit,
1991-
TTLSecondsAfterFinished: pointer.Int32(180),
1992+
TTLSecondsAfterFinished: ptr.To(ttl),
19921993
}
19931994

19941995
if err := r.SvcClient.Create(ctx, j); err != nil {

controllers/postgres_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package controllers
88

99
import (
1010
pg "github.com/fi-ts/postgreslet/api/v1"
11-
firewall "github.com/metal-stack/firewall-controller/api/v1"
11+
firewall "github.com/metal-stack/firewall-controller/v2/api/v1"
1212
. "github.com/onsi/ginkgo"
1313
. "github.com/onsi/gomega"
1414
zalando "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"

controllers/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
pg "github.com/fi-ts/postgreslet/api/v1"
3030
"github.com/fi-ts/postgreslet/pkg/lbmanager"
3131
"github.com/fi-ts/postgreslet/pkg/operatormanager"
32-
firewall "github.com/metal-stack/firewall-controller/api/v1"
32+
firewall "github.com/metal-stack/firewall-controller/v2/api/v1"
3333
zalando "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
3434
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3535
clientgoscheme "k8s.io/client-go/kubernetes/scheme"

0 commit comments

Comments
 (0)