Argo CD Application Sync Fails with “invalid Kustomization: yaml: mapping values are not allowed in this context”
search cancel

Argo CD Application Sync Fails with “invalid Kustomization: yaml: mapping values are not allowed in this context”

book

Article ID: 423300

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service

Issue/Introduction

  • Creating or syncing an application in Argo CD fails with following error message:

The Kubernetes API could not find version "v1beta1" of kustomize.config.k8s.io/Kustomization for requested resource <namespace>/<application-name>.Version "v1" of kustomize.toolkit.fluxcd.io/Kustomization is installed on the destination cluster.

  • Logs from argocd-server will show entries similar to: 

kubectl logs argocd-server-xxxxx -n <argocd-namespace>

time="<timestamp>" level=error msg="finished unary call with code Unknown"error="rpc error: code = Unknown desc = kustomize build <cached-source-path>/kustomize-<repo>/overlays/<environment> failed exit status 1:Error: accumulating resources: accumulation err='accumulating resources from ../../base':'<cached-source-path>/kustomize-<repo>/base' must resolve to a file:
invalid Kustomization: yaml: line <line-number>: mapping values are not allowed in this context"
grpc.code=Unknown grpc.method=<grpc-method> grpc.service=<grpc-service>
grpc.start_time="<timestamp>" grpc.time_ms=<duration> span.kind=server system=grpc

Environment

VMware vSphere Kubernetes Service
ArgoCD Service

Cause

kustomization.yaml file had leading spaces before top-level keys, causing Kustomize to fail parsing the file.

Resolution

Remove leading spaces from top-level YAML keys.

Invalid YAML:

apiVersion: kustomize.config.k8s.io/v1beta1

  kind: Kustomization

  resources:

  - hello-kube-ns.yaml

  - hello-kube-deploy.yaml

  - hello-kube-svc.yaml

Valid YAML:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - hello-kube-ns.yaml
  - hello-kube-deploy.yaml
  - hello-kube-svc.yaml

Additional Information

Argo CD - Declarative GitOps CD for Kubernetes

The Kustomization File