aws

package module
v0.0.0-...-b405a1f Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

README

Cluster API Provider AWS

Build the controller

Update dependencies if needed:

make deps

Then:

cd cmd
go build

Test the actuator standalone

Run the expected prebuild environment:

create an aws iam profile/role named openshift_node_describe_instances
create an aws iam profile/role named openshift_master_launch_instances
create an aws ssh key named actuator
cd aws-actuator-test/prebuild
terraform apply

Then:

cd aws-actuator-test
go build
./aws-actuator-test create test
./aws-actuator-test exists test
./aws-actuator-test delete test

Test the actuator along with the machine controller and the cluster API on minikube

Run the expected prebuild environment as above. Then:

minikube start
eval $(minikube docker-env)

Change source code and:

make aws-machine-controller-image

Add your aws credentials to the addons.yaml file in base64 format:

echo -n 'your_id' | base64
echo -n 'your_key' | base64

Deploy the comoponents:

kubectl apply examples/addons.yaml
kubectl apply examples/cluster-api-server.yaml
kubectl apply examples/provider-components.yml

Deploy the machines:

kubectl apply examples/machine.yaml --validate=false

or alternatively:

kubectl apply examples/machine-set.yaml --validate=false

Run it with Cluster API clusterctl

Include the aws provider https://github.com/enxebre/cluster-api/blob/master/clusterctl/cmd/create_cluster.go#L160

dep ensure
cd clusterctl

Follow the docs https://github.com/enxebre/cluster-api/tree/master/clusterctl

go build
./clusterctl create cluster --provider aws -c cluster.yaml -m machines.yaml -p provider-components.yaml -a addons.yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInstances

func GetInstances(machine *clusterv1.Machine, client Client, instanceStateFilter []*string, clusterId string) ([]*ec2.Instance, error)

GetInstances returns all instances that have a tag matching our machine name, and cluster ID.

func GetRunningInstances

func GetRunningInstances(machine *clusterv1.Machine, client Client, clusterId string) ([]*ec2.Instance, error)

GetRunningInstances returns all running instances that have a tag matching our machine name, and cluster ID.

func SortInstances

func SortInstances(instances []*ec2.Instance) (*ec2.Instance, []*ec2.Instance)

SortInstances will examine the given slice of instances and return the current active instance for the machine, as well as a slice of all other instances which the caller may want to terminate. The active instance is calculated as the most recently launched instance. This function should only be called with running instances, not those which are stopped or terminated.

func TerminateInstances

func TerminateInstances(client Client, instances []*ec2.Instance, mLog log.FieldLogger) error

TerminateInstances terminates all provided instances with a single EC2 request.

Types

type Actuator

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

Actuator is the AWS-specific actuator for the Cluster API machine controller

func NewActuator

func NewActuator(kubeClient kubernetes.Interface, clusterClient clusterclient.Interface, logger *log.Entry, defaultAvailabilityZone string) *Actuator

NewActuator returns a new AWS Actuator

func (*Actuator) Create

func (a *Actuator) Create(cluster *clusterv1.Cluster, machine *clusterv1.Machine) error

Create runs a new EC2 instance

func (*Actuator) CreateMachine

func (a *Actuator) CreateMachine(cluster *clusterv1.Cluster, machine *clusterv1.Machine) (*ec2.Instance, error)

CreateMachine starts a new AWS instance as described by the cluster and machine resources

func (*Actuator) Delete

func (a *Actuator) Delete(cluster *clusterv1.Cluster, machine *clusterv1.Machine) error

Delete deletes a machine and updates its finalizer

func (*Actuator) DeleteMachine

func (a *Actuator) DeleteMachine(machine *clusterv1.Machine) error

DeleteMachine deletes an AWS instance

func (*Actuator) Exists

func (a *Actuator) Exists(cluster *clusterv1.Cluster, machine *clusterv1.Machine) (bool, error)

Exists determines if the given machine currently exists. For AWS we query for instances in running state, with a matching name tag, to determine a match.

func (*Actuator) GetIP

func (a *Actuator) GetIP(cluster *clusterv1.Cluster, machine *clusterv1.Machine) (string, error)

Implements ProviderDeployer

func (*Actuator) GetKubeConfig

func (a *Actuator) GetKubeConfig(cluster *clusterv1.Cluster, master *clusterv1.Machine) (string, error)

Implements ProviderDeployer

func (*Actuator) Update

func (a *Actuator) Update(cluster *clusterv1.Cluster, machine *clusterv1.Machine) error

Update attempts to sync machine state with an existing instance. Today this just updates status for details that may have changed. (IPs and hostnames) We do not currently support making any changes to actual machines in AWS. Instead these will be replaced via MachineDeployments.

type Client

Client is a wrapper object for actual AWS SDK clients to allow for easier testing.

func NewClient

func NewClient(kubeClient kubernetes.Interface, mSpec *cov1.MachineSetSpec, namespace, region string) (Client, error)

NewClient creates our client wrapper object for the actual AWS clients we use. For authentication the underlying clients will use either the cluster AWS credentials secret if defined (i.e. in the root cluster), otherwise the IAM profile of the master where the actuator will run. (target clusters)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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