I have kubernetes configuration in a seperate yaml file. I want to use that yaml file while running terraform can I do it? If yes, then how.
According to my experience, Terraform supports the Kubernetes provider, but all the things in that provider are separate, such as deployment, pod, service and etc. It does not provide a way to load all the things from a configuration file.
So, to deploy from the configuration file, I recommend you put the kubectl apply -f config_file
in the null_resource
. And it's also simple to delete all the things that have deployed with multiple mull_resource, you just need to use the Terraform command terraform destroy
, it will remove all the resources that deployed through the Terraform file.
As far as I know this has been talked about for quite some time but as of yet hasn't been implemented: https://github.com/terraform-providers/terraform-provider-kubernetes/issues/141
If it helps, I often use this tool to convert YAML files to terraform specification. It is quite reliable. https://github.com/sl1pm4t/k2tf