From 254052d79857406a13fe7295f424786cd1ef38c3 Mon Sep 17 00:00:00 2001 From: tusuii Date: Fri, 27 Feb 2026 23:08:36 +0530 Subject: [PATCH] fix: set storageClassName=local-path in PVC patch to match live cluster MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit kubectl apply computes a 3-way merge. The base PVC has no storageClassName (nil), but the already-bound PVC in the cluster has storageClassName=local-path. This diff caused apply to attempt a mutation on a bound PVC — forbidden by k8s. Fix: patch the PVC with storageClassName=local-path so desired state matches live state and apply produces no diff on the PVC. Co-Authored-By: Claude Sonnet 4.6 --- k8s/overlays/on-premise/kustomization.yaml | 13 +++++++++---- k8s/overlays/on-premise/mysql-pvc-patch.yaml | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/k8s/overlays/on-premise/kustomization.yaml b/k8s/overlays/on-premise/kustomization.yaml index f0e5a46..b526219 100644 --- a/k8s/overlays/on-premise/kustomization.yaml +++ b/k8s/overlays/on-premise/kustomization.yaml @@ -19,10 +19,15 @@ resources: - ../../base - ingress.yaml -# NOTE: mysql-pv.yaml and mysql-pvc-patch.yaml are only needed on clusters -# without a default StorageClass. This cluster uses 'local-path' (dynamic -# provisioner), so the base PVC works as-is and must NOT be patched after -# it is already bound. +patches: + # This patch explicitly sets storageClassName: local-path to match the live + # PVC in the cluster. Without it, the base PVC (no storageClassName = nil) + # diffs against the existing "local-path" value and kubectl apply tries to + # mutate a bound PVC, which Kubernetes forbids. + - path: mysql-pvc-patch.yaml + target: + kind: PersistentVolumeClaim + name: mysql-data-pvc images: - name: scrum-frontend diff --git a/k8s/overlays/on-premise/mysql-pvc-patch.yaml b/k8s/overlays/on-premise/mysql-pvc-patch.yaml index 592d580..498a650 100644 --- a/k8s/overlays/on-premise/mysql-pvc-patch.yaml +++ b/k8s/overlays/on-premise/mysql-pvc-patch.yaml @@ -3,8 +3,10 @@ kind: PersistentVolumeClaim metadata: name: mysql-data-pvc spec: - storageClassName: manual - volumeName: mysql-pv + # Must explicitly match the storageClassName already on the live PVC. + # Without this, kubectl apply diffs nil (base has no field) vs "local-path" + # (cluster) and tries to mutate a bound PVC — which Kubernetes forbids. + storageClassName: local-path accessModes: - ReadWriteOnce resources: