By kickthemooon
I have a simple Terraform definition of a kubernetes cluster and a load balancer that will point to the kubernetes nodes by tag.
resource "digitalocean_kubernetes_cluster" "cluster" {
name = "cluster"
region = "fra1"
version = "1.20.2-do.0"
node_pool {
name = "worker-pool"
size = "s-2vcpu-2gb"
node_count = 3
tags = [var.worker_node_tag]
}
}
resource "digitalocean_loadbalancer" "load_balancer" {
name = "loadbalancer"
region = "fra1"
forwarding_rule {
entry_port = 80
entry_protocol = "http"
target_port = 80
target_protocol = "http"
}
healthcheck {
port = 22
protocol = "tcp"
}
droplet_tag = var.worker_node_tag
depends_on = [
digitalocean_kubernetes_cluster.cluster
]
}
Unfortunately when I do terraform apply the first time I get this error when terraform tries to create the load balancer
Error: Error creating Load Balancer: POST https://api.digitalocean.com/v2/load_balancers: 422 (request "a1601575-6f25-4b38-bf39-cab1c182aa44") some of the specified target droplets don't belong to the same VPC as the Load Balancer
Then I wait for a few minutes, do plan and apply again and viola the load balancer gets created…
So from my understanding there seems to be a delay with the nodes networking…
Is there anyway I can do terraform apply only once?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I used a timeout as a workaround
resource "time_sleep" "wait" {
depends_on = [
digitalocean_kubernetes_cluster.cluster
]
create_duration = "360s"
}
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.