I'd appreciate any examples of Go and kubernetes w...
# getting-started
I'd appreciate any examples of Go and kubernetes where everything is NOT in a large single main function. I'm trying to break down this giant sucker into smaller pieces to work through if I can and have very limited time to finish this pilot test to see if I can replace a drafted helm chart. Any help would be appreciated as I'll have to go another direction if I can get my plan setup. I have more terraform + helm templating experience than Pulumi. So far I finished setting up a config file with dev input values, and will want to do a deployment + render to yaml in the next day or so. I used kube2pulumi to get started.
I can't find Pulumi K8 Go v3 option to RenderToYaml either. Is this still pending?
https://www.pulumi.com/docs/guides/adopting/from_kubernetes/#rendering-kubernetes-yaml I did this and it worked to render the deployment. Will look further at this
Ahhh. Nice. Ok, so i can break pieces up and then put these in the NewDeployment. This would let me create a seperate func for each service so I could potentionally render and test stuff easier later?
you can import them as libraries basically, so you can break things apart cleanly
and yes ComponentResources are unit testable\
Any repo with examples. I'm crunched for time unfortunately and still want to give this a shot over investing more in helm. Anything to jump start would be great. For now even just rendering the yaml and using pulumi as glorified templater would be a step forward šŸ™‚
Oh and with the renderer, is there something I can do to just render and not run deployment itself so I can do comparisons of the helm to this?
I don't mind putting this in github discussions if better too for others to benefit, whatever works. Just gonna have some small questions to work through and need to know the best avenue. thanks!
what examples are you looking for specifically?
ā€¢ I know terraform, so normally I'd use prebuitl modules. I understand that Pulumi is going to be more hands on right now with the registry being so new. ā€¢ I want to see a repo with example of breaking services into seperate functions in Go , even better if any unit testing examples included. ā€¢ I'll want to eventually run in minikube/kind locally, but for now Im just sticking with the shared cluster i have. ā€¢ I want to run pulumi up and just get the rendered yaml and not try to deploy yet so I can compare the generated yaml to the helm template rendering and make sure I'm on track.
Hopefully that helps. Stepping away. Please feel free to have me post in github so others benefit or just here, whatever is easiest for you pulumi pros šŸ™‚ Right now I'm trying to replace a CI text templating replacement approach with a code driven approach, but for now I'm trying to emulate this exact deployment (it's almost the same as a brand new helm template but has some more security features added).
unfortunately I won't have the time to put that together, but the component resource example i sent above should be a good starting point
Ok. That's honestly my biggest point of feedback as a user wanting to adopt . Lots of good examples, but definitely would love to see more including testing patterns. I'll look on github too. I also need to know if I can render the yaml without trying to deploy? I want to preview this but before I trying to deploy. I can't figure out how to do that.
renderYamltoDirectory won't do a deploy at all if that helps? only outputs the yaml
@billowy-army-68599 yes. I mean to get the rendering to run I seem to have to run
pulumi up
. refresh/preview don't seem to render the yaml.
Oh are you saying when I set the provider to have rendertoyaml as an option that overrides actually trying to deploy it?
I think i see. I need to add the renderer to the components not just deployment, looking now as I bet that's it
So far so good. NewRole for example, added
, pulumi.Provider(renderProvider))
and i think this solves the issue
worked. I like it! Now at least I can render and mature it from there, just taking a small step to confirm my yaml matches expectations. The Component stuff is a bit deep so I'm going to have to look into this plus Integration/unit testing soon too. Any resources welcomed
@billowy-army-68599 ok, now that I have yaml rendered, any idea on how pass an option to either use the renderer for yaml or go ahead and deploy? I'm going to try using pulumi directly later today so not sure if I can do both since the yaml file target is the managed resource with that provider being set. I'm assuming I can't do both and set a yaml only flag. I'm assuming I'd have to create another provider that is just the k8 target and use a switch to pick which one to pass.
the renderyaml option is designed to be used if you're doing something with a gitops executor like flux or argocd
you'd need a second provider to do the deploy directly with pulumi
I have a new config flag in yaml that is
onlyyaml: true
and when I flip it seems to be correctly identifying the change.
Let me confirm: I can't use pulumi for dual output to yaml, since it's actually managing the yaml like it would any resource. It's not really any type of "Export" but an actual managed resource. As a result I can render like I showed, but when I flip over to deploying to actual k8 I'm not going to be able to render to yaml + deploy at the same time. It's a 1 or the other option, right?
@billowy-army-68599 i put a follow-up in more long-form here to confirm I'm not missing anything else so others benefit. I'll try to post more of that on github since it's visible to all (and myself when I repeat the same questions later šŸ˜‰ )
okay, I'll take a look when i get a few mins!