Fix invalid deployment.yaml by adding missing labels
Trying to deploy the current deployment.yaml
via Flux will result in the following error
Deployment/example-nginx/nginx dry-run failed, reason: Invalid: Deployment.apps "nginx" is invalid: [spec.selector: Required value, spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`, spec.selector: Invalid value: "null": field is immutable]
This MR fixes that problem
Original error can be found on the Kustomization
object status:
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
annotations:
reconcile.fluxcd.io/requestedAt: "2023-07-12T14:39:47.514154+02:00"
creationTimestamp: "2023-07-12T12:10:58Z"
finalizers:
- finalizers.fluxcd.io
generation: 1
labels:
kustomize.toolkit.fluxcd.io/name: flux-system
kustomize.toolkit.fluxcd.io/namespace: flux-system
name: example-nginx-app
namespace: flux-system
resourceVersion: "27125"
uid: 2e582e9f-a7aa-490f-9ea7-578d819ce866
spec:
force: false
interval: 10m0s
path: ./manifests
prune: true
sourceRef:
kind: GitRepository
name: example-nginx-app
status:
conditions:
- lastTransitionTime: "2023-07-12T12:40:06Z"
message: Detecting drift for revision main@sha1:6d70029806b346506a32d5de6d6a144b859f2749
with a timeout of 9m30s
observedGeneration: 1
reason: ProgressingWithRetry
status: "True"
type: Reconciling
- lastTransitionTime: "2023-07-12T12:40:06Z"
message: |
Deployment/example-nginx/nginx dry-run failed, reason: Invalid: Deployment.apps "nginx" is invalid: [spec.selector: Required value, spec.template.metadata.labels: Invalid value: map[string]string(nil): `selector` does not match template `labels`, spec.selector: Invalid value: "null": field is immutable]
observedGeneration: 1
reason: ReconciliationFailed
status: "False"
type: Ready
inventory:
entries:
- id: _example-nginx__Namespace
v: v1
- id: example-nginx_nginx_apps_Deployment
v: v1
lastAppliedRevision: main@sha1:52752d7b6c9fceeb94ba8714674db565955cadbc
lastAttemptedRevision: main@sha1:6d70029806b346506a32d5de6d6a144b859f2749
lastHandledReconcileAt: "2023-07-12T14:39:47.514154+02:00"
observedGeneration: 1