diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index 1b44529773..debca97e79 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -15,25 +15,25 @@ import ( ) type CreateClusterCmd struct { - Yes bool - Target string - Models string - Cloud string - Zones string - MasterZones string - NodeSize string - MasterSize string - NodeCount int - Project string - KubernetesVersion string - OutDir string - Image string - SSHPublicKey string - VPCID string - NetworkCIDR string - DNSZone string - AdminAccess string - NoPublicIP bool + Yes bool + Target string + Models string + Cloud string + Zones string + MasterZones string + NodeSize string + MasterSize string + NodeCount int + Project string + KubernetesVersion string + OutDir string + Image string + SSHPublicKey string + VPCID string + NetworkCIDR string + DNSZone string + AdminAccess string + NoAssociatePublicIP bool } var createCluster CreateClusterCmd @@ -82,7 +82,7 @@ func init() { cmd.Flags().StringVar(&createCluster.OutDir, "out", "", "Path to write any local output") cmd.Flags().StringVar(&createCluster.AdminAccess, "admin-access", "", "Restrict access to admin endpoints (SSH, HTTPS) to this CIDR. If not set, access will not be restricted by IP.") - cmd.Flags().BoolVar(&createCluster.NoPublicIP, "no-public-ip", false, "Specify --no-public-ip to disable association of public IP for master ASG and nodes.") + cmd.Flags().BoolVar(&createCluster.NoAssociatePublicIP, "no-associate-public-ip", false, "Specify --no-associate-public-ip to disable association of public IP for master ASG and nodes.") } func (c *CreateClusterCmd) Run(args []string) error { @@ -243,6 +243,10 @@ func (c *CreateClusterCmd) Run(args []string) error { } } + for _, group := range instanceGroups { + group.Spec.AssociatePublicIP = fi.Bool(!c.NoAssociatePublicIP) + } + if c.NodeCount != 0 { for _, group := range nodes { group.Spec.MinSize = fi.Int(c.NodeCount) @@ -357,12 +361,6 @@ func (c *CreateClusterCmd) Run(args []string) error { fmt.Println("Previewing changes that will be made:\n") } - if c.NoPublicIP { - fullCluster.Spec.AssociatePublicIP = fi.Bool(false); - } else { - fullCluster.Spec.AssociatePublicIP = fi.Bool(true); - } - applyCmd := &cloudup.ApplyClusterCmd{ Cluster: fullCluster, InstanceGroups: fullInstanceGroups, diff --git a/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml b/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml index 2c1d68b17f..062cf6c313 100644 --- a/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml +++ b/upup/models/cloudup/_aws/master/_master_asg/master_asg.yaml @@ -8,7 +8,7 @@ launchConfiguration/{{ $m.Name }}.masters.{{ ClusterName }}: iamInstanceProfile: iamInstanceProfile/masters.{{ ClusterName }} imageId: {{ $m.Spec.Image }} instanceType: {{ $m.Spec.MachineType }} - associatePublicIP: {{ AssociatePublicIP }} + associatePublicIP: {{ $m.Spec.AssociatePublicIP }} userData: resources/nodeup.sh _kubernetes_master rootVolumeSize: {{ or $m.Spec.RootVolumeSize "20" }} rootVolumeType: {{ or $m.Spec.RootVolumeType "gp2" }} diff --git a/upup/models/cloudup/_aws/nodes.yaml b/upup/models/cloudup/_aws/nodes.yaml index 885173972f..d10e76deeb 100644 --- a/upup/models/cloudup/_aws/nodes.yaml +++ b/upup/models/cloudup/_aws/nodes.yaml @@ -52,7 +52,7 @@ launchConfiguration/{{ $nodeset.Name }}.{{ ClusterName }}: iamInstanceProfile: iamInstanceProfile/nodes.{{ ClusterName }} imageId: {{ $nodeset.Spec.Image }} instanceType: {{ $nodeset.Spec.MachineType }} - associatePublicIP: {{ AssociatePublicIP }} + associatePublicIP: {{ $nodeset.Spec.AssociatePublicIP }} userData: resources/nodeup.sh _kubernetes_pool rootVolumeSize: {{ or $nodeset.Spec.RootVolumeSize "20" }} rootVolumeType: {{ or $nodeset.Spec.RootVolumeType "gp2" }} diff --git a/upup/pkg/api/cluster.go b/upup/pkg/api/cluster.go index d65ad425c1..010f5d1567 100644 --- a/upup/pkg/api/cluster.go +++ b/upup/pkg/api/cluster.go @@ -103,8 +103,6 @@ type ClusterSpec struct { // * enable debugging handlers on the master, so kubectl logs works IsolateMasters *bool `json:"isolateMasters,omitempty"` - AssociatePublicIP *bool `json:"associatePublicIp,omitempty"` - //NetworkProvider string `json:",omitempty"` // //HairpinMode string `json:",omitempty"` diff --git a/upup/pkg/api/instancegroup.go b/upup/pkg/api/instancegroup.go index e965905eb8..a8e054cb8f 100644 --- a/upup/pkg/api/instancegroup.go +++ b/upup/pkg/api/instancegroup.go @@ -44,6 +44,8 @@ type InstanceGroupSpec struct { // MaxPrice indicates this is a spot-pricing group, with the specified value as our max-price bid MaxPrice *string `json:"maxPrice,omitempty"` + + AssociatePublicIP *bool `json:"associatePublicIp,omitempty"` } // PerformAssignmentsInstanceGroups populates InstanceGroups with default values diff --git a/upup/pkg/fi/cloudup/apply_cluster.go b/upup/pkg/fi/cloudup/apply_cluster.go index 6df0396c14..f3cc0b25aa 100644 --- a/upup/pkg/fi/cloudup/apply_cluster.go +++ b/upup/pkg/fi/cloudup/apply_cluster.go @@ -230,9 +230,7 @@ func (c *ApplyClusterCmd) Run() error { // Autoscaling "autoscalingGroup": &awstasks.AutoscalingGroup{}, - "launchConfiguration": &awstasks.LaunchConfiguration{ - AssociatePublicIP: c.Cluster.Spec.AssociatePublicIP, - }, + "launchConfiguration": &awstasks.LaunchConfiguration{}, // Route53 "dnsName": &awstasks.DNSName{}, diff --git a/upup/pkg/fi/cloudup/template_functions.go b/upup/pkg/fi/cloudup/template_functions.go index e8c497f0e3..c215a7f6d4 100644 --- a/upup/pkg/fi/cloudup/template_functions.go +++ b/upup/pkg/fi/cloudup/template_functions.go @@ -10,7 +10,6 @@ import ( "sort" "strings" "text/template" - "k8s.io/kops/upup/pkg/fi" ) type TemplateFunctions struct { @@ -79,9 +78,6 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap) { dest["IAMPrefix"] = tf.IAMPrefix dest["IAMServiceEC2"] = tf.IAMServiceEC2 - dest["AssociatePublicIP"] = func() bool { - return fi.BoolValue(tf.cluster.Spec.AssociatePublicIP) - } } func (tf *TemplateFunctions) EtcdClusterMemberTags(etcd *api.EtcdClusterSpec, m *api.EtcdMemberSpec) map[string]string {