News for hackers. Stuff that matters.
Re:Ask HN: If Kubernetes is the solution, why are there so m... by jrx on Wednesday June 01, 2022 @01:46PM (#31585428)
The question is: what tool to use? I'm a solo developer running a very small kube cluster for my hobby project. I very much wanted to have a declarative version controlled state of my cluster. Every time I try googling solutions I get flooded with some enterprise Saas offerings that do nothing I want.

I managed my stateful sets/services for a while with terraform, but my experience was absolutely terrible and I have stopped that eventually. I now use "kubectl patch" and "kubectl apply" with handwritten yaml, but the workflow feels very clunky.

Intuitively it seems obvious to me that there must be a tool helping with that, but for some reason I was absolutely not able to find anything that would be even a little bit helpful. I am considering writing a couple python scripts that will automate it.

Re:Ask HN: If Kubernetes is the solution, why are there so m... by kube-system on Wednesday June 01, 2022 @05:25PM (#31588352)
kubectl apply on a directory full of yaml works fairly well for small stuff. Check it into git and it's version controlled.

If you need something more flexible than that, try making your own helm chart. Helm will give you some text templating, pre and post hooks, some basic functions, and some versioning and rollback functionality.

You can start simple by just pasting in your existing k8s yaml, and then just pull out the pieces you need into variables in your values file. If you need to change an image version, then you just update the variable and `helm upgrade mychart ./mychart`

Re:Ask HN: If Kubernetes is the solution, why are there so m... by throwaway894345 on Wednesday June 01, 2022 @09:09PM (#31590147)
kubectl apply on a directory doesn’t work because deleting a resource manifest won’t delete the corresponding resources.
Re:Ask HN: If Kubernetes is the solution, why are there so m... by kube-system on Thursday June 02, 2022 @12:00AM (#31591177)
It does work, as long as you’re not deleting anything. :) That might be good enough for a “very small kube cluster for my hobby project”

I only use ‘kubectl apply’ for small stuff where I only have a couple resources. Anything more complicated and a tool like helm is much more useful.

Re:Ask HN: If Kubernetes is the solution, why are there so m... by bavell on Wednesday June 01, 2022 @10:50PM (#31590727)
'kubectl delete -f dir/' will delete all resources in the directory.
Re:Ask HN: If Kubernetes is the solution, why are there so m... by throwaway894345 on Thursday June 02, 2022 @12:19AM (#31591299)
Right, but the only resource you want to delete is no longer in that directory, so you’ve now deleted every resource you except the one you actually wanted to delete. :)
Re:Ask HN: If Kubernetes is the solution, why are there so m... by bavell on Saturday June 04, 2022 @10:20AM (#31620615)
Ah, I slightly misunderstood. Still, you should always have your manifests under version control so this shouldn't ever be a problem :)
Re:Ask HN: If Kubernetes is the solution, why are there so m... by lukeschlather on Wednesday June 01, 2022 @04:58PM (#31588007)
I'm a fan of emrichen, but simple text templating (Jinja) works almost as well. (j2cli means you can just provide a yaml file with per-stage configs.)
Re:Ask HN: If Kubernetes is the solution, why are there so m... by edude03 on Wednesday June 01, 2022 @02:41PM (#31586262)
Fluxcd, or argo CD if you want a nice UI