model

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const STACK_TEMPLATE_FILENAME = "stack.json"

Variables

View Source
var VERSION = "UNKNOWN"

VERSION set by build script

Functions

func ClusterFromBytes

func ClusterFromBytes(data []byte) (*api.Cluster, error)

ClusterFromBytes Necessary for unit tests, which store configs as hardcoded strings

func ClusterFromFile

func ClusterFromFile(filename string) (*api.Cluster, error)

func LoadCredentials

func LoadCredentials(sess *session.Session, cfg *Config, opts api.StackTemplateOptions) (*credential.CompactAssets, error)

func NewCredentialGenerator

func NewCredentialGenerator(c *Config) *credential.Generator

func WithTrailingDot

func WithTrailingDot(s string) string

Types

type APIEndpoint

type APIEndpoint struct {
	// APIEndpoint derives the user-provided configuration in an item of an `apiEndpoints` array and adds various computed settings
	api.APIEndpoint
	// LoadBalancer is the load balancer serving this API endpoint if any
	LoadBalancer APIEndpointLB
}

APIEndpoint represents a Kubernetes API endpoint

type APIEndpointLB

type APIEndpointLB struct {
	// APIEndpointLB derives the user-provided configuration in an `apiEndpoints[].loadBalancer` and adds various computed settings
	api.APIEndpointLB
	// APIEndpoint is inherited to configure this load balancer
	api.APIEndpoint
	// Subnets contains all the subnets assigned to this load-balancer. Specified only when this load balancer is not reused but managed one
	Subnets api.Subnets
}

APIEndpointLB is the load balancer serving the API endpoint

func (APIEndpointLB) DNSNameRef

func (b APIEndpointLB) DNSNameRef() string

DNSNameRef returns a CloudFormation ref for the Amazon-provided DNS name of this load balancer, which is typically used to fill an ALIAS or a CNAME dns record in Route 53

func (APIEndpointLB) Enabled

func (b APIEndpointLB) Enabled() bool

Enabled returns true when controller nodes should be added as targets of this load balancer

func (APIEndpointLB) HostedZoneRef

func (b APIEndpointLB) HostedZoneRef() string

HostedZoneRef returns a CloudFormation ref for the hosted zone the record set for this load balancer is created in

func (APIEndpointLB) LogicalName

func (b APIEndpointLB) LogicalName() string

LogicalName returns the unique resource name of the load balancer

func (APIEndpointLB) RecordSetLogicalName

func (b APIEndpointLB) RecordSetLogicalName() string

RecordSetLogicalName returns the logical name of a record set created for this load balancer A logical name is an unique name of an AWS resource inside a CloudFormation stack template

func (APIEndpointLB) Ref

func (b APIEndpointLB) Ref() string

Ref returns a CloudFormation ref for the load balancer backing the API endpoint

func (APIEndpointLB) SecurityGroupLogicalName

func (b APIEndpointLB) SecurityGroupLogicalName() string

SecurityGroupLogicalName returns a CloudFormation ref for the Security Group backing the API endpoint

func (APIEndpointLB) SecurityGroupRefs

func (b APIEndpointLB) SecurityGroupRefs() []string

SecurityGroupRefs contains CloudFormation resource references for additional SGs associated to this LB

func (APIEndpointLB) TargetGroupRef

func (b APIEndpointLB) TargetGroupRef() string

TargetGroupRef returns a CloudFormation ref for the Target Group backing the API endpoint

type APIEndpoints

type APIEndpoints map[string]APIEndpoint

APIEndpoints is a set of API endpoints associated to a Kubernetes cluster

func NewAPIEndpoints

func NewAPIEndpoints(configs []api.APIEndpoint, allSubnets []api.Subnet) (APIEndpoints, error)

NewAPIEndpoints computes and returns all the required settings required to manage API endpoints form various user-inputs and other already-computed settings

func (APIEndpoints) ELBClassicRefs

func (e APIEndpoints) ELBClassicRefs() []string

ELBClassicRefs returns the names of all the Classic ELBs to which controller nodes should be associated

func (APIEndpoints) ELBV2TargetGroupRefs

func (e APIEndpoints) ELBV2TargetGroupRefs() []string

ELBV2TargetGroupRefs returns the names of all the Load Balancers v2 to which controller nodes should be associated

func (APIEndpoints) FindByName

func (e APIEndpoints) FindByName(name string) (*APIEndpoint, error)

FindByName finds an API endpoint in this set by its name

func (APIEndpoints) GetDefault

func (e APIEndpoints) GetDefault() APIEndpoint

GetDefault returns the default API endpoint identified by its name. The name is defined as DefaultAPIEndpointName

func (APIEndpoints) ManagedELBLogicalNames

func (e APIEndpoints) ManagedELBLogicalNames() []string

ManageELBLogicalNames returns all the logical names of the cfn resources corresponding to ELBs managed by kube-aws for API endpoints

type ClusterDescriber

type ClusterDescriber interface {
	Info() (*Info, error)
}

func NewClusterDescriber

func NewClusterDescriber(clusterName string, stackName string, elbResourceLogicalNames []string, session *session.Session) ClusterDescriber

type Config

type Config struct {
	*api.Cluster

	AdminAPIEndpoint APIEndpoint
	APIEndpoints     APIEndpoints

	// EtcdNodes is the golang-representation of etcd nodes, which is used to differentiate unique etcd nodes
	// This is used to simplify templating of the control-plane stack template.
	EtcdNodes []EtcdNode

	APIServerVolumes   api.APIServerVolumes
	APIServerFlags     api.CommandLineFlags
	ControllerFlags    api.CommandLineFlags
	KubeSchedulerFlags api.CommandLineFlags

	KubernetesManifestFiles []*provisioner.RemoteFile
	HelmReleaseFilesets     []api.HelmReleaseFileset
}

Config contains configuration parameters available when rendering userdata injected into a controller or an etcd node from golang text templates

func Compile

func Compile(cfgRef *api.Cluster, opts api.ClusterOptions) (*Config, error)

func (*Config) APIEndpointURLPort

func (c *Config) APIEndpointURLPort() string

func (*Config) AWSIAMAuthenticatorClusterIDRef

func (c *Config) AWSIAMAuthenticatorClusterIDRef() string

func (*Config) AdminAPIEndpointURL

func (c *Config) AdminAPIEndpointURL() string

AdminAPIEndpointURL is the url of the API endpoint which is written in kubeconfig and used to by admins

func (*Config) EtcdCluster

func (c *Config) EtcdCluster() EtcdCluster

func (Config) EtcdStackName

func (c Config) EtcdStackName() string

func (*Config) Etcdadm

func (c *Config) Etcdadm() (string, error)

Etcdadm returns the content of the etcdadm script to be embedded into cloud-config-etcd

func (*Config) HelmReleasePlugin

func (c *Config) HelmReleasePlugin() helmReleasePlugin

func (*Config) IAMRoleARNs

func (c *Config) IAMRoleARNs() []string

func (Config) InternetGatewayLogicalName

func (c Config) InternetGatewayLogicalName() string

func (Config) InternetGatewayRef

func (c Config) InternetGatewayRef() string

func (*Config) KubernetesManifestPlugin

func (c *Config) KubernetesManifestPlugin() kubernetesManifestPlugin

func (*Config) ManagedELBLogicalNames

func (c *Config) ManagedELBLogicalNames() []string

ManageELBLogicalNames returns all the logical names of the cfn resources corresponding to ELBs managed by kube-aws for API endpoints

func (Config) NetworkStackName

func (c Config) NetworkStackName() string

func (Config) VPCID

func (c Config) VPCID() (string, error)

func (Config) VPCLogicalName

func (c Config) VPCLogicalName() (string, error)

func (Config) VPCManaged

func (c Config) VPCManaged() bool

func (Config) VPCRef

func (c Config) VPCRef() (string, error)

func (Config) VPCRefFromNetworkStack

func (c Config) VPCRefFromNetworkStack() (string, error)

type Context

type Context struct {
	Session *session.Session

	ProvidedEncryptService  credential.KMSEncryptionService
	ProvidedCFInterrogator  cfnstack.CFInterrogator
	ProvidedEC2Interrogator cfnstack.EC2Interrogator
	StackTemplateGetter     StackTemplateGetter
}

func (*Context) GenerateAssetsOnDisk

func (s *Context) GenerateAssetsOnDisk(c *Config, dir string, opts credential.GeneratorOptions) (*credential.RawAssetsOnDisk, error)

func (*Context) InspectEtcdExistingState

func (s *Context) InspectEtcdExistingState(c *Config) (bool, api.EtcdExistingState, error)

func (*Context) InspectWorkerExistingState added in v0.15.0

func (s *Context) InspectWorkerExistingState(npconf *NodePoolConfig) (bool, error)

Check for the existence of a worker nodepool stack by looking it up in cloudformation.

func (*Context) LoadCredentials

func (s *Context) LoadCredentials(cfg *Config, opts api.StackTemplateOptions) (*credential.CompactAssets, error)

func (*Context) ValidateNodePoolStack

func (s *Context) ValidateNodePoolStack(c *NodePoolConfig, stack *Stack) (string, error)

ValidateStack validates the CloudFormation stack for this worker node pool already uploaded to S3

func (*Context) ValidateStack

func (s *Context) ValidateStack(c *Stack) (string, error)

ValidateStack validates the CloudFormation stack for this control plane already uploaded to S3

type ControllerTmplCtx

type ControllerTmplCtx struct {
	*Stack
	*Config
	VPC     api.VPC
	Subnets api.Subnets
}

ControllerTmplCtx is used for rendering controller stack and userdata

type EtcdCluster

type EtcdCluster struct {
	api.EtcdCluster
	Network
	// contains filtered or unexported fields
}

func NewEtcdCluster

func NewEtcdCluster(config api.EtcdCluster, region api.Region, network Network, nodeCount int) EtcdCluster

func (EtcdCluster) DNSNames

func (c EtcdCluster) DNSNames() []string

func (EtcdCluster) LogicalName added in v0.15.0

func (c EtcdCluster) LogicalName() string

func (EtcdCluster) NodeCount

func (c EtcdCluster) NodeCount() int

func (EtcdCluster) Region

func (c EtcdCluster) Region() api.Region

type EtcdNode

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

func NewEtcdNode

func NewEtcdNode(cluster EtcdCluster, index int, nodeConfig api.EtcdNode, s api.Subnet) EtcdNode

func NewEtcdNodeDependsOnManagedNGW

func NewEtcdNodeDependsOnManagedNGW(cluster EtcdCluster, index int, nodeConfig api.EtcdNode, s api.Subnet, ngw api.NATGateway) EtcdNode

func NewEtcdNodes

func NewEtcdNodes(nodeConfigs []api.EtcdNode, cluster EtcdCluster) ([]EtcdNode, error)

NewEtcdNodes derives etcd nodes from user-provided etcd node configs

func (EtcdNode) AdvertisedFQDN added in v0.14.2

func (i EtcdNode) AdvertisedFQDN() (string, error)

func (EtcdNode) AdvertisedFQDNRef

func (i EtcdNode) AdvertisedFQDNRef() (string, error)

func (EtcdNode) DependencyExists

func (i EtcdNode) DependencyExists() bool

func (EtcdNode) DependencyRef

func (i EtcdNode) DependencyRef() (string, error)

func (EtcdNode) EBSLogicalName

func (i EtcdNode) EBSLogicalName() string

func (EtcdNode) EBSRef

func (i EtcdNode) EBSRef() string

func (EtcdNode) EIPAllocationIDRef

func (i EtcdNode) EIPAllocationIDRef() (string, error)

func (EtcdNode) EIPLogicalName

func (i EtcdNode) EIPLogicalName() (string, error)

func (EtcdNode) EIPManaged

func (i EtcdNode) EIPManaged() bool

func (EtcdNode) EIPRef

func (i EtcdNode) EIPRef() (string, error)

func (EtcdNode) LaunchConfigurationLogicalName

func (i EtcdNode) LaunchConfigurationLogicalName() string

LaunchConfigurationLogicalName returns the logical name of the launch configuration specific to this etcd node

func (EtcdNode) LogicalName

func (i EtcdNode) LogicalName() string

func (EtcdNode) LogicalNameForIndex added in v0.15.0

func (i EtcdNode) LogicalNameForIndex(index int64) string

func (EtcdNode) MajorMinorVersion added in v0.15.0

func (i EtcdNode) MajorMinorVersion() string

func (EtcdNode) Name

func (i EtcdNode) Name() string

func (EtcdNode) NetworkInterfaceIDRef

func (i EtcdNode) NetworkInterfaceIDRef() string

func (EtcdNode) NetworkInterfaceLogicalName

func (i EtcdNode) NetworkInterfaceLogicalName() string

func (EtcdNode) NetworkInterfaceManaged

func (i EtcdNode) NetworkInterfaceManaged() bool

func (EtcdNode) NetworkInterfacePrivateIPLogicalName

func (i EtcdNode) NetworkInterfacePrivateIPLogicalName() string

NetworkInterfacePrivateIPLogicalName returns the logical name of the launch configuration specific to this etcd node

func (EtcdNode) NetworkInterfacePrivateIPRef

func (i EtcdNode) NetworkInterfacePrivateIPRef() string

func (EtcdNode) RecordSetLogicalName

func (i EtcdNode) RecordSetLogicalName() string

func (EtcdNode) RecordSetManaged

func (i EtcdNode) RecordSetManaged() bool

func (EtcdNode) SubnetAvailabilityZone

func (i EtcdNode) SubnetAvailabilityZone() string

func (EtcdNode) SubnetRef

func (i EtcdNode) SubnetRef() string

type EtcdTmplCtx

type EtcdTmplCtx struct {
	*Stack
	*Config
	api.EtcdExistingState
	EtcdNodes []EtcdNode
}

An EtcdTmplCtx contains configuration settings/options mixed with existing state in a way that can be consumed by stack and cloud-config templates.

type Info

type Info struct {
	Name            string
	ControllerHosts []string
}

func (*Info) String

func (c *Info) String() string

type MainClusterSettings

type MainClusterSettings struct {
	EtcdNodes             []EtcdNode
	KubeResourcesAutosave api.KubeResourcesAutosave
}

type Network

type Network interface {
	Subnets() []api.Subnet
	NATGateways() []api.NATGateway
	NATGatewayForSubnet(api.Subnet) (*api.NATGateway, error)
}

func NewNetwork

func NewNetwork(subnets []api.Subnet, natGateways []api.NATGateway) Network

type NetworkTmplCtx

type NetworkTmplCtx struct {
	*Stack
	*Config
	WorkerNodePools []WorkerTmplCtx
}

type NodePoolConfig

type NodePoolConfig struct {
	api.WorkerNodePool `yaml:",inline"`

	MainClusterSettings
	// APIEndpoint is the k8s api endpoint to which worker nodes in this node pool communicate
	APIEndpoint     APIEndpoint
	api.UnknownKeys `yaml:",inline"`
	AMI             string
}

func NodePoolCompile

func NodePoolCompile(spec api.WorkerNodePool, main *Config) (*NodePoolConfig, error)

func (NodePoolConfig) APIEndpointURL

func (c NodePoolConfig) APIEndpointURL() string

APIEndpointURL is the url of the API endpoint which is written in cloud-config-worker and used by kubelets in worker nodes to access the apiserver

func (NodePoolConfig) APIEndpointURLPort

func (c NodePoolConfig) APIEndpointURLPort() string

func (NodePoolConfig) AWSIAMAuthenticatorClusterIDRef

func (c NodePoolConfig) AWSIAMAuthenticatorClusterIDRef() string

func (*NodePoolConfig) ExternalDNSName

func (c *NodePoolConfig) ExternalDNSName() string

func (NodePoolConfig) FeatureGates

func (c NodePoolConfig) FeatureGates() api.FeatureGates

func (NodePoolConfig) NestedStackName

func (c NodePoolConfig) NestedStackName() string

NestedStackName returns a sanitized name of this node pool which is usable as a valid cloudformation nested stack name

func (NodePoolConfig) NodeLabels

func (c NodePoolConfig) NodeLabels() api.NodeLabels

func (NodePoolConfig) SecurityGroupRefs

func (c NodePoolConfig) SecurityGroupRefs() []string

func (NodePoolConfig) StackName

func (c NodePoolConfig) StackName() string

StackName returns the logical name of a CloudFormation stack resource in a root stack template This is not needed to be unique in an AWS account because the actual name of a nested stack is generated randomly by CloudFormation by including the logical name. This is NOT intended to be used to reference stack name from cloud-config as the target of awscli or cfn-bootstrap-tools commands e.g. `cfn-init` and `cfn-signal`

func (NodePoolConfig) StackNameEnvFileName

func (c NodePoolConfig) StackNameEnvFileName() string

func (NodePoolConfig) StackNameEnvVarName

func (c NodePoolConfig) StackNameEnvVarName() string

func (NodePoolConfig) VPCRef

func (c NodePoolConfig) VPCRef() (string, error)

func (NodePoolConfig) Validate

func (c NodePoolConfig) Validate() error

func (NodePoolConfig) WorkerDeploymentSettings

func (c NodePoolConfig) WorkerDeploymentSettings() NodePoolDeploymentSettings

type NodePoolDeploymentSettings

type NodePoolDeploymentSettings struct {
	api.WorkerNodePool
	api.Experimental
	api.DeploymentSettings
}

func (NodePoolDeploymentSettings) StackTags

func (c NodePoolDeploymentSettings) StackTags() map[string]string

func (NodePoolDeploymentSettings) Validate

func (c NodePoolDeploymentSettings) Validate() error

func (NodePoolDeploymentSettings) WorkerSecurityGroupRefs

func (c NodePoolDeploymentSettings) WorkerSecurityGroupRefs() []string

type NodePoolStackInfo

type NodePoolStackInfo struct {
	Name string
}

func (*NodePoolStackInfo) String

func (c *NodePoolStackInfo) String() string

type NodePoolStackRef

type NodePoolStackRef struct {
	*NodePoolConfig
	// contains filtered or unexported fields
}

func (*NodePoolStackRef) Destroy

func (c *NodePoolStackRef) Destroy() error

func (*NodePoolStackRef) Info

type Ref

type Ref struct {
	PoolName string
}

type Stack

type Stack struct {
	NodeProvisioner *provisioner.Provisioner

	StackName   string
	S3URI       string
	ClusterName string
	StackExists bool
	Region      api.Region

	Config         *Config
	NodePoolConfig *NodePoolConfig

	api.StackTemplateOptions
	UserData          map[string]api.UserData
	CfnInitConfigSets map[string]interface{}
	ExtraCfnResources map[string]interface{}
	ExtraCfnTags      map[string]interface{}
	ExtraCfnOutputs   map[string]interface{}

	AssetsConfig *credential.CompactAssets
	// contains filtered or unexported fields
}

func NewControlPlaneStack

func NewControlPlaneStack(conf *Config, opts api.StackTemplateOptions, extras clusterextension.ClusterExtension, assetsConfig *credential.CompactAssets) (*Stack, error)

NewControlPlaneStack reads the specified cluster spec along with all the referenced files into memory. Any configuration error like a reference to a missing file results in kube-aws existing with an error.

func NewEtcdStack

func NewEtcdStack(conf *Config, opts api.StackTemplateOptions, extras clusterextension.ClusterExtension, assetsConfig *credential.CompactAssets, s *Context) (*Stack, error)

func NewNetworkStack

func NewNetworkStack(conf *Config, nodePools []*Stack, opts api.StackTemplateOptions, extras clusterextension.ClusterExtension, assetsConfig *credential.CompactAssets) (*Stack, error)

func NewWorkerStack

func NewWorkerStack(conf *Config, npconf *NodePoolConfig, opts api.StackTemplateOptions, extras clusterextension.ClusterExtension, assetsConfig *credential.CompactAssets, s *Context) (*Stack, error)

func (*Stack) Assets

func (c *Stack) Assets() cfnstack.Assets

func (*Stack) ClusterExportedStacksS3URI

func (c *Stack) ClusterExportedStacksS3URI() string

func (*Stack) ClusterS3URI

func (c *Stack) ClusterS3URI() string

func (Stack) EtcdSnapshotsS3Bucket

func (c Stack) EtcdSnapshotsS3Bucket() (string, error)

func (Stack) EtcdSnapshotsS3PathRef

func (c Stack) EtcdSnapshotsS3PathRef() (string, error)

EtcdSnapshotsS3Path is a pair of a S3 bucket and a key of an S3 object containing an etcd cluster snapshot

func (Stack) EtcdSnapshotsS3PrefixRef

func (c Stack) EtcdSnapshotsS3PrefixRef() (string, error)

func (*Stack) GetUserData

func (c *Stack) GetUserData(id string) *api.UserData

func (Stack) NestedStackName

func (c Stack) NestedStackName() string

NestedStackName returns a sanitized name of this control-plane which is usable as a valid cloudformation nested stack name

func (*Stack) RenderAddControllerUserdata

func (p *Stack) RenderAddControllerUserdata(opts api.StackTemplateOptions) error

func (*Stack) RenderAddEtcdUserdata

func (p *Stack) RenderAddEtcdUserdata(opts api.StackTemplateOptions) error

func (*Stack) RenderAddWorkerUserdata

func (p *Stack) RenderAddWorkerUserdata(opts api.StackTemplateOptions) error

func (*Stack) RenderAndAddUserData

func (s *Stack) RenderAndAddUserData(id, userdataTmplPath string) error

RenderAndAddUserData adds a userdata with the id that is loaded from the file located at `userdataTmplPath`. When the id is "Controller", the loaded useradata can be referenced by `Userdata.Controller` in templates.

func (*Stack) RenderStackTemplateAsBytes

func (c *Stack) RenderStackTemplateAsBytes() ([]byte, error)

func (*Stack) RenderStackTemplateAsString

func (c *Stack) RenderStackTemplateAsString() (string, error)

func (*Stack) String

func (c *Stack) String() string

func (*Stack) TemplateURL

func (c *Stack) TemplateURL() (string, error)

type StackRef

type StackRef struct {
	*api.Cluster
	// contains filtered or unexported fields
}

func (*StackRef) Validate

func (c *StackRef) Validate() error

type StackTemplateGetter

type StackTemplateGetter interface {
	GetTemplate(input *cloudformation.GetTemplateInput) (*cloudformation.GetTemplateOutput, error)
}

type WorkerTmplCtx

type WorkerTmplCtx struct {
	*Stack
	*NodePoolConfig
}

WorkerTmplCtx is used for rendering worker stacks and userdata

Jump to

Keyboard shortcuts

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