cloudforms

package
v1.6.2-tectonic.1-rc.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2017 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckKubernetesCIDRs

func CheckKubernetesCIDRs(sess *session.Session, existingVPCID, podCIDR, serviceCIDR string) error

CheckKubernetesCIDRs validates an existing VPC, pod, and service CIDRs do not overlap.

func CheckSubnetsAgainstExistingVPC

func CheckSubnetsAgainstExistingVPC(sess *session.Session, existingVPCID string, controllerSubnets, workerSubnets []VPCSubnet) error

CheckSubnetsAgainstExistingVPC dynamically checks that the proposed subnets are suitable with the given existing VPC and its subnets.

Do not call this method in unit tests. It makes API requests to AWS and requires credentials.

func GetDefaultSubnets

func GetDefaultSubnets(sess *session.Session, vpcCIDR string) ([]VPCSubnet, []VPCSubnet, error)

GetDefaultSubnets partitions a CIDR into subnets

func GetVPCSubnets

func GetVPCSubnets(sess *session.Session, vpcID string) ([]VPCSubnet, []VPCSubnet, error)

GetVPCSubnets returns the lists of existing subnets in the given VPC, that are suitable for controllers and workers nodes.

func PopulateCIDRs

func PopulateCIDRs(sess *session.Session, existingVPCID string, publicSubnets, privateSubnets []VPCSubnet) error

PopulateCIDRs shoves some CIDRs into subnets when we know the IDs

func ValidateKubernetesCIDRs

func ValidateKubernetesCIDRs(vpcCIDR, podCIDR, serviceCIDR string) error

ValidateKubernetesCIDRs validates node, pod, and service CIDRs do not overlap. Leave vpcCIDR blank if it is unknown (i.e. bare-metal).

func ValidateSubnets

func ValidateSubnets(vpcCIDR string, subnets []VPCSubnet) error

ValidateSubnets statically validates for correct subnet format, inclusion in the VPC CIDR range, and non-overlapping subnets.

Types

type AwsBucket

type AwsBucket struct {
	// contains filtered or unexported fields
}

func NewAwsBucket

func NewAwsBucket(sess *session.Session,
	hostedZoneName string) *AwsBucket

func (*AwsBucket) Bucket

func (a *AwsBucket) Bucket() string

Bucket returns the genrated unique bucket name in S3

func (*AwsBucket) Remove

func (a *AwsBucket) Remove(filename string) error

Remove removes the specified filename from the S3 bucket

func (*AwsBucket) Upload

func (a *AwsBucket) Upload(filename string, contents []byte) error

Upload puts the filename and data in the bucket

func (*AwsBucket) Url

func (a *AwsBucket) Url(filename string) string

Url returns the complete S3 link to the object

type Cluster

type Cluster struct {
	ClusterName      string
	ControllerDomain string
	Region           string
	StackBody        string
	StackURL         string
}

func NewCloudFormation

func NewCloudFormation(config *Config, sess *session.Session, secrets *SecretAssets) (*Cluster, error)

func (*Cluster) Deploy

func (cb *Cluster) Deploy(sess *session.Session, tags []Tag) (*cloudformation.CreateStackOutput, error)

func (*Cluster) Destroy

func (cb *Cluster) Destroy(sess *session.Session) error

func (*Cluster) Status

func (cb *Cluster) Status(sess *session.Session) (*Status, error)

returns error if, for some reason, we can't query the stack status

type Config

type Config struct {
	// Name of cloudformation stack
	ClusterName string `json:"clusterName"`

	// Region to deploy cluster in
	Region string `json:"region"`

	// CoreOS Channel - alpha/beta/stable
	Channel string `json:"channel"`

	// DNS name for Kubernetes Controller Load Balancer
	// Must be contained within hosted zone
	ControllerDomain string `json:"controllerDomain"`

	// DNS name for Tectonic Load Balancer
	// Must be contained within hosted zone
	TectonicDomain string `json:"tectonicDomain"`

	// ELBs and controllers should be 'internet-facing' or 'internal'
	ELBScheme string `json:"elbScheme"`

	// Hosted zone ID to add DNS records to
	HostedZoneID string `json:"hostedZoneID"`

	// CIDR for new VPC
	VPCCIDR string `json:"vpcCIDR"`

	// Existing VPC ID (leave blank to create new VPC)
	VPCID string `json:"vpcID,omitempty"`

	// OPTIONAL: Existing VPC route table to attach subnets to.
	// (Leave blank to use main route table in existing VPC)
	RouteTableID string `json:"routeTableID,omitempty"`

	// List of subnets in VPC (new or existing) to spread controllers across.
	ControllerSubnets []VPCSubnet `json:"controllerSubnets"`

	// List of subnets in VPC (new or existing) to spread workers across.
	WorkerSubnets []VPCSubnet `json:"workerSubnets"`

	// ARN of KMS key used to encrypt secrets
	KMSKeyARN string `json:"kmsKeyARN"`

	// EC2 ssh key for instances (controller and worker)
	KeyName string `json:"keyName"`

	// EC2 etcd instance settings
	ETCDCount          int    `json:"etcdCount"`
	ETCDInstanceType   string `json:"etcdInstanceType"`
	ETCDRootVolumeType string `json:"etcdRootVolumeType"`
	ETCDRootVolumeIOPS int    `json:"etcdRootVolumeIOPS"`
	ETCDRootVolumeSize int    `json:"etcdRootVolumeSize"`

	// External etcd client endpoint, e.g. etcd.example.com:2379
	ExternalETCDClient string `json:"externalETCDClient"`

	// EC2 controller instances
	ControllerCount          int    `json:"controllerCount"`
	ControllerInstanceType   string `json:"controllerInstanceType"`
	ControllerRootVolumeType string `json:"controllerRootVolumeType"`
	ControllerRootVolumeIOPS int    `json:"controllerRootVolumeIOPS"`
	ControllerRootVolumeSize int    `json:"controllerRootVolumeSize"`

	// EC2 worker instances
	WorkerCount          int    `json:"workerCount"`
	WorkerInstanceType   string `json:"workerInstanceType"`
	WorkerRootVolumeType string `json:"workerRootVolumeType"`
	WorkerRootVolumeIOPS int    `json:"workerRootVolumeIOPS"`
	WorkerRootVolumeSize int    `json:"workerRootVolumeSize"`

	PodCIDR     string `json:"podCIDR"`
	ServiceCIDR string `json:"serviceCIDR"`

	// Cloudformation tags
	Tags []Tag `json:"tags"`

	// Userdata templates
	ControllerTemplate *template.Template `json:"-"`
	WorkerTemplate     *template.Template `json:"-"`
	EtcdTemplate       *template.Template `json:"-"`

	// Cloudformation stack template
	StackTemplate *template.Template `json:"-"`

	// Computed IPs for self-hosted Kubernetes
	APIServiceIP net.IP
	DNSServiceIP net.IP

	// computed fields (set during initialize(), and/or overwritable after)
	ETCDInstances           []ETCDInstance
	ETCDEndpoints           string
	ETCDInitialCluster      string
	APIServers              string
	SecureAPIServers        string
	AMI                     string
	CreateControllerSubnets bool
	CreateWorkerSubnets     bool
	HostedZoneName          string

	// Encoded assets
	EncodedSecrets *compactSecretAssets

	// Logical names of dynamic resources
	VPCLogicalName string

	// Reference strings for dynamic resources
	VPCRef string

	// Logical name for the VPC internet gateway
	InternetGatewayLogicalName string

	// Reference to an existing VPC internet gateway
	InternetGatewayRef string

	// Asset S3 location information
	AssetsS3File   string
	AssetsS3Bucket string
}

Config: External configuration interface

func (*Config) SetComputed

func (c *Config) SetComputed(sess *session.Session) error

SetComputed populates computed fields and may make calls to AWS endpoints.

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults sets Config default values (idempotent).

func (*Config) Valid

func (c *Config) Valid() error

Valid returns true if the cloudform Config is valid.

type ETCDInstance

type ETCDInstance struct {
	// Nam of the ETCD instance
	Name string
	// DNS name addressing the EC2 Instance
	DomainName string
	// Subnet for this EC2 Instance
	Subnet VPCSubnet
}

func PopulateETCDInstances

func PopulateETCDInstances(clusterName, hostedZoneName string, subnets []VPCSubnet, count int) (instances []ETCDInstance, initialCluster, endpoints string)

PopulateETCDInstances initializes a slice of ETCDInstance, with the corresponding initial-cluster and endpoint variables.

type SecretAssets

type SecretAssets struct {
	CACert     []byte
	ClientCert []byte
	ClientKey  []byte
}

SecretAssets are secret assets as raw bytes.

type Status

type Status struct {
	Name         string
	ID           string
	StatusString string
	Events       []string
	Resources    []*cloudformation.StackResourceSummary
	Ready        bool
	Error        bool
}

type Tag

type Tag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type VPCSubnet

type VPCSubnet struct {
	// Identifier of the subnet if already existing
	ID string `json:"id"`
	// Logical name for this subnet
	// ignored if existing
	Name string `json:"name"`
	// Availability zone for this subnet
	// Max one subnet per availability zone
	AvailabilityZone string `json:"availabilityZone"`
	// CIDR for this subnet
	// must be disjoint from other subnets
	// must be contained by VPC CIDR
	InstanceCIDR string `json:"instanceCIDR"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL