github.com/kubernetes-incubator/kube-aws@v0.16.4/pkg/api/api_endpoints.go (about)

     1  package api
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  type APIEndpoints []APIEndpoint
     8  
     9  const (
    10  	// DefaultAPIEndpointName is the default endpoint name used when you've omitted `apiEndpoints` but not `externalDNSName`
    11  	DefaultAPIEndpointName = "Default"
    12  
    13  	// DefaultLoadBalancerType is the default load balancer to be provisioned by kube-aws for the API endpoints
    14  	DefaultLoadBalancerType = "classic"
    15  )
    16  
    17  // NewDefaultAPIEndpoints creates the slice of API endpoints containing only the default one which is with arbitrary DNS name and an ELB
    18  func NewDefaultAPIEndpoints(dnsName string, subnets []SubnetReference, hostedZoneId string, recordSetTTL int, private bool) APIEndpoints {
    19  	defaultLBType := DefaultLoadBalancerType
    20  
    21  	return []APIEndpoint{
    22  		APIEndpoint{
    23  			Name:    DefaultAPIEndpointName,
    24  			DNSName: dnsName,
    25  			LoadBalancer: APIEndpointLB{
    26  				Type:                        &defaultLBType,
    27  				APIAccessAllowedSourceCIDRs: DefaultCIDRRanges(),
    28  				SubnetReferences:            subnets,
    29  				HostedZone: HostedZone{
    30  					Identifier: Identifier{
    31  						ID: hostedZoneId,
    32  					},
    33  				},
    34  				RecordSetTTLSpecified: &recordSetTTL,
    35  				PrivateSpecified:      &private,
    36  			},
    37  		},
    38  	}
    39  }
    40  
    41  // Validate returns an error if there's any user error in the settings of apiEndpoints
    42  func (e APIEndpoints) Validate() error {
    43  	for i, apiEndpoint := range e {
    44  		if err := apiEndpoint.Validate(); err != nil {
    45  			return fmt.Errorf("invalid apiEndpoint \"%s\" at index %d: %v", apiEndpoint.Name, i, err)
    46  		}
    47  	}
    48  	return nil
    49  }
    50  
    51  // HasNetworkLoadBalancers returns true if there's any API endpoint load balancer of type 'network'
    52  func (e APIEndpoints) HasNetworkLoadBalancers() bool {
    53  	for _, apiEndpoint := range e {
    54  		if apiEndpoint.LoadBalancer.NetworkLoadBalancer() {
    55  			return true
    56  		}
    57  	}
    58  	return false
    59  }
    60  
    61  //type APIDNSRoundRobin struct {
    62  //	// PrivateSpecified determines the resulting DNS round robin uses private IPs of the nodes for an endpoint
    63  //	PrivateSpecified bool
    64  //	// HostedZone is where the resulting A records are created for an endpoint
    65  //      // Beware that kube-aws will never create a hosted zone used for a DNS round-robin because
    66  //      // Doing so would result in CloudFormation to be unable to remove the hosted zone when the stack is deleted
    67  //	HostedZone HostedZone
    68  //}