Expected Outcome
After completing this procedure, the Terraform Enterprise container will have a host mapping that resolves its own hostname to the private IP address of the instance, enabling hairpin addressing.
Prerequisites
- An existing Terraform Enterprise installation using Flexible Deployment Options with Podman.
Use Case
This procedure is for users who are migrating from a Replicated installation to Flexible Deployment Options and need to enable the equivalent of hairpin_addressing for the main Terraform Enterprise application container.
Procedure
-
Edit the Kubernetes
YAMLfile for your Terraform Enterprise Pod and add ahostAliasesblock under the Podspec. This block maps the TFE hostname to the private IP address of the node. -
---
apiVersion: "v1"
kind: "Pod"
...
spec:
hostAliases:
- ip: "<private_ip_of_the_node>"
hostnames: ["<TFE hostname e.g. terraform.example.com>"] -
Restart the Terraform Enterprise Pod to apply the changes. If you have configured Terraform Enterprise to run as a
systemdservice, use the standard service commands. Otherwise, restart it manually withpodman.## Stop the existing Pod # podman kube down <path_to_YAML_file> ## Start the Pod with the updated configuration # podman kube play <path_to_YAML_file> -
Verify that the host mapping was successfully applied by inspecting the Pod's configuration. The output should show the added hostname and IP address.
# podman pod inspect terraform-enterprise -f '{{.InfraConfig.HostAdd}}' ## Output should be similar to: ## [terraform.example.com:10.240.100.10] -
Alternatively, you can verify the change by checking the container's
/etc/hostsfile.
Additional Information
To enable hairpin_addressing for Terraform runs executed by agents, you must set the TFE_RUN_PIPELINE_DOCKER_EXTRA_HOSTS environment variable. This setting applies the extra_hosts configuration to the agent containers.