This looks like a great project, thanks very much for it.
I use Terraform to create my Kubernetes cluster and deploy services to it.
Have you considered, will you consider, creating a Terraform provider so that we can use it to script deployments to k3s?
Personally I have not had the opportunity to use terraform much, so am curious what functionality might be needed in a provider that is not already in the kubernetes provider? https://www.terraform.io/docs/providers/kubernetes/index.html
If there was a community desire for a custom provider we would certainly be willing to take community submitted PRs, but otherwise we likely doesn't have the resources to work on something like that at the moment without a clear need for it.
Currently I use Docker-Compose to simulate my application on the dev PC.
I use Terraform to deploy it to Kubernetes.
That means there's two pathways in my dev flow.
If k3s could work with Terraform then I could used it for development on my local PC and do away with Docker-Compose. I'd just have the one set of code then that I could use to deploy both locally and to the cloud, so there's less code for me to maintain.
I wish I had time to build this provider, but I don't, but still I wanted to let you know about it and I hope that someone implements.
Feel free to close this issue or leave it open if you want to continue the discussion and see if others are interested.
@ashleydavis when I get back next week, Monday, I can clean up some code that could help. The TF code I have is for a k3s instance and would need to be extended to support other clouds or be more native. It's written to be a tiny dev server, but could be a start.
All the best.
I personally dont quite understand the goal yet. Is it implementing k3s to support terraform as a cloud provider or managing the containers running on the nodes themselves?
If the the latter, terraform should be able to interact with the kube api much like it would anywhere else.
@resnostyle I use Terraform already to deploy my services to Kubernetes in the cloud. I thought k3s would be a great option for testing my application (or at least a simple version of it) on my dev PC. Currently I use Docker-Compose to bring up the application on my dev PC, but that requires maintaining a separate set of "infrastructure as code" scripts. If I could use Kubernetes both for production (k8s) and for development (k3s) then I could potentially just have a single set of Terraform scripts that cover both cases (just a dream really, not sure if it can work in practice).
The point you make about the kube api is important actually, because it would make sense that the Kubernetes Terraform provider just uses the kube api and if so that means it could already work with k3s which would be awesome.
I'll update here if I find out any new information.
I just tested the kubernetes provider and works with K3s without any modification needed (the test was extremely simple, so I can't assure the full compliance with it)
🍺 Blckh.local ➜ tf-k3s terraform apply -auto-approve
kubernetes_namespace.example: Creating...
kubernetes_namespace.example: Creation complete after 0s [id=my-first-namespace]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
🍺 Blckh.local ➜ tf-k3s k get namespaces
NAME STATUS AGE
default Active 41h
kube-node-lease Active 41h
kube-public Active 41h
kube-system Active 41h
metallb-system Active 40h
my-first-namespace Active 5s
That's awesome. I'm looking forward to trying it. Thanks for such quick responses!
@ashleydavis I cleaned this up, and currently use it as a dev burner instance for k3s in different regions; us-west-2 is hard coded. The user module is for aws specific automation used outside of the code, but I left it in case useful.
https://github.com/Ligemer/k3s/pull/1
Happy to make changes if there are suggestions or merge into the rancher codebase. For example, the --cidr=0.0.0.0/0 lines in README are not ideal. Could possibly be useful with your kube provider as mentioned above to perform a deployment.
will you consider, creating a Terraform provider so that we can use it to script deployments to k3s?
I think there's no need for a provider only to deploy to k3s, the kubernetes terraform provider does that work already, i'd rather have a provider to bootstrap/deploy k3s, pretty much like RKE provider does. That would really great.
Most helpful comment
@ashleydavis when I get back next week, Monday, I can clean up some code that could help. The TF code I have is for a k3s instance and would need to be extended to support other clouds or be more native. It's written to be a tiny dev server, but could be a start.
All the best.