Skip to content
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

Standalone kubeconfig for gce kube-up #5154

Merged
merged 2 commits into from
Mar 9, 2015
Merged

Conversation

j3ffml
Copy link
Contributor

@j3ffml j3ffml commented Mar 7, 2015

Make gce create and clear standalone .kubeconfig (embedded certs) on kube-up, kube-down respectively. Also updated e2e test driver to pull auth info from either a .kubeconfig file or a .kubernetes_auth with optional certs directory.

This closes #5040, and enables the following workflow

  1. spin up cluster on host1 with kube-up.sh
  2. copy $HOME/.kube/.kubeconfig to host2
  3. use kubectl on host2 to talk to cluster

e2e tests passing on gce, gke. cc @zmerlynn, @satnam6502

fmt.Printf(">>> testContext.kubeConfig: %s\n", testContext.kubeConfig)
c, err := clientcmd.LoadFromFile(testContext.kubeConfig)
if err != nil {
return nil, fmt.Errorf("Error loading kubeConfig: %v", err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

How about starting returned error messages with a lower case letter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@satnam6502
Copy link
Contributor

@filbranden because he always has an opinion on bash code :-)

@satnam6502
Copy link
Contributor

Great, thanks. I think it is good to remove information about deleted clusters to avoid confusion for users (like me) who look at these files and then make assumptions about what exists in the real world. Also, it's also great to be able to copy a config file from my Ubuntu desktop to my MacBook Pro and carry on where I left off.

@satnam6502 satnam6502 added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 9, 2015
"${kubectl}" config unset "users.${CONTEXT}"
"${kubectl}" config unset "contexts.${CONTEXT}"

local current=$("${kubectl}" config view -o template --template='{{ index . "current-context" }}')
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a problem with the interaction of local with $(...) in that the local will "hide" the error status of the command being replaced here.

For example this function will not fail under errexit as expected:

set -o errexit
function should_fail() {
  local failure=$(false)
}

Recommendation is to split the local and the assignment instead:

  local current
  current=$("${kubectl}" config view -o template --template='{{ index . "current-context" }}')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Also tweaked the ginkgo tests to pull auth directly from a kubeconfig file
instead of the legacy kubernetes_auth file.
@j3ffml
Copy link
Contributor Author

j3ffml commented Mar 9, 2015

PTAL

@satnam6502
Copy link
Contributor

@filbranden : want to give a LGTM for the bash?

@filbranden
Copy link
Contributor

Yes, LGTM, that was my only comment. Thanks for addressing it!

satnam6502 added a commit that referenced this pull request Mar 9, 2015
Standalone kubeconfig for gce kube-up
@satnam6502 satnam6502 merged commit 89bc7bb into kubernetes:master Mar 9, 2015
@j3ffml j3ffml deleted the kube-up branch March 10, 2015 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube-down.sh should remove entries from ./kube/...
5 participants