move --no-associate-public-ip to instance group

This commit is contained in:
Mykhailo Oleksiuk 2016-08-06 14:46:46 +03:00
parent 0c96f5dd1d
commit fad3d3a4f4
7 changed files with 29 additions and 37 deletions

View File

@ -33,7 +33,7 @@ type CreateClusterCmd struct {
NetworkCIDR string
DNSZone string
AdminAccess string
NoPublicIP bool
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,

View File

@ -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" }}

View File

@ -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" }}

View File

@ -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"`

View File

@ -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

View File

@ -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{},

View File

@ -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 {