Skip to content

Commit e7a3f2c

Browse files
committed
Add --use-kubeconfig to kops reconcile cluster
This is implemented the same way as update cluster, validate cluster, etc.
1 parent e91d258 commit e7a3f2c

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

cmd/kops/reconcile_cluster.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"k8s.io/kops/cmd/kops/util"
2828
"k8s.io/kops/pkg/apis/kops"
2929
"k8s.io/kops/pkg/commands/commandutils"
30+
"k8s.io/kops/pkg/kubeconfig"
3031
"k8s.io/kops/upup/pkg/fi/cloudup"
3132
"k8s.io/kubectl/pkg/util/i18n"
3233
"k8s.io/kubectl/pkg/util/templates"
@@ -47,6 +48,8 @@ var (
4748

4849
type ReconcileClusterOptions struct {
4950
CoreUpdateClusterOptions
51+
52+
kubeconfig.CreateKubecfgOptions
5053
}
5154

5255
func NewCmdReconcileCluster(f *util.Factory, out io.Writer) *cobra.Command {
@@ -61,7 +64,7 @@ func NewCmdReconcileCluster(f *util.Factory, out io.Writer) *cobra.Command {
6164
Args: rootCommand.clusterNameArgs(&options.ClusterName),
6265
ValidArgsFunction: commandutils.CompleteClusterName(f, true, false),
6366
RunE: func(cmd *cobra.Command, args []string) error {
64-
err := RunReconcileCluster(cmd.Context(), f, out, &options.CoreUpdateClusterOptions)
67+
err := RunReconcileCluster(cmd.Context(), f, out, options)
6568
return err
6669
},
6770
}
@@ -76,6 +79,8 @@ func NewCmdReconcileCluster(f *util.Factory, out io.Writer) *cobra.Command {
7679
// cmd.Flags().StringVar(&options.OutDir, "out", options.OutDir, "Path to write any local output")
7780
// cmd.MarkFlagDirname("out")
7881

82+
options.CreateKubecfgOptions.AddCommonFlags(cmd.Flags())
83+
7984
// These flags from the update command are specified to kubeconfig creation
8085
//
8186
// cmd.Flags().BoolVar(&options.CreateKubecfg, "create-kube-config", options.CreateKubecfg, "Will control automatically creating the kube config file on your local filesystem")
@@ -115,7 +120,8 @@ func NewCmdReconcileCluster(f *util.Factory, out io.Writer) *cobra.Command {
115120
// To respect skew policy, it updates the control plane first, then updates the nodes.
116121
// "update" is probably now smart enough to automatically not update the control plane if it is already at the desired version,
117122
// but we do it explicitly here to be clearer / safer.
118-
func RunReconcileCluster(ctx context.Context, f *util.Factory, out io.Writer, c *CoreUpdateClusterOptions) error {
123+
func RunReconcileCluster(ctx context.Context, f *util.Factory, out io.Writer, options *ReconcileClusterOptions) error {
124+
c := &options.CoreUpdateClusterOptions
119125
if c.Target == cloudup.TargetTerraform {
120126
return fmt.Errorf("reconcile is not supported with terraform")
121127
}
@@ -149,6 +155,7 @@ func RunReconcileCluster(ctx context.Context, f *util.Factory, out io.Writer, c
149155
opt := &ValidateClusterOptions{}
150156
opt.InitDefaults()
151157
opt.ClusterName = c.ClusterName
158+
opt.CreateKubecfgOptions = options.CreateKubecfgOptions
152159
opt.wait = 10 * time.Minute
153160

154161
// filter the instance group to only include the control plane
@@ -171,6 +178,7 @@ func RunReconcileCluster(ctx context.Context, f *util.Factory, out io.Writer, c
171178
opt := &RollingUpdateOptions{}
172179
opt.InitDefaults()
173180
opt.ClusterName = c.ClusterName
181+
opt.CreateKubecfgOptions = options.CreateKubecfgOptions
174182
opt.InstanceGroupRoles = []string{
175183
string(kops.InstanceGroupRoleAPIServer),
176184
string(kops.InstanceGroupRoleControlPlane),
@@ -197,6 +205,7 @@ func RunReconcileCluster(ctx context.Context, f *util.Factory, out io.Writer, c
197205
opt := &RollingUpdateOptions{}
198206
opt.InitDefaults()
199207
opt.ClusterName = c.ClusterName
208+
opt.CreateKubecfgOptions = options.CreateKubecfgOptions
200209
// Do all roles this time, though we only expect changes to node & bastion roles
201210
opt.InstanceGroupRoles = nil
202211
opt.Yes = c.Yes

docs/cli/kops_reconcile_cluster.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)