Documentation ¶
Overview ¶
Package adapter contains the required logic for creating data structures used for feeding CloudFormation templates.
It follows the adapter pattern https://en.wikipedia.org/wiki/Adapter_pattern in the sense that it has the knowledge to transform a aws custom object into a data structure easily interpolable into the templates without any additional view logic.
There's a base template in `service/templates/cloudformation/guest/main.yaml` which defines the basic structure and includes the rest of templates that form the stack as nested templates. Those subtemplates should use a `define` action with the name that will be used to refer to them from the main template, as explained here https://golang.org/pkg/text/template/#hdr-Nested_template_definitions
Each adapter is related to one of these nested templates. It includes the data structure with all the values needed to interpolate in the related template and the logic required to obtain them, this logic is packed into functions called `hydraters`.
When extending the stack we will just need to: * Add the template file in `service/template/cloudformation/guest` and modify `service/template/cloudformation/main.yaml` to include the new template. * Add the adapter logic file in `service/resource/cloudformation/adapter` with the type definition and the Hydrater function to fill the fields (like asg.go or launch_configuration.go). * Add the new type to the Adapter type in `service/resource/cloudformation/adapter/adapter.go` and include the Hydrater function in the `hydraters` slice.
Index ¶
- func IsEmptyAmazonAccountID(err error) bool
- func IsInvalidConfig(err error) bool
- func IsMalformedAmazonAccountID(err error) bool
- func IsNotFound(err error) bool
- func IsTooFewResults(err error) bool
- func IsTooManyResults(err error) bool
- func IsWrongAmazonAccountIDLength(err error) bool
- func IsWrongType(err error) bool
- type APIWhitelist
- type Adapter
- type BlockDeviceMapping
- type Config
- type Gateway
- type GuestAdapter
- type GuestAutoScalingGroupAdapter
- type GuestIAMPoliciesAdapter
- type GuestInstanceAdapter
- type GuestInstanceAdapterCluster
- type GuestInstanceAdapterImage
- type GuestInstanceAdapterMaster
- type GuestInstanceAdapterMasterDockerVolume
- type GuestInstanceAdapterMasterEtcdVolume
- type GuestInstanceAdapterMasterInstance
- type GuestInstanceAdapterMasterLogVolume
- type GuestInternetGatewayAdapter
- type GuestLaunchConfigAdapter
- type GuestLifecycleHooksAdapter
- type GuestLifecycleHooksAdapterASG
- type GuestLifecycleHooksAdapterLifecycleHook
- type GuestLifecycleHooksAdapterWorker
- type GuestLoadBalancersAdapter
- type GuestLoadBalancersAdapterPortPair
- type GuestNATGatewayAdapter
- type GuestOutputsAdapter
- type GuestOutputsAdapterMaster
- type GuestOutputsAdapterMasterCloudConfig
- type GuestOutputsAdapterMasterDockerVolume
- type GuestOutputsAdapterMasterInstance
- type GuestOutputsAdapterVersionBundle
- type GuestOutputsAdapterWorker
- type GuestOutputsAdapterWorkerASG
- type GuestOutputsAdapterWorkerCloudConfig
- type GuestRecordSetsAdapter
- type GuestRouteTablesAdapter
- type GuestSecurityGroupsAdapter
- type GuestSubnetsAdapter
- type GuestVPCAdapter
- type Hydrater
- type RouteTableAssociation
- type RouteTableName
- type SmallCloudconfigConfig
- type StackState
- type Subnet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEmptyAmazonAccountID ¶
IsEmptyAmazonAccountID asserts emptyAmazonAccountIDError.
func IsInvalidConfig ¶
IsInvalidConfig asserts invalidConfigError.
func IsMalformedAmazonAccountID ¶
IsMalformedAmazonAccountID asserts malformedAmazonAccountIDError.
func IsTooFewResults ¶
IsTooFewResults asserts tooFewResultsError.
func IsTooManyResults ¶
IsTooManyResults asserts tooManyResultsError.
func IsWrongAmazonAccountIDLength ¶
IsWrongAmazonAccountIDLength asserts wrongAmazonAccountIDLengthError.
Types ¶
type APIWhitelist ¶
APIWhitelist defines guest cluster k8s api whitelisting.
type Adapter ¶
type Adapter struct {
Guest GuestAdapter
}
type BlockDeviceMapping ¶
type Config ¶
type Config struct { APIWhitelist APIWhitelist ControlPlaneAccountID string ControlPlaneNATGatewayAddresses []*ec2.Address ControlPlanePeerRoleARN string ControlPlaneVPCID string ControlPlaneVPCCidr string CustomObject v1alpha1.AWSConfig EncrypterBackend string GuestAccountID string InstallationName string PublicRouteTables string Route53Enabled bool StackState StackState TenantClusterAccountID string TenantClusterKMSKeyARN string }
type GuestAdapter ¶
type GuestAdapter struct { AutoScalingGroup GuestAutoScalingGroupAdapter IAMPolicies GuestIAMPoliciesAdapter InternetGateway GuestInternetGatewayAdapter Instance GuestInstanceAdapter LaunchConfiguration GuestLaunchConfigAdapter LifecycleHooks GuestLifecycleHooksAdapter LoadBalancers GuestLoadBalancersAdapter NATGateway GuestNATGatewayAdapter Outputs GuestOutputsAdapter RecordSets GuestRecordSetsAdapter RouteTables GuestRouteTablesAdapter SecurityGroups GuestSecurityGroupsAdapter Subnets GuestSubnetsAdapter VPC GuestVPCAdapter }
type GuestAutoScalingGroupAdapter ¶
type GuestAutoScalingGroupAdapter struct { ASGDesiredCapacity int ASGMaxSize int ASGMinSize int ASGType string ClusterID string HealthCheckGracePeriod int MaxBatchSize string MinInstancesInService string PrivateSubnets []string RollingUpdatePauseTime string WorkerAZs []string }
func (*GuestAutoScalingGroupAdapter) Adapt ¶
func (a *GuestAutoScalingGroupAdapter) Adapt(cfg Config) error
type GuestIAMPoliciesAdapter ¶
type GuestIAMPoliciesAdapter struct { ClusterID string EC2ServiceDomain string KMSKeyARN string MasterRoleName string MasterPolicyName string MasterProfileName string RegionARN string S3Bucket string WorkerRoleName string WorkerPolicyName string WorkerProfileName string }
func (*GuestIAMPoliciesAdapter) Adapt ¶
func (i *GuestIAMPoliciesAdapter) Adapt(cfg Config) error
type GuestInstanceAdapter ¶
type GuestInstanceAdapter struct { Cluster GuestInstanceAdapterCluster Image GuestInstanceAdapterImage Master GuestInstanceAdapterMaster }
func (*GuestInstanceAdapter) Adapt ¶
func (i *GuestInstanceAdapter) Adapt(config Config) error
type GuestInstanceAdapterCluster ¶
type GuestInstanceAdapterCluster struct {
ID string
}
type GuestInstanceAdapterImage ¶
type GuestInstanceAdapterImage struct {
ID string
}
type GuestInstanceAdapterMaster ¶
type GuestInstanceAdapterMaster struct { AZ string CloudConfig string EncrypterBackend string DockerVolume GuestInstanceAdapterMasterDockerVolume EtcdVolume GuestInstanceAdapterMasterEtcdVolume LogVolume GuestInstanceAdapterMasterLogVolume Instance GuestInstanceAdapterMasterInstance PrivateSubnet string }
type GuestInstanceAdapterMasterEtcdVolume ¶
type GuestInstanceAdapterMasterEtcdVolume struct {
Name string
}
type GuestInstanceAdapterMasterLogVolume ¶
type GuestInstanceAdapterMasterLogVolume struct {
Name string
}
type GuestInternetGatewayAdapter ¶
func (*GuestInternetGatewayAdapter) Adapt ¶
func (a *GuestInternetGatewayAdapter) Adapt(cfg Config) error
type GuestLaunchConfigAdapter ¶
type GuestLaunchConfigAdapter struct { ASGType string WorkerAssociatePublicIPAddress bool WorkerBlockDeviceMappings []BlockDeviceMapping WorkerInstanceMonitoring bool WorkerInstanceType string WorkerImageID string WorkerSecurityGroupID string WorkerSmallCloudConfig string }
func (*GuestLaunchConfigAdapter) Adapt ¶
func (l *GuestLaunchConfigAdapter) Adapt(config Config) error
type GuestLifecycleHooksAdapter ¶
type GuestLifecycleHooksAdapter struct {
Worker GuestLifecycleHooksAdapterWorker
}
func (*GuestLifecycleHooksAdapter) Adapt ¶
func (a *GuestLifecycleHooksAdapter) Adapt(config Config) error
type GuestLifecycleHooksAdapterASG ¶
type GuestLifecycleHooksAdapterASG struct {
Ref string
}
type GuestLifecycleHooksAdapterLifecycleHook ¶
type GuestLifecycleHooksAdapterLifecycleHook struct {
Name string
}
type GuestLifecycleHooksAdapterWorker ¶
type GuestLifecycleHooksAdapterWorker struct { ASG GuestLifecycleHooksAdapterASG LifecycleHook GuestLifecycleHooksAdapterLifecycleHook }
type GuestLoadBalancersAdapter ¶
type GuestLoadBalancersAdapter struct { APIElbHealthCheckTarget string APIElbName string APIElbPortsToOpen []GuestLoadBalancersAdapterPortPair APIElbScheme string APIElbSecurityGroupID string EtcdElbHealthCheckTarget string EtcdElbName string EtcdElbPortsToOpen []GuestLoadBalancersAdapterPortPair EtcdElbScheme string EtcdElbSecurityGroupID string ELBHealthCheckHealthyThreshold int ELBHealthCheckInterval int ELBHealthCheckTimeout int ELBHealthCheckUnhealthyThreshold int IngressElbHealthCheckTarget string IngressElbName string IngressElbPortsToOpen []GuestLoadBalancersAdapterPortPair IngressElbScheme string MasterInstanceResourceName string PublicSubnets []string PrivateSubnets []string }
func (*GuestLoadBalancersAdapter) Adapt ¶
func (a *GuestLoadBalancersAdapter) Adapt(cfg Config) error
type GuestNATGatewayAdapter ¶
type GuestNATGatewayAdapter struct {
Gateways []Gateway
}
func (*GuestNATGatewayAdapter) Adapt ¶
func (a *GuestNATGatewayAdapter) Adapt(cfg Config) error
type GuestOutputsAdapter ¶
type GuestOutputsAdapter struct { Master GuestOutputsAdapterMaster Worker GuestOutputsAdapterWorker Route53Enabled bool VersionBundle GuestOutputsAdapterVersionBundle }
func (*GuestOutputsAdapter) Adapt ¶
func (a *GuestOutputsAdapter) Adapt(config Config) error
type GuestOutputsAdapterMaster ¶
type GuestOutputsAdapterMaster struct { ImageID string Instance GuestOutputsAdapterMasterInstance CloudConfig GuestOutputsAdapterMasterCloudConfig DockerVolume GuestOutputsAdapterMasterDockerVolume }
type GuestOutputsAdapterMasterCloudConfig ¶
type GuestOutputsAdapterMasterCloudConfig struct {
Version string
}
type GuestOutputsAdapterMasterDockerVolume ¶
type GuestOutputsAdapterMasterDockerVolume struct {
ResourceName string
}
type GuestOutputsAdapterVersionBundle ¶
type GuestOutputsAdapterVersionBundle struct {
Version string
}
type GuestOutputsAdapterWorker ¶
type GuestOutputsAdapterWorker struct { ASG GuestOutputsAdapterWorkerASG CloudConfig GuestOutputsAdapterWorkerCloudConfig DockerVolumeSizeGB string ImageID string InstanceType string }
type GuestOutputsAdapterWorkerASG ¶
type GuestOutputsAdapterWorkerASG struct {
Ref string
}
type GuestOutputsAdapterWorkerCloudConfig ¶
type GuestOutputsAdapterWorkerCloudConfig struct {
Version string
}
type GuestRecordSetsAdapter ¶
type GuestRecordSetsAdapter struct { BaseDomain string EtcdDomain string ClusterID string MasterInstanceResourceName string Route53Enabled bool }
func (*GuestRecordSetsAdapter) Adapt ¶
func (a *GuestRecordSetsAdapter) Adapt(config Config) error
type GuestRouteTablesAdapter ¶
type GuestRouteTablesAdapter struct { HostClusterCIDR string PublicRouteTableName RouteTableName PrivateRouteTableNames []RouteTableName }
func (*GuestRouteTablesAdapter) Adapt ¶
func (r *GuestRouteTablesAdapter) Adapt(cfg Config) error
type GuestSecurityGroupsAdapter ¶
type GuestSecurityGroupsAdapter struct { APIWhitelistEnabled bool MasterSecurityGroupName string MasterSecurityGroupRules []securityGroupRule WorkerSecurityGroupName string WorkerSecurityGroupRules []securityGroupRule IngressSecurityGroupName string IngressSecurityGroupRules []securityGroupRule EtcdELBSecurityGroupName string EtcdELBSecurityGroupRules []securityGroupRule }
func (*GuestSecurityGroupsAdapter) Adapt ¶
func (s *GuestSecurityGroupsAdapter) Adapt(cfg Config) error
type GuestSubnetsAdapter ¶
func (*GuestSubnetsAdapter) Adapt ¶
func (s *GuestSubnetsAdapter) Adapt(cfg Config) error
type GuestVPCAdapter ¶
type GuestVPCAdapter struct { CidrBlock string ClusterID string InstallationName string HostAccountID string PeerVPCID string PeerRoleArn string Region string RegionARN string RouteTableNames []RouteTableName }
func (*GuestVPCAdapter) Adapt ¶
func (v *GuestVPCAdapter) Adapt(cfg Config) error
type RouteTableAssociation ¶
type RouteTableName ¶
type SmallCloudconfigConfig ¶
SmallCloudconfigConfig represents the data structure required for executing the small cloudconfig template.
type StackState ¶
type StackState struct { Name string DockerVolumeResourceName string MasterImageID string MasterInstanceType string MasterInstanceResourceName string // TODO the cloud config versions shouldn't be injected here. These should // actually always only be the ones the operator has hard coded. No other // version should be used here ever. MasterCloudConfigVersion string MasterInstanceMonitoring bool // TODO the cloud config versions shouldn't be injected here. These should // actually always only be the ones the operator has hard coded. No other // version should be used here ever. WorkerCloudConfigVersion string WorkerDesired int WorkerDockerVolumeSizeGB string WorkerKubeletVolumeSizeGB string WorkerLogVolumeSizeGB string WorkerImageID string WorkerInstanceMonitoring bool WorkerInstanceType string WorkerMax int WorkerMin int VersionBundleVersion string }
TODO we copy this because of a circular import issue with the cloudformation resource. The way how the resource works with the adapter and how infromation is passed has to be reworked at some point. Just hacking this now to keep going and to keep the changes as minimal as possible.
Source Files ¶
- adapter.go
- error.go
- guest_auto_scaling_group.go
- guest_iam_policies.go
- guest_instance.go
- guest_internet_gateway.go
- guest_launch_configuration.go
- guest_lifecycle_hooks.go
- guest_load_balancers.go
- guest_nat_gateway.go
- guest_outputs.go
- guest_record_sets.go
- guest_route_tables.go
- guest_security_groups.go
- guest_subnets.go
- guest_vpc.go
- spec.go