Skip to content

Commit

Permalink
Default to exporting a kubecfg, even without credentials
Browse files Browse the repository at this point in the history
We do log a hint for the user when we have exported an empty kubecfg,
but this now supports the "current cluster" UX.

Issue #9990
  • Loading branch information
justinsb committed Oct 25, 2020
1 parent e0e41a6 commit e03bb72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions cmd/kops/update_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func (o *UpdateClusterOptions) InitDefaults() {
o.Target = "direct"
o.SSHPublicKey = ""
o.OutDir = ""
o.CreateKubecfg = false

// By default we export a kubecfg, but it doesn't have a static/eternal credential in it any more.
o.CreateKubecfg = true

o.RunTasksOptions.InitDefaults()
}

Expand Down Expand Up @@ -149,10 +152,6 @@ func RunUpdateCluster(ctx context.Context, f *util.Factory, clusterName string,
return nil, fmt.Errorf("cannot use both --admin and --user")
}

if c.CreateKubecfg && c.admin == 0 && c.user == "" {
return nil, fmt.Errorf("--create-kube-config requires that either --admin or --user is set")
}

if c.admin != 0 && !c.CreateKubecfg {
klog.Info("--admin implies --create-kube-config")
c.CreateKubecfg = true
Expand Down Expand Up @@ -312,6 +311,7 @@ func RunUpdateCluster(ctx context.Context, f *util.Factory, clusterName string,
firstRun = !hasKubecfg

klog.Infof("Exporting kubecfg for cluster")

// TODO: Another flag?
useKopsAuthenticationPlugin := false
conf, err := kubeconfig.BuildKubecfg(
Expand All @@ -332,6 +332,10 @@ func RunUpdateCluster(ctx context.Context, f *util.Factory, clusterName string,
if err != nil {
return nil, err
}

if c.admin == 0 && c.user == "" {
klog.Warningf("Exported kubecfg with no user authentication; use --admin, --user or --auth-plugin flags with `kops export kubecfg`")
}
}

if !isDryrun {
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/kops_update_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kops update cluster [flags]
```
--admin duration[=18h0m0s] Also export a cluster admin user credential with the specified lifetime and add it to the cluster context
--allow-kops-downgrade Allow an older version of kops to update the cluster than last used
--create-kube-config Will control automatically creating the kube config file on your local filesystem
--create-kube-config Will control automatically creating the kube config file on your local filesystem (default true)
-h, --help help for cluster
--internal Use the cluster's internal DNS name. Implies --create-kube-config
--lifecycle-overrides strings comma separated list of phase overrides, example: SecurityGroups=Ignore,InternetGateway=ExistsAndWarnIfChanges
Expand Down

0 comments on commit e03bb72

Please sign in to comment.