-
Notifications
You must be signed in to change notification settings - Fork 986
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
Source config_path provider argument from $KUBECONFIG env var #1175
Comments
Thanks for writing up this issue! It was an intentional decision with the 2.0 release to remove the automatic reading of I think we could mitigate the original issue mentioned in #909 by setting an order of precedence that prefers explicit configuration over implicit configurations (such as in the case of specifying a static configuration in the provider block, and having |
Hi @dak1n1, Thanks for the explanation. I can see how it would be easy to get bit if Having to set If people do like the idea of being able to read |
Following |
Hey @dak1n1 , since this has been open for some time I'd like to give my 2cents as someone who's been using terraform for multiple years with multiple different providers. Personally I don't understand the change in the 2.0 release at all, since it introduced even more inconsistency with the Kubernetes Backend and how basically all other terraform providers operate. I think the biggest reason to change this back again is consistency throughout existing official providers. Looking at the big 3 Here's for example what is documented for AWS credentials:
Also credential lookup for other providers is the same for the backend provider. In case of AWS this makes the terraform setup super simple, because at most you configure an assume_role as part of your provider config. It also makes it super easy for new people to get started with AWS and Terraform, since as long as they've setup their AWS CLI, they're able to run terraform as well. With the latest Kubernetes changes, I always need to take some extra minutes to get new people started with it, and every single one so far asked me why terraform insists on using a separate environment variable. Lastly even if we disregard that other providers follow a different authentication pattern, it sucks from a local execution point of view as well. I'm working with quite a few clusters and for unrelated reasons it makes it easier for me to manage this by using multiple kubeconfig files and contexts (think different teams with multiple instances, where each team has its own file and each file has an entry for dev/staging/prod). My normal procedure in the past would've been to simply switch the KUBECONFIG env variable to switch cluster connections, double check I'm working on the correct cluster by using the kubectl cli and then executing terraform. |
Count me in (with my "Kubernetes community member" hat on) as favoring reading implicit kubeconfig, ideally using the same semantics and with the same ordering that are defined for
|
@dak1n1 I've got to agree with the other comments above. My $0.02 is that terraform within a CI/CD platform should be the first class citizen. In that environment you should have a VERY good idea of the environment and strive to ensure that environment is isolated from any action that happening concurrently. In some CI platforms that's running inside containers, in others it's copying files into working directories. eg |
Wow, this is pretty surprising behavior. It took a lot of debugging and trial-and-error before I understood how this really works. Considering that most other Kubernetes clients ( |
Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you! |
Not stale, still an issue especially when introducing the provider to new users. |
Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you! |
I think it's an important issue to keep open. |
@giosueDelgado You can follow an issue by clicking the Subscribe button (at the right hand side on desktop; bottom of the page on mobile). That way do you not notify everyone in the thread that you are following the issue. |
Yes,
Hello @lindhe you are right! I update the comment to be more complete |
There are some update about this? In this moment I found the only workaround to use the local file but not always works as expected...
|
Description
Can the
config_path
provider argument be sourced from$KUBECONFIG
? Thekubectl
command usesKUBECONFIG
by default so it makes sense to me that this provider would look in the same place. I think this could provide a smoother integration with other tools via consistent defaults.My specific use-case is with Gitlab CI. Gitlab CI has a nice k8s cluster integration that automatically exports the
KUBECONFG
env var for each CI job. Because this provider looks forKUBE_CONFIG_PATH
, I have to add some extra logic to re-export the kube config path. This sounds simple, but is made a bit more complex by what I'd consider a bug in Gitlab CI: addingto my
.gitlab-ci.yml
script actually exports the contents of the kube config file. The solution I've found is to add a script to the container running the job, to properly exportKUBE_CONFIG_PATH
before running Terraform.To maintain backward compatibility, sourcing from
KUBECONFIG
would be in addition to sourcing fromKUBE_CONFIG_PATH
.KUBE_CONFIG_PATH
could have priority to help prevent surprises.I'm wondering if this has been looked at before. The choice of
KUBE_CONFIG_PATH
certainly feels intentional. If so, why was it decided not to useKUBECONFIG
?If this sounds reasonable, I can work on it and submit a PR.
References
Also posted at: hashicorp/terraform-provider-helm#687
Community Note
The text was updated successfully, but these errors were encountered: