diff --git a/Gopkg.lock b/Gopkg.lock index f051eff0500..ea0eeb5138f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -771,11 +771,11 @@ [[projects]] branch = "master" - digest = "1:14833e88e9193430014238507ee22eb650952caa5b70611babab520380cfcbc8" + digest = "1:70e659b4cad21aaf34189b548b3c050783713330972b54fe30959f2b43b0ef78" name = "sigs.k8s.io/cluster-api-provider-aws" packages = ["pkg/apis/awsproviderconfig/v1alpha1"] pruneopts = "NUT" - revision = "24d07d04fe7fa31597bf75f45d4cd41d0e4b2b94" + revision = "e6986093d1fbac2084c50b04fe2f78125ffca582" source = "https://github.com/openshift/cluster-api-provider-aws.git" [[projects]] diff --git a/pkg/asset/machines/aws/machines.go b/pkg/asset/machines/aws/machines.go index 1c7a9dc419a..e4dfc0963fa 100644 --- a/pkg/asset/machines/aws/machines.go +++ b/pkg/asset/machines/aws/machines.go @@ -118,3 +118,21 @@ func tagsFromUserTags(clusterID, clusterName string, usertags map[string]string) } return tags, nil } + +// ConfigMasters sets the PublicIP flag and assigns a set of load balancers to the given machines +func ConfigMasters(machines []clusterapi.Machine, clusterName string) { + for _, machine := range machines { + providerConfig := machine.Spec.ProviderConfig.Value.Object.(*awsprovider.AWSMachineProviderConfig) + providerConfig.PublicIP = pointer.BoolPtr(true) + providerConfig.LoadBalancers = []awsprovider.LoadBalancerReference{ + { + Name: fmt.Sprintf("%s-ext", clusterName), + Type: awsprovider.NetworkLoadBalancerType, + }, + { + Name: fmt.Sprintf("%s-int", clusterName), + Type: awsprovider.NetworkLoadBalancerType, + }, + } + } +} diff --git a/pkg/asset/machines/master.go b/pkg/asset/machines/master.go index a9d69f65531..e898871b048 100644 --- a/pkg/asset/machines/master.go +++ b/pkg/asset/machines/master.go @@ -84,6 +84,7 @@ func (m *Master) Generate(dependencies asset.Parents) error { if err != nil { return errors.Wrap(err, "failed to create master machine objects") } + aws.ConfigMasters(machines, ic.ObjectMeta.Name) list := listFromMachines(machines) raw, err := yaml.Marshal(list) diff --git a/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go b/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go index caddff13361..84a01e79f97 100644 --- a/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go +++ b/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/awsmachineproviderconfig_types.go @@ -133,9 +133,9 @@ type AWSMachineProviderConfig struct { // Placement specifies where to create the instance in AWS Placement Placement `json:"placement"` - // LoadBalancerNames is the names of the load balancers to which the new instance + // LoadBalancers is the set of load balancers to which the new instance // should be added once it is created. - LoadBalancerNames []string `json:"loadBalancerIds"` + LoadBalancers []LoadBalancerReference `json:"loadBalancers"` } // AWSResourceReference is a reference to a specific AWS resource by ID, ARN, or filters. @@ -188,6 +188,23 @@ type AWSMachineProviderConfigList struct { Items []AWSMachineProviderConfig `json:"items"` } +// LoadBalancerReference is a reference to a load balancer on AWS. +type LoadBalancerReference struct { + Name string `json:"name"` + Type AWSLoadBalancerType `json:"type"` +} + +// AWSLoadBalancerType is the type of LoadBalancer to use when registering +// an instance with load balancers specified in LoadBalancerNames +type AWSLoadBalancerType string + +// Possible values for AWSLoadBalancerType. Add to this list as other types +// of load balancer are supported by the actuator. +const ( + ClassicLoadBalancerType AWSLoadBalancerType = "classic" // AWS classic ELB + NetworkLoadBalancerType AWSLoadBalancerType = "network" // AWS Network Load Balancer (NLB) +) + func init() { SchemeBuilder.Register(&AWSMachineProviderConfig{}, &AWSMachineProviderConfigList{}, &AWSMachineProviderStatus{}) } diff --git a/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go b/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go index 142489564b1..26e80f4a189 100644 --- a/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1/zz_generated.deepcopy.go @@ -87,9 +87,9 @@ func (in *AWSMachineProviderConfig) DeepCopyInto(out *AWSMachineProviderConfig) } in.Subnet.DeepCopyInto(&out.Subnet) out.Placement = in.Placement - if in.LoadBalancerNames != nil { - in, out := &in.LoadBalancerNames, &out.LoadBalancerNames - *out = make([]string, len(*in)) + if in.LoadBalancers != nil { + in, out := &in.LoadBalancers, &out.LoadBalancers + *out = make([]LoadBalancerReference, len(*in)) copy(*out, *in) } return @@ -242,6 +242,22 @@ func (in *Filter) DeepCopy() *Filter { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerReference) DeepCopyInto(out *LoadBalancerReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerReference. +func (in *LoadBalancerReference) DeepCopy() *LoadBalancerReference { + if in == nil { + return nil + } + out := new(LoadBalancerReference) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Placement) DeepCopyInto(out *Placement) { *out = *in