kuberneteshpa

unable to parse YAML: error converting YAML to JSON: did not find expected key on line "advanced" field


The build is throwing error:- did not find the expected key on line "advanced" field Below is the yaml file snipped that i have written

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: {{ .Values.service.name }}-sqs
spec:
  scaleTargetRef:
    name: {{ .Values.service.name }}
  minReplicaCount: {{ .Values.hpa.minReplicaCount }}
  maxReplicaCount: {{ .Values.hpa.maxReplicaCount }}
  fallback:
    failureThreshold: 3
    replicas: {{ .Values.hpa.minReplicaCount }}
  advanced:
    behavior:
      scaleDown:
        stabilizationWindowSeconds: {{ .Values.hpa.scaleDown.stabilizationWindowSeconds}} 
        policies:
{{ toYaml .Values.hpa.scaleDown.policies | indent 6 }}
      scaleUp:
        stabilizationWindowSeconds: {{ .Values.hpa.scaleUp.stabilizationWindowSeconds}}  
        policies:
{{ toYaml .Values.hpa.scaleUp.policies | indent 6 }}
        selectPolicy: {{ .Values.hpa.selectPolicyForScaleUp}} ```

Solution

  • There are some formatting and indentation issues in the yaml file you have provided as said by Rafał Leszko. You can use helm lint for validating your charts before deploying them. Helm Linter will validate your chart syntax and pints out all the errors, warnings and info which will break your code from working.(Source: Helm docs)