Reputation: 11
I have a azure devops pipeline to deploy my helm chart to Kubernetes cluster. In helm upgrade command I have specified --post-renderer which runs a script
This script runs command
kubectl kustomize ./
kustomization.yaml contents
resources:
- deployment.yml
patches:
- target:
kind: Deployment
path: set_affinitytolerations.yml
While running the pipeline I can see the error
error: accumulating resources: accumulating resources from 'deployment.yml': MalformedYAMLError: yaml: line 3: did not find expected key in File: deployment.yml
Is there any way I can print the input deployment.yaml file being fed to kustomize
I am using
Client Version: v1.32.0
Kustomize Version: v5.5.0
Server Version: v1.26.10+rke2r2
I checked command line options available for for kustomize by running
kubectl kustomize --help
But couldn't find any option
Upvotes: 1
Views: 110
Reputation: 385
Kustomize itself doesn't have a built-in print input files
option.
However, You can try this workaround that might work in your case :
post-render
script. This approach uses cat to print the content of your deployment.yml
and set\_affinitytolerations.yml
files directly after they've been rendered.#!/bin/bash
# Print the contents of the deployment.yml before kustomize
echo "Contents of deployment.yml"
cat ./templates/deployment.yml
# Print the contents of affinitytolerations.yml before kustomize
echo "Contents of affinitytolerations.yml"
cat ./templates/set_affinitytolerations.yml
kubectl kustomize ./
Notes : Make sure to edit the correct path in cat
where your files are located.
post-render
script. Run this command directly just to view the output of deployment instead of helm upgrade../post-renderer.sh
You might also want to debug the issue you encountered: MalformedYAMLError: yaml: line 3: did not find expected key in File: deployment.yml
. It indicates that the deployment.yml
file has a syntax error pointing to line 3 of your deployment.yml
file. This could be due to missing key, incorrect indentation or formatting issues YAML is very sensitive to formatting and indentation even a small mistake can cause issues.
I suggest looking for Syntax issues such as:
Indentation: ensure you're using two spaces per level (not tabs).
Missing or extra colon, hyphen, or quote.
Data type mismatches
For further information you can check this documentation : https://helm.sh/docs/chart_template_guide/debugging/
Upvotes: 1