Switch to not including trailing period in root domain.

This commit is contained in:
Tom Alexander 2025-03-22 21:23:05 -04:00
parent 9d0acdac13
commit b576d44af0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 8 additions and 10 deletions

@ -88,8 +88,8 @@ gcloud auth application-default login
Then go into the `terraform` folder and apply the configuration. We need to apply the config in two phases via the `cluster_exists` variable because the kubernetes terraform provider does not have native support for the Gateway API and the `kubernetes_manifest` terraform resource [has a shortcoming that requires the cluster exists at plan time](https://github.com/hashicorp/terraform-provider-kubernetes/issues/1775).
```
terraform apply -var dns_root="k8sdemo.mydomain.example." -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=false
terraform apply -var dns_root="k8sdemo.mydomain.example." -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=true
terraform apply -var dns_root="k8sdemo.mydomain.example" -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=false
terraform apply -var dns_root="k8sdemo.mydomain.example" -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=true
```
Please note that this will exceed the default quotas on new Google Cloud projects. The terraform configuration will automatically put in requests for quota increases but they can take multiple days to be approved or denied. You should be able to fit 3 clusters in the default quota until then.
@ -279,7 +279,7 @@ But that doesn't mean that we need to use the valuable RFC-1918 IP address space
To demonstrate, we can apply the terraform config again but with the `enable_snat=true` variable set:
```
terraform apply -var dns_root="k8sdemo.mydomain.example." -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=true -var enable_snat=true
terraform apply -var dns_root="k8sdemo.mydomain.example" -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=true -var enable_snat=true
```
Then in our kubernetes pod, we can run the `curl` again:
@ -311,6 +311,6 @@ Clean Up
Just like we did a 2-stage apply by toggling the `cluster_exists` variable, we will need to do a 2-stage destroy. First we tear down any kubernetes resources by running *apply* with the `cluster_exists` variable set to `false`. Then we can destroy the entire project.
```
terraform apply -var dns_root="k8sdemo.mydomain.example." -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=false
terraform destroy -var dns_root="k8sdemo.mydomain.example." -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=false
terraform apply -var dns_root="k8sdemo.mydomain.example" -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=false
terraform destroy -var dns_root="k8sdemo.mydomain.example" -var quota_email="MrManager@mydomain.example" -var quota_justification="Explain why you need quotas increased here." -var cluster_exists=false
```

@ -1,7 +1,5 @@
# TODO: Switch to not requiring trailing period?
variable "dns_root" {
description = "DNS domain root with trailing period. Example: \"foo.bar.com.\""
description = "DNS domain root. Example: \"k8sdemo.mydomain.example\""
type = string
}
@ -9,7 +7,7 @@ variable "dns_root" {
resource "google_dns_managed_zone" "zone" {
project = google_project.project.project_id
name = "dns-zone"
dns_name = var.dns_root
dns_name = "${var.dns_root}."
depends_on = [google_project_service.service["dns"], ]
}

@ -21,7 +21,7 @@ locals {
# }
# resource "google_cloud_quotas_quota_preference" "public_ip_per_project_region" {
# count = var.quota_email == null ? 0 : 1
# count = var.quota_email == null && var.public_ingress == true ? 0 : 1
# parent = "projects/${google_project.project.project_id}"
# name = "compute-IN-USE-ADDRESSES-per-project-region"
# dimensions = { region = var.region }