-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
kubeconfig overhaul #1029
kubeconfig overhaul #1029
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BenTheElder The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
heh our lints don't like client-go :+)
|
important reference for expected behavior: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands in addition, from inspecting code (mainly client-go directly) and reading some other sources
|
81a545d
to
ef2111d
Compare
f11700a
to
f919591
Compare
"sigs.k8s.io/kind/pkg/internal/util/assert" | ||
) | ||
|
||
func TestEncodeRoundtrip(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a test failing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not trivially, it only fails if it cannot marshal the type so ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI we have 41.5% statements covered in this package, the rest are mostly error cases that aren't really triggerable like this, or file system interactions (and somewhat unit tests then, but I will probably still add some)
if err != nil { | ||
return nil, err | ||
} | ||
// special case: don't write anything when empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can detect this first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really, the input is fairly arbitrary.
this is a really simple nice to have thing to make the output more like the user would expect. it would be totally valid to not have this entire method.
brought coverage up to 59.4% of statements for the kubeconfig package by covering |
ok covered removal. this is now at 64.7% statements covered.
|
|
||
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands | ||
|
||
- If the --kubeconfig flag is set, then only that file is loaded. The flag may only be set once and no merging takes place. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document this later in the quick start guide or the readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done #1032
/lgtm |
// matches kubeconfig server entry like: | ||
// server: https://172.17.0.2:6443 | ||
// which we rewrite to: | ||
// server: https://$ADDRESS:$PORT | ||
var serverAddressRE = regexp.MustCompile(`^(\s+server:) https://.*:\d+$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the 'rewrite' doesn't (seem to) happen anymore, the kind get kubeconfig
prints the container's host and port instead of 127.0.0.1 + the forwarded port. Or am I wrong?
Or maybe I'm using kind get kubeconfig
wrong 😁
The kind get kubeconfig --internal
does the same as kind get kubeconfig --internal
for now (as of aea9a47)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this is failing
https://github.com/kubernetes-sigs/kind/pull/1029/files#diff-8e81c51b562c668c8c80420dd1917316R81
:/
can you open a bug @maelvls ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick response 🙂
Issue created: #1051
Implements most of #850, also #112, #113
This is smaller than it looks, a lot of the lines are boilerplate license etc. because I broke up the implementation into small portions and tried to comment it pretty strongly
There are a few additional not strictly necessary but nice to have features like ensuring that the formatting matches client-go generated kubeconfigs.
This does:
kind-${cluster_name}
instead of the ~static kubeadm names) kind create cluster creates same kubeconfig user name for each cluster #112kubectl
Add option to specify kubeconfig when creating kind clusters #113kind create cluster
kind delete cluster
kind get kubeconfig-path
as it's no longer relevantkind get kubeconfig
to not depend on any files on the hostThis is a mildly breaking change. We'll want a simple guide in the release notes for migration.
If you want kind to use a different config file, you can either set the
--kubeconfig
option tokind create cluster
/kind delete cluster
or you can exportKUBECONFIG
prior to using kind.This is basically the same as before, just that you decide the path and you do it before
kind create cluster
instead of after.