Add master and node image options when creating a cluster

This commit is contained in:
Ciprian Hacman 2020-06-19 21:54:54 +03:00
parent d5f0d6a3ca
commit fa9b4ac217
2 changed files with 24 additions and 8 deletions

View File

@ -84,6 +84,8 @@ type CreateClusterOptions struct {
ContainerRuntime string
OutDir string
Image string
NodeImage string
MasterImage string
VPCID string
SubnetIDs []string
UtilitySubnetIDs []string
@ -299,8 +301,14 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&sshPublicKey, "ssh-public-key", sshPublicKey, "SSH public key to use (defaults to ~/.ssh/id_rsa.pub on AWS)")
cmd.Flags().StringVar(&options.NodeSize, "node-size", options.NodeSize, "Set instance size for nodes")
cmd.Flags().Int32Var(&options.MasterCount, "master-count", options.MasterCount, "Set number of masters. Defaults to one master per master-zone")
cmd.Flags().Int32Var(&options.NodeCount, "node-count", options.NodeCount, "Set number of nodes")
cmd.Flags().StringVar(&options.Image, "image", options.Image, "Set image for all instances.")
cmd.Flags().StringVar(&options.NodeImage, "node-image", options.NodeImage, "Set image for nodes")
cmd.Flags().StringVar(&options.MasterImage, "master-image", options.MasterImage, "Set image for masters")
cmd.Flags().StringVar(&options.NodeSize, "node-size", options.NodeSize, "Set instance size for nodes")
cmd.Flags().StringVar(&options.MasterSize, "master-size", options.MasterSize, "Set instance size for masters")
cmd.Flags().Int32Var(&options.MasterVolumeSize, "master-volume-size", options.MasterVolumeSize, "Set instance volume size (in GB) for masters")
@ -312,13 +320,9 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.NetworkCIDR, "network-cidr", options.NetworkCIDR, "Set to override the default network CIDR")
cmd.Flags().BoolVar(&options.DisableSubnetTags, "disable-subnet-tags", options.DisableSubnetTags, "Set to disable automatic subnet tagging")
cmd.Flags().Int32Var(&options.MasterCount, "master-count", options.MasterCount, "Set the number of masters. Defaults to one master per master-zone")
cmd.Flags().Int32Var(&options.NodeCount, "node-count", options.NodeCount, "Set the number of nodes")
cmd.Flags().BoolVar(&options.EncryptEtcdStorage, "encrypt-etcd-storage", options.EncryptEtcdStorage, "Generate key in aws kms and use it for encrypt etcd volumes")
cmd.Flags().StringVar(&options.EtcdStorageType, "etcd-storage-type", options.EtcdStorageType, "The default storage type for etc members")
cmd.Flags().StringVar(&options.Image, "image", options.Image, "Image to use for all instances.")
cmd.Flags().StringVar(&options.Networking, "networking", options.Networking, "Networking mode to use. kubenet, external, weave, flannel-vxlan (or flannel), flannel-udp, calico, canal, kube-router, amazon-vpc-routed-eni, cilium, cni, lyftvpc.")
cmd.Flags().StringVar(&options.DNSZone, "dns-zone", options.DNSZone, "DNS hosted zone to use (defaults to longest matching zone)")
@ -852,6 +856,16 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr
group.Spec.Image = c.Image
}
}
if c.MasterImage != "" {
for _, group := range masters {
group.Spec.Image = c.MasterImage
}
}
if c.NodeImage != "" {
for _, group := range nodes {
group.Spec.Image = c.NodeImage
}
}
if c.AssociatePublicIP != nil {
for _, group := range instanceGroups {

View File

@ -83,9 +83,10 @@ kops create cluster [flags]
--etcd-storage-type string The default storage type for etc members
--gce-service-account string Service account with which the GCE VM runs. Warning: if not set, VMs will run as default compute service account.
-h, --help help for cluster
--image string Image to use for all instances.
--image string Set image for all instances.
--kubernetes-version string Version of kubernetes to run (defaults to version in channel)
--master-count int32 Set the number of masters. Defaults to one master per master-zone
--master-count int32 Set number of masters. Defaults to one master per master-zone
--master-image string Set image for masters
--master-public-name string Sets the public master public name
--master-security-groups strings Add precreated additional security groups to masters.
--master-size string Set instance size for masters
@ -95,7 +96,8 @@ kops create cluster [flags]
--model string Models to apply (separate multiple models with commas) (default "proto,cloudup")
--network-cidr string Set to override the default network CIDR
--networking string Networking mode to use. kubenet, external, weave, flannel-vxlan (or flannel), flannel-udp, calico, canal, kube-router, amazon-vpc-routed-eni, cilium, cni, lyftvpc. (default "kubenet")
--node-count int32 Set the number of nodes
--node-count int32 Set number of nodes
--node-image string Set image for nodes
--node-security-groups strings Add precreated additional security groups to nodes.
--node-size string Set instance size for nodes
--node-tenancy string The tenancy of the node group on AWS. Can be either default or dedicated.