简体   繁体   中英

How can I migrate an ingress from an helm chart to terraform without deleting the resource during deployment

I have a custom application helm chart with an ingress object which is deployed in production. Now I need to migrate the ingress source code object from the helm chart to terraform to give control over the object to another team. Technically no problem with accepting a downtime. But I want to keep the ingress object from being undeployed by the helm chart during deployment as there is a letsencrypt certificate attached to it.

So is there a possibility to tell helm to keep the ingress object when I remove the ingress in the source of the helm chart during helm upgrade?

found the answer myself in the helm anntotations. https://helm.sh/docs/howto/charts_tips_and_tricks/#tell-helm-not-to-uninstall-a-resource

That mean's you deploy the ingress again via helm chart with the annotation "helm.sh/resource-policy": keep. Then you remove the ingress from the helm chart and redeploy it. Now the ingress is still deployed in kubernetes but not anymore under control of the helm release. Next step is to model/code the ingress in terraform and import the resource via terraform import. Last step is to test with terraform plan if the imported resource corresponds completely with the coded ingress in terraform

That's it.

You can just keep the helm chart as it is and add details into the terraform, I think it will work.

Terraform will run the plan and apply the helm release and if you set helm config to roll out , in that case, if No changes there no update will get applied to resources like ingress, deployment etc.

With terraform, you can use the Helm provider: https://registry.terraform.io/providers/hashicorp/helm/latest/docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM