Skip to content

Better kubernetes configuration detection based on k8s libraries #30

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

Conversation

nathanmcgarvey-modopayments
Copy link
Contributor

Please test this locally (go run ./main.go) and in a k8s cluster both with a .kube/config with no KUBECONFIG env variable set and one with a KUBECONFIG env variable set before merging. It works for me, but I want to ensure it doesn't break anyone.

Instead of doing our own user home directory detection for .kube/config, use the k8s.io/cmdclient built-in methods which support KUBECONFIG env variable, $HOME/.kube/config, and KUBERNETES_SERVICE env variables automatically.

Also print out a sanitized representation of the config at startup in case of misconfiguration.

…ig, use the k8s.io/cmdclient built-in methods which support KUBECONFIG env variable, $HOME/.kube/config, and KUBERNETES_SERVICE env variables automatically.

Also print out a sanitized representation of the config at startup in case of misconfiguration.
@nathanmcgarvey-modopayments
Copy link
Contributor Author

nathanmcgarvey-modopayments commented Jun 21, 2023

Now that I'm looking at it, why are these variables being set in the helm chart?

-  KUBERNETES_API_URL: https://172.20.0.1:443
-  CA_FILE: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

Those should get picked up by default (I haven't tested, but it should)

Edit: at least in my local cluster, those variables are not necessary at all. Removed in the next commit.

…ontainer securityContext configurable via variables instead of hard-coded
@max-rocket-internet
Copy link
Owner

Those should get picked up by default (I haven't tested, but it should)

When that code was written about 4 years ago this was not the case but a lot has changed since 😅

@max-rocket-internet
Copy link
Owner

Edit: at least in my local cluster, those variables are not necessary at all. Removed in the next commit.

Give me a couple days and I'll test it.

Copy link
Owner

@max-rocket-internet max-rocket-internet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and in AWS EKS, LGTM ✅
Thanks @nathanmcgarvey-modopayments 💖

@max-rocket-internet max-rocket-internet merged commit 9eb8df6 into max-rocket-internet:master Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants