Deploying Kubernetes Clusters in Increasingly Absurd Languages

Deploying Kubernetes Clusters in Increasingly Absurd Languages

It’s been over three years since I revealed my maximum a success weblog publish concerning the abject horror of templated yaml and in some ways, I think the similar means now as I did then, except falling out of affection with jsonnet. Jsonnet looked like a excellent device for the task when I used to be the use of Go templates to take a look at and get effects, however in 2022 there are many other mechanisms you’ll be able to use to keep away from YAML templating hell. Today, we at Pulumi introduced YAML fortify. You may well be questioning, “Lee, don’t you fucking hate YAML? Isn’t that your entire factor?” Well, hell has frozen over and Pulumi helps YAML now. So as an alternative of bemoaning this reality, why don’t be lean into this and notice what sort of depressing enjoy we will be able to create for ourselves? Pulumi’s YAML compiler When YAML fortify was once added, enterprising CUE fan, pal and colleague David Flanagan used the Pulumi hackathon so as to add a mechanism to mechanically convert CUE manifests into YAML paperwork and pipe them without delay into the Pulumi CLI. This talent to make use of exported CUE was once to begin with added without delay to the YAML language plugin, however challenge lead Aaron Friel took David’s inspiration and added the aptitude to make use of any “compiler” that spits out YAML. It seems a bit of like this: identify: my-yaml-program runtime: identify: yaml choices: compiler: # just about anything that emits yaml to stdout description: A YAML instance Now, I’m positive Aaron’s intent was once sure, however this gave me an concept: simply how a lot are we able to abuse this? JSON and the YAMLnauts It’s value remembering that YAML is a superset of JSON, so any legitimate JSON could also be legitimate YAML. With that firmly tucked into my thoughts, I set about seeing what I may do with this new YAML enter mechanism. Note: The asciicasts following handiest display the preview level, as a result of AWS doesn’t price you time and takes 10ish mins to provision an EKS cluster. I did run every instance and so they paintings, sadly. HCL Note: The code for the HCL instance may also be discovered right here My first concept was once that HCL was once an glaring candidate to creator Pulumi techniques, in spite of everything, it’s already used to deploy infrastructure. I began with brew set up hcl2json to get the hcl2json device and got here up with this: assets = { cluster = { sort = “eks:Cluster” houses = { vpcId = “${vpcId}” subnetIds = “${subnetIds}” instanceType = “t2.medium” desiredCapacity = 2 minSize = 1 maxSize = 2 } } } variables = { subnetIds = { “Fn::Invoke” = { Arguments = { vpcId = “${vpcId}” } Function = “aws:ec2:getSubnetIds” Return = “ids” } } vpcId = { “Fn::Invoke” = { Arguments = { default = true } Function = “aws:ec2:getVpc” Return = “identification” } } } outputs = { kubeconfig = “${cluster.kubeconfig}” } I to begin with bumped into an issue with my first cross as a result of HCL gadgets and blocks are remarkably equivalent so my preliminary try at provisioning my EKS cluster wasn’t running. I requested Aaron for some assist, he joined the zoom and right away stated “oh god” which I regarded as to be a excellent signal. After ironing out the syntax problems with some assist from Aaron, I outlined my Pulumi.yaml to make use of hcl2json as a converter: identify: hcl runtime: identify:…

Like to keep reading?

This article first appeared on leebriggs.co.uk. If you'd like to keep reading, follow the white rabbit.

View Full Article

Leave a Reply