New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing Kubernetes resources after cluster creation fails with "no such host" #500
Comments
Hey 👋 Looks like it's DNS propagation 😅 just to confirm could you try again but with |
|
Errrm scratch that, it actually doesn't. I just didn't wait for it to timeout, my bad. |
Ok so I tried a bunch of things and I don't think I can use that DNS server because it doesn't even resolve the Scaleway API:
Apparently fallback to the secondary DNS server doesn't work either. 🤷♂️ |
Huh that's really weird 🤔what about 1.1.1.1 ? |
Nope:
Same with Google DNS. Does this work for you? |
Now it's deleted so it doesn't work 😅 |
Oh 😄 I didn't mean that URL literally, it does start working shortly after creation (DNS propagation I guess). I meant the example from above, with Cloudflare or Google DNS, when Terraform instantly tries to access the API. |
Huh, I just created a cluster and I can resolve the URL on |
Interesting. When I create a cluster in the web UI and don't even wait for the progress indicator to finish and copy the domain, it works:
But when the cluster is created via terraform / the API and I copy the domain from the very same web UI:
😕 |
I think I see the problem. Quick solution, add:
in the It's because the cluster is first created in I'll have to think about how to manage this case 🤔 |
Ah, that makes sense. TF doesn't have any specific order of execution but the web UI instantly creates the pool. Adding a depends_on to every single resource is a pretty poor workaround though (sadly can't have it on the kubernetes provider). The solution may be to turn scaleway_k8s_pool_beta into a no-op and make it an input of scaleway_k8s_cluster_beta? resource "scaleway_k8s_pool_beta" "foo" {
name = "foo"
}
resource "scaleway_k8s_pool_beta" "bar" {
name = "bar"
}
resource "scaleway_k8s_cluster_beta" "example" {
name = "example"
pools = [
scaleway_k8s_pool_beta.foo,
scaleway_k8s_pool_beta.bar
]
} Like that? Because with how it's currently designed, TF will simply not wait for the pool to be created. |
We need a solution that's sure, the workaround is ugly 😅 though I'm not fond of the solution of giving the pools in the cluster 🤔 I'll discuss it with the team responsible for the provider next week! |
A simpler workaround may be to split the cluster logic and the k8s logic |
Sounds good! I found a much better workaround, I can just reference the pool on the Kubernetes provider and it behaves similar to depends_on: provider "kubernetes" {
load_config_file = false
host = "${scaleway_k8s_pool_beta.default.cluster_id == "" ? "" : ""}${scaleway_k8s_cluster_beta.example.kubeconfig[0].host}" # ugly hack
token = scaleway_k8s_cluster_beta.example.kubeconfig[0].token
cluster_ca_certificate = base64decode(
scaleway_k8s_cluster_beta.example.kubeconfig[0].cluster_ca_certificate
)
version = "~> 1.11"
} |
It's a bit less messy but still hacky 😅 |
Another solution not much cleaner could be resource "scaleway_k8s_cluster_beta" "example" {}
resource "scaleway_k8s_pool_beta" "default" {}
resource "null_resource" "kubeconfig" {
depends_on = [scaleway_k8s_pool_beta.default]
triggers = {
kubeconfig = scaleway_k8s_cluster_beta.example.kubeconfig[0]
}
}
provider "kubernetes" {
load_config_file = "false"
host = null_resource.kubeconfig.triggers.host
token = null_resource.kubeconfig.triggers.token
cluster_ca_certificate = base64decode(
null_resource.kubeconfig.triggers.cluster_ca_certificate
)
version = "~> 1.11"
} The null_resource can be used as an intermediate dependency and allow waiting for other resources. |
There also seems to be a similar issue with pool nodes:
This is just a data source that I use to pull the private IP: data "scaleway_instance_server" "pool_default_node_0" {
name = scaleway_k8s_pool_beta.default.nodes[0].name
} Could be that the created pool takes a moment to launch the instances so right after creation the API doesn't return any? |
Yep thtat's why. You can use the https://www.terraform.io/docs/providers/scaleway/r/k8s_pool_beta.html#wait_for_pool_ready flaf though :) |
Oh nice, thanks! |
Is this meant to be the final solution or just a temporary one? |
@jgillich I think it'll be the final one. At least until some changes are done on TF side for providers 😢 |
Creating a fresh cluster and then accessing it via the Kubernetes provider fails with a "no such host" error. It seems like there needs to be some check in place to make sure the cluster is fully created and its API is accessible.
Example:
Result:
Terraform Version
Terraform v0.12.26
The text was updated successfully, but these errors were encountered: