Skip to content

Commit bde4f4e

Browse files
(fix): update PSA versions to match Kubernetes API version
derive Kubernetes minor version from client-go for PSA updates - Introduce `KUBE_MINOR`, derived from the `k8s.io/client-go` version, to determine the minor Kubernetes version to build against. - Add `update-k8s-values` Make target to update PSA (Pod Security Admission) labels in YAML manifests with the correct Kubernetes version. - Ensure PSA version aligns with the supported Kubernetes version, not the latest, to prevent potential breaking changes.
1 parent 97b1337 commit bde4f4e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,18 @@ generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyI
143143
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
144144

145145
.PHONY: verify
146-
verify: tidy fmt generate manifests crd-ref-docs #HELP Verify all generated code is up-to-date.
146+
verify: tidy fmt generate manifests crd-ref-docs update-k8s-values #HELP Verify all generated code is up-to-date.
147147
git diff --exit-code
148148

149+
# Minor Kubernetes version to build against derived from the client-go dependency version
150+
KUBE_MINOR ?= $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1/')
151+
152+
.PHONY: update-k8s-values # HELP Update PSA labels in config manifests with Kubernetes version
153+
update-k8s-values:
154+
find config -type f -name '*.yaml' -exec \
155+
sed -i.bak -E 's/(pod-security.kubernetes.io\/[a-zA-Z-]+-version:).*/\1 "v$(KUBE_MINOR)"/g' {} +;
156+
find config -type f -name '*.yaml.bak' -delete
157+
149158
.PHONY: fix-lint
150159
fix-lint: $(GOLANGCI_LINT) #EXHELP Fix lint issues
151160
$(GOLANGCI_LINT) run --fix --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)

config/base/common/namespace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ metadata:
44
labels:
55
app.kubernetes.io/part-of: olm
66
pod-security.kubernetes.io/enforce: baseline
7-
pod-security.kubernetes.io/enforce-version: latest
7+
pod-security.kubernetes.io/enforce-version: "v1.32"
88
name: system

0 commit comments

Comments
 (0)