Had some spare time, so I’ve tried to learn a bit more about Helm, the package manager for Kubernetes.
I’ve decided to follow the relatively new Pluralsight course called – Kubernetes Package Administration with Helm, done by my MVP colleague Andrew Pruski. And it was great – not too long, clear and easy to follow, with only a handful of prerequisites if you want to follow along! Great job!
Of course, there is also the nice, official documentation.
But why am I writing this post?
I was normally following this course on my Windows 10 laptop, using Visual Studio Code, as suggested, and also using PowerShell terminal, with Helm v3.3.1.
It all went well until the part when we are creating our Helm Chart, more specifically – when we’re filling up our deployment.yaml and service.yaml files. Suggested (and simplest) method is to use the simple output redirection (with “>“), like this:
1 |
kubectl create deployment nginx --image=nginx --dry-run=client --output=yaml > .\ourchart\templates\deployment.yaml |
But, this gave me the following error when trying to deploy the chart:
1 2 |
helm install ourchart .\ourchart # Error: unable to build kubernetes objects from release manifest: error parsing : error converting YAML to JSON: yaml: invalid leading UTF-8 octet |
It’s quite obvious – Helm works with UTF-8, and my .yaml files seem to be encoded differently. Quick look at the bottom of my VSCode confirms it:
How can I fix it?
As I’m using PowerShell, it’s pretty easy – instead of doing the simple output redirection (“>“), I pipe output to Out-File cmdlet with -Encoding UTF8 option, in all cases, which takes care of the encoding (and sets it to UTF-8 with BOM, which is just fine for Helm):
1 |
kubectl create deployment nginx --image=nginx --dry-run=client --output=yaml | Out-File .\ourchart\templates\deployment.yaml -Encoding UTF8 |
So, long story short – if you run into the error above (“Error: unable to build kubernetes objects from release manifest: error parsing : error converting YAML to JSON: yaml: invalid leading UTF-8 octet”), remember to check your file’s encoding (and change it to UTF-8, if needed)! 🙂
Cheers!
P.S. Thanks to good people at Pluralsight for providing me a complimentary subscription!
Thank for this. It was the first article after googling the Helm error I face while in the same exact Pluralsight course. Saved me a ton of time….
You’re welcome! Thanks for feedback!
Thank you!
Glad it helped!
Solved my problem four years later – thank you!
Glad it helped (still)! 😊
Cheers,
Tom