Hi everyone! I’ve been toying around with Pulumi f...
# general
b
Hi everyone! I’ve been toying around with Pulumi for a while trying to decide if it would work for my organization. But there’s one thing really important thing that I can’t figure out how to do. I’d like to create an npm package for other developers to import into their repos that has an abstracted Kubernetes application. I’m picturing creating a Component Resource class that takes in some kind of configuration and makes a deployment/service/whatever. That much I’ve got. But I also want to be able to import that class, create an object from it, and be able to customize any additional fields that I didn’t happen to put in the config. For example, if someone wants to change the serviceAccountName of the podSpec for a deployment, I don’t want to have to go back and add that to the config. I want them to be able to modify it once it has be instantiated. Am I missing an easy way to do this?
m
Pulumi allows you to create Custom Component Resources that take custom arguments and extend existing components / their properties. You can then package it up using the standards of that languages ecosystem for distribution, and the teams can use your custom / extended resource declarations. • https://www.pulumi.com/docs/intro/concepts/resources/components/https://www.pulumi.com/docs/guides/pulumi-packages/
Pulumi Packages are new, and than the simple case of writing and packaging a Custom Component Resource. Here's an example of a basic Custom Resource Component in Javascript https://github.com/pulumi/examples/blob/master/aws-js-s3-folder-component/s3folder.js
b
@brash-dream-38657 you can use transformations to modify any resource (including a component resource): https://www.pulumi.com/docs/intro/concepts/resources/options/transformations/ What this means in practice is that you can create your own custom abstractions (a component) and expose values via the input arguments, but if you miss anything out, the downstream users can simply import your package and "transform" it as needed
✔️ 1
m
Really good call-out jaxxstorm
b
this is used very often on the helm
chart
resource which is a ComponentResource itself: https://www.pulumi.com/registry/packages/kubernetes/api-docs/helm/v3/chart/#chart-with-transformations
b
ah, ok. I think that ‘chart with transformations’ example is exactly what I need. I toyed around with transformations for a bit, but this example will help. Thanks so much!