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

k8saas: better kubeconfig support #372

Merged
merged 4 commits into from Dec 5, 2018
Merged

k8saas: better kubeconfig support #372

merged 4 commits into from Dec 5, 2018

Conversation

aybabtme
Copy link
Contributor

  • Adds/updates/deletes cluster credentials from a user's local kubeconfig.
  • Automatically sets the created cluster as the default context for the user.
  • Provide facilities to print/save/remove a cluster from a user's kubeconfig.
  • Allow waiting for a cluster to be running on a create call.

@aybabtme aybabtme mentioned this pull request Nov 28, 2018
@aybabtme aybabtme force-pushed the k8saas-support branch 2 times, most recently from b0a5195 to 1200693 Compare November 28, 2018 06:47
if err := writeOrAddToKubeconfig(kubeconfig); err != nil {
warn(fmt.Sprintf("couldn't write cluster credentials: %v", err))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you return an error and print it here instead ?

Copy link
Contributor Author

@aybabtme aybabtme Nov 28, 2018

Choose a reason for hiding this comment

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

i could, but it'd be redundant. also because this isn't a reason to fail the whole operation and not print the cluster that was just created, it would confuse users into thinking their cluster wasn't created

failCount = 0 // API responded, reset it's error counter
}
if cluster.Status == nil {
time.Sleep(1 * time.Second)

This comment was marked as resolved.


// waitForClusterRunning waits for a cluster to be running.
func waitForClusterRunning(kube do.KubernetesService, clusterID string) error {
failCount := 0

This comment was marked as resolved.

@aybabtme aybabtme force-pushed the k8saas-support branch 5 times, most recently from 50b29dd to 5c81229 Compare November 29, 2018 12:33
AddStringFlag(cmdKubeClusterCreate, doctl.ArgSizeSlug, "", defaultNodeSize, "size of the nodes in the default node pool (incompatible with --"+doctl.ArgClusterNodePool+")")
AddStringFlag(cmdKubeClusterCreate, doctl.ArgNodePoolCount, "", strconv.Itoa(defaultNodeCount), "size of the nodes in the default node pool (incompatible with --"+doctl.ArgClusterNodePool+")")
AddStringSliceFlag(cmdKubeClusterCreate, doctl.ArgClusterNodePool, "", nil, `cluster node pools in the form "name=your-name;size=droplet_size;count=5;tag=tag1;tag=tag2"`, requiredOpt())
AddBoolFlag(cmdKubeClusterCreate, doctl.ArgClusterUpdateKubeconfig, "", true, "whether to add the created cluster to your kubeconfig")
Copy link
Member

Choose a reason for hiding this comment

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

This default also changes the current context to the new cluster cluster, should this maybe be a separate value that defaults to false? I've had a few occasions where this happened and I forgot about it, and got very confused why my kubectl seemed to not be doing what I wanted it to the cluster that was previously my active 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.

I'm reproducing the minikube and kubeadm behavior here, but this could be a flag yes.

Choose a reason for hiding this comment

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

Is there a way you could make the node-pool flag more usable or show how to print the various "slug" sizes in the help text?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'll try to make this better in a next iteration.

@hilary
Copy link
Contributor

hilary commented Dec 3, 2018

Looks (and feels) ready to me.

@alexellis
Copy link

Automatically sets the created cluster as the default context for the user.

I know minikube does this, but is there a flag to preserve context? When creating clusters with eksctl for example I'm not forced to get a context-switch.

@aybabtme
Copy link
Contributor Author

aybabtme commented Dec 3, 2018

@alexellis I'll add one, and change the default behavior to not change the context. It seems that enough people find this jarring to suggest it's probably not a good default behavior.

@aybabtme
Copy link
Contributor Author

aybabtme commented Dec 3, 2018

actually I'll just remove that changing the context thing, it's already easily done with kubectl.

@aybabtme aybabtme merged commit 4debd4b into master Dec 5, 2018
@aybabtme aybabtme deleted the k8saas-support branch December 5, 2018 00:08
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.

None yet

6 participants