From 1380f1d2ddeb23947a7fb2ef0d1dae14c180fcef Mon Sep 17 00:00:00 2001 From: John Gardiner Myers Date: Sat, 12 Nov 2022 11:59:10 -0800 Subject: [PATCH] Add --bastion-image flag to "kops create cluster" --- cmd/kops/create_cluster.go | 2 ++ docs/cli/kops_create_cluster.md | 1 + upup/pkg/fi/cloudup/new_cluster.go | 13 +++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index 3d03e8146f..16419fd32c 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -267,6 +267,8 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command { cmd.RegisterFlagCompletionFunc("node-image", completeInstanceImage) cmd.Flags().StringVar(&options.MasterImage, "master-image", options.MasterImage, "Machine image for masters. Takes precedence over --image") cmd.RegisterFlagCompletionFunc("master-image", completeInstanceImage) + cmd.Flags().StringVar(&options.BastionImage, "bastion-image", options.BastionImage, "Machine image for bastions. Takes precedence over --image") + cmd.RegisterFlagCompletionFunc("bastion-image", completeInstanceImage) cmd.Flags().StringVar(&options.NodeSize, "node-size", options.NodeSize, "Machine type for worker nodes") cmd.RegisterFlagCompletionFunc("node-size", completeMachineType) diff --git a/docs/cli/kops_create_cluster.md b/docs/cli/kops_create_cluster.md index de81df53e8..d35258e140 100644 --- a/docs/cli/kops_create_cluster.md +++ b/docs/cli/kops_create_cluster.md @@ -71,6 +71,7 @@ kops create cluster [CLUSTER] [flags] --associate-public-ip Specify --associate-public-ip=[true|false] to enable/disable association of public IP for master ASG and nodes. Default is 'true'. --authorization string Authorization mode: AlwaysAllow or RBAC (default "RBAC") --bastion Enable a bastion instance group. Only applies to private topology. + --bastion-image string Machine image for bastions. Takes precedence over --image --channel string Channel for default versions and configuration to use (default "stable") --cloud string Cloud provider to use - aws, digitalocean, gce, hetzner, openstack --cloud-labels string A list of key/value pairs used to tag all instance groups (for example "Owner=John Doe,Team=Some Team"). diff --git a/upup/pkg/fi/cloudup/new_cluster.go b/upup/pkg/fi/cloudup/new_cluster.go index c1aa0dddf0..b537ade663 100644 --- a/upup/pkg/fi/cloudup/new_cluster.go +++ b/upup/pkg/fi/cloudup/new_cluster.go @@ -153,11 +153,12 @@ type NewClusterOptions struct { // InstanceManager specifies which manager to use for managing instances. InstanceManager string - Image string - NodeImage string - MasterImage string - MasterSize string - NodeSize string + Image string + NodeImage string + MasterImage string + BastionImage string + MasterSize string + NodeSize string } func (o *NewClusterOptions) InitDefaults() { @@ -1125,7 +1126,6 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S cluster.Spec.Topology = &api.TopologySpec{ ControlPlane: api.TopologyPublic, Nodes: api.TopologyPublic, - // Bastion: &api.BastionSpec{Enable: c.Bastion}, } if opt.Bastion { @@ -1248,6 +1248,7 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S } } + bastionGroup.Spec.Image = opt.BastionImage } default: