Skip to content

Commit 9634f31

Browse files
committed
Remove the status field from generated CRD YAML
We use server-side apply to manage our large CRD, but older versions of Kubernetes do not ignore sub-resource fields. Issue: [sc-14162]
1 parent ce16911 commit 9634f31

File tree

4 files changed

+16
-28
lines changed

4 files changed

+16
-28
lines changed

Makefile

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,21 @@ createnamespaces:
8383
deletenamespaces:
8484
$(PGO_KUBE_CLIENT) delete -k ./config/namespace
8585

86-
# Note: For 'install', 'deploy' and 'deploy-dev' below
87-
# Using `--server-side --force-conflicts` when applying the K8s objects in order to
88-
# A) remove the `kubectl.kubernetes.io/last-applied-configuration` from the CRD since it
89-
# was violating the limit on size of `metadata.annotations`
90-
# - https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go#L36
91-
# B) overriding conflicts around managed fields during subsequent applies;
92-
# the fields that were erroring in a local k3s cluster were `.status.conditions`,
93-
# `.status.acceptedNames.kind`, and `.status.acceptedNames.plural`, which were managed by
94-
# `k3s` rather than by `kubectl`
95-
9686
# Install the postgrescluster CRD
9787
install:
98-
$(PGO_KUBE_CLIENT) apply --server-side --force-conflicts -k ./config/crd
88+
$(PGO_KUBE_CLIENT) apply --server-side -k ./config/crd
9989

10090
# Delete the postgrescluster CRD
10191
uninstall:
10292
$(PGO_KUBE_CLIENT) delete -k ./config/crd
10393

10494
# Deploy the PostgreSQL Operator (enables the postgrescluster controller)
10595
deploy:
106-
$(PGO_KUBE_CLIENT) apply --server-side --force-conflicts -k ./config/default
96+
$(PGO_KUBE_CLIENT) apply --server-side -k ./config/default
10797

10898
# Deploy the PostgreSQL Operator locally
10999
deploy-dev: build-postgres-operator createnamespaces
110-
$(PGO_KUBE_CLIENT) apply --server-side --force-conflicts -k ./config/dev
100+
$(PGO_KUBE_CLIENT) apply --server-side -k ./config/dev
111101
hack/create-kubeconfig.sh postgres-operator pgo
112102
env \
113103
CRUNCHY_DEBUG=true \
@@ -197,17 +187,9 @@ check-envtest: hack/tools/envtest
197187
KUBEBUILDER_ASSETS="$(CURDIR)/$^/bin" PGO_NAMESPACE="postgres-operator" $(GO_TEST) -count=1 -cover -tags=envtest ./...
198188

199189
# - PGO_TEST_TIMEOUT_SCALE=1
200-
# Note: using `--server-side --force-conflicts` when applying the K8s objects in order to
201-
# A) remove the `kubectl.kubernetes.io/last-applied-configuration` from the CRD since it
202-
# was violating the limit on size of `metadata.annotations`
203-
# - https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go#L36
204-
# B) overriding conflicts around managed fields during subsequent applies;
205-
# the fields that were erroring in a local k3s cluster were `.status.conditions`,
206-
# `.status.acceptedNames.kind`, and `.status.acceptedNames.plural`, which were managed by
207-
# `k3s` rather than by `kubectl`
208190
.PHONY: check-envtest-existing
209191
check-envtest-existing: createnamespaces
210-
${PGO_KUBE_CLIENT} apply --server-side --force-conflicts -k ./config/dev
192+
${PGO_KUBE_CLIENT} apply --server-side -k ./config/dev
211193
USE_EXISTING_CLUSTER=true PGO_NAMESPACE="postgres-operator" $(GO_TEST) -count=1 -cover -p=1 -tags=envtest ./...
212194
${PGO_KUBE_CLIENT} delete -k ./config/dev
213195

build/crd/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ patchesJson6902:
1111
kind: CustomResourceDefinition
1212
name: postgresclusters.postgres-operator.crunchydata.com
1313
path: condition.yaml
14+
- target:
15+
group: apiextensions.k8s.io
16+
version: v1
17+
kind: CustomResourceDefinition
18+
name: postgresclusters.postgres-operator.crunchydata.com
19+
path: status.yaml
1420
- target:
1521
group: apiextensions.k8s.io
1622
version: v1

build/crd/status.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Remove the zero status field included by controller-gen@v0.8.0. These zero
2+
# values conflict with the CRD controller in Kubernetes before v1.22.
3+
# - https://github.com/kubernetes-sigs/controller-tools/pull/630
4+
# - https://pr.k8s.io/100970
5+
- op: remove
6+
path: /status

config/crd/bases/postgres-operator.crunchydata.com_postgresclusters.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9406,9 +9406,3 @@ spec:
94069406
storage: true
94079407
subresources:
94089408
status: {}
9409-
status:
9410-
acceptedNames:
9411-
kind: ""
9412-
plural: ""
9413-
conditions: []
9414-
storedVersions: []

0 commit comments

Comments
 (0)