-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
dial tcp 127.0.0.1:80: connect: connection refused #2007
Comments
I have the same issue but when I work with state with another AWS user , I'm got error like
|
Would you try replacing I guess |
not quite true - if the data source fails to find a result, its a failure not indeterminate. @ArchiFleKs you shouldn't need the data source at all; does this still present the same issue? provider "kubernetes" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
command = "aws"
# This requires the awscli to be installed locally where Terraform is executed
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_id]
}
} |
you cant run these in tf cloud though, cause of the local exec |
This is just merely pointing to what the Kubernetes provider documentation specifies. The module doesn't have any influence over this aspect |
I can confirm that this snippet works as expected without the datasource:
|
I know Hashi are hiring and have made some hires to start offering more support to the Kubernetes and Helm providers recently so hopefully some of these quirks get resolved soon! for now, we can just keep sharing what others have found to have worked for their setups 🤷🏽♂️ |
Unfortunately, it doesn't seem to work with tf-cloud (it gets the |
Apparently using kubectl provider instead of kubernetes provider (even completely removing it) made it work with terraform-cloud 🤷♀️ :
but unfortunately this got the previously working aws-auth deleted and was not able to create one |
I just ran into this while debugging an issue during redeployment of a cluster. I'm not sure exactly how it happened, but we ended up in a state where the cluster had been destroyed, which caused terraform to not be able to connect to the cluster (duh...) using the provider and such defaulted to 120.0.0.1 when trying to touch the config map... As mentioned, I'm not sure exactly how it ended up in that state, but it got so bad that I'd get this Maybe not applicable to most of you, but hopefully it's useful for someone in the future :D |
hey all - let me know if its still worthwhile to leave this issue open. I don't think there is anything further we can do here in this module to help alleviate any of the issues shown - there seems to be some variability in terms of what works or does not work for folks. I might be biased, but I think the best place to look at sourcing some improvements/resolution would be upstream with the other providers (Kubernetes, Helm, Kubectl, etc.) |
I'm also experiencing this, in the meantime are there any work arounds? Im experiencing the same problem with the latest version. Initial creation of cluster worked fine but trying to update any resources after creation i get the same error.
Same as the example below except i had multiple profiles on my machine and had to specify the profile.
|
Faced the same, then checked state using
And that helped to resolve the issue. |
The previous suggestions didin't work for me (maybe i misunderstood something)
This kubeconfig does not appear to exist in my current path...
The latest version of this example and module does not use a datasource, instead just uses i ended up deleting the aws_auth from the state, it allowed me to continue/resolve the connection refused problem.
I don't know what the implications of rm'ing this state has, is it safe to keep removing this state whenever we encounter this error?. |
a brand new cluster and tf state, eks 1.22
leads to:
any ideas @bryantbiggs ? |
@FernandoMiguel I'm seeing something similar in a configuration I'm working with. After some time of thought I believe you'll need to add the Assumed role to your configuration
Sadly this isn't a solution for me. The configuration I'm working with uses dynamic credentials fed in. Something along the lines...
This is useful if doing something where a temporary vm or container or tfe is running the terraform execution Going down this route the provider is getting fed the information for connection and used entirely within the provider context (no aws config process was ever used). The problem is none of that data is stored or carried over, so when the @FernandoMiguel it looks like your are presumably using a |
No config and no aws creds hardcoded. |
If you mean the cli exec, that's running from aws-vault exec --server |
@FernandoMiguel Hmm well that's interesting. I was able to get a solution to work for me.
This seemed to work for me, but I also had to expose my endpoint to be public for the first run. Our network configuration was locked down too tightly for our remote execution server to hit the endpoint. That could be something else you make sure you are hitting.
What I meant was if credentials are being passed to the If my guess it correct than a way around it would be creating a The thought process I am having is the data being passed into the kubernetes provider contains no information about aws configuration. So I would expect it to fail if the instance running the terraform didn't have the aws cli configured. Further thought if the remote execution tool being used doesn't have an ~/.aws/config but running inside an instance with an IAM role attached to it. Then it would default to that IAM role, so then it could still work as long as that IAM role has the ability to assume the role. |
@bryantbiggs I think the thought process I had from above just reassures your comment. I don't think there is anything in this module that can be done to fix this. I do have a suggestion of not completely remove the aws_auth_configmap_yaml output unless you have other solutions coming up. The reasoning is I could see a use case where terraform is ran to provision private cluster which may or may not be running on an instance that can reach that endpoint. If it isn't the aws_auth_configmap_yaml can be used in a completely separate process to hit the private cluster endpoint. It all depends on how separation of duties may come into play (a person to provision, and maybe a person to configure). It's just a thought. |
I would love to know what isn't working here. If we were to keep the now deprecated output, I can at least revert my internal PR and keep using that old and terrible null exec code to patch the config map. |
The problem might be the terraform-provider-kubernetes and not terraform-aws-eks, eg. hashicorp/terraform-provider-kubernetes#1479, ... more about localhost connection refused. This one can really be difficult to catch. |
@tanvp112 you are onto something there we have this provider |
So my issue was with authentication, and I believe this example clearly states the issue. The example state that you must set
I haven't gotten to try this myself, but it should work. The AWS_SESSION_TOKEN would only be needed for an assumed role process, but it could possibly work. |
I honestly don't know what you are trying to do... |
When you assume a role your retrieve an temporary access key, secret key, and token. My code snippet is an example for when a user is running things in a jobbed off process inside of a container. Where the container contains no context for AWS (no When the aws provider is used the configuration information is is passed into the provider for this example.
In this instance the AWS Provider has all information passed in and using the Provider Configuration method. On this run no local aws config file or environment variables exist, so it needs this to make any aws connection. All aws resources create successfully in this process, besides that aws-auth configmap, when using the suggested example.
The reason this is failing is the Kubernetes provider has no context on what you use for the aws command because no config or environment variables are being used. Therefore this will fail
That is how the suggested route came to be.
In this provider block it is purposely passing in the required credential/configuration needed for the aws cli to successfully call @FernandoMiguel does this make sense on what I was trying to attain now? This may not be your use case, but it is useful information for anyone trying to run this module using some external remote execution tool. I'm going to add this module does not contain the issue, but adding the above snippet to the documentation may help out those that may be purposely providing configuration to the aws provider vs utilizing Environment variables or local config files. |
it does. I've been fighting issued using the kube provider for weeks with what seems a race condition or failed to initialise endpoint/creds. |
I was having the same issue but the solution that worked for me is to configure the kubernetes provider to use the role, something like this:
|
Ohh that's an interesting option... Need to try that |
|
@bcarranza actually the error keeps the same until I have to destroy and recreate, the more strange part is that the |
Hi @adiii717 , In my case I can't destroy the cluster, because even though it happens to me in an early environment, I don't want to imagine this happening in production, so I have to find a solution without destroying the cluster, as a preventive measure if this happens in production. |
This is such a frustrating issue having to do crazy workarounds to get the auth mechanism to work. Only an issue when certain changes to the EKS cluster that cause data sources to be empty. |
This issue has been automatically marked as stale because it has been open 30 days |
This is still a major issue. |
This isn't a module issue. This is at the provider level; there isn't anything we can do here |
I am getting below error while if i touch/change/comment/update anything on cluster_security_group_description = "Short Description"
Any solution for this? Thanks! |
Hello, Regarding this problem, I also had this problem and found a workaround. This is the content of the .tf file used to instantiate the kubernetes providers : data "external" "aws_eks_cluster" { provider "kubernetes" { The same configuration can be applied to kubectl and helm providers. I know that External Data Source is not recommended as it's a bypass to the terraform state, but in this case it's very useful. |
That is entirely inaccurate. The kubernetes/helm/kubectl providers will always need a clusters certificate and endpoint, in some shape or form, which are not values that you can know before the cluster comes into existence |
My bad. What I was trying to say is that after the cluster is created, I will not depend on "know after applying" in case of changes in the EKS control plane. If the cluster does not exist of course, I cannot retrieve the EKS cluster endpoint and certificate. That's why I said, "If this datasource fails (usually when I create a new cluster), it switches to the default EKS datasource." That's why I have this condition: |
Thank you @mesobreira and @bryantbiggs. I will try this solution. |
Same issue here, i could create without any issue the clusters and modify it. I already try a lot of changes. Always the same issue. │ Error: Get "http://localhost/api/v1/namespaces/kube-system/configmaps/aws-auth": dial tcp [::1]:80: connect: connection refused |
@csepulveda, have you tried to use external data source, as I mentioned above ? |
I really do not understand what the issue is with terraform.
Using the data will not provide the information to the provider, despite the information clearly are in state file and are correct. Why the variables are not provided to provider ??
|
This issue has been automatically marked as stale because it has been open 30 days |
Was getting this error:
|
How do you mean static values? |
Previously had something along the lines of:
Based on some of the comments above, decided to use pre-set values so used variables and that got rid of the error. |
Same error here using Terragrunt. Everytime i have to upgrade k8s version i have to delete
|
This issue has been automatically marked as stale because it has been open 30 days |
This issue was automatically closed because of stale in 10 days |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
I know there are numerous issues (#817) related to this problem, but since v18.20.1 reintroduced the management of configmap thought we could discuss in a new one because the old ones are closed.
The behavior is till very weird. I updated my module to use the configmap management feature and the first run went fine (was using the
aws_eks_cluster_auth
datasource. When I run the module with no change I have no error either inplan
orapply
.I then tried to update my cluster form v1.21 to v1.22 and then plan and apply began to
fail
with the following well know error:I then moved to the exec plugin as recommended per the documentation and removed from state the old datasource. Still go the same error.
Something I don't get is when setting the variable
export KUBE_CONFIG_PATH=$PWD/kubeconfig
as suggested in #817 things work as expected.I'm sad to see things are still unusable (not related to this module but on the Kubernetes provider side),
load_config_file
option has been removed from Kubernetes provider for a while and I don't see why this variable needs to be set and how it could be set beforehand.Anyway, if someone managed to use the readded feature of managing configmap I'd be glad to know how to workaround this and help debug this issue.
PS: I'm using Terragrunt, not sure if the issue could be related but it might
Versions
Reproduce
Here is my provider block
The text was updated successfully, but these errors were encountered: