19.06.2021 Views

148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Initializing a CloudFormation

Chapter 4 ■ Using Multiple Zones

Initializing a CloudFormation stack is discussed in detail in Chapter 2. The procedure to create an AWS

CloudFormation is as follows:

1. Install Kube-aws (required to be installed only once for the Amazon Linux

instance).

2. Set up Cluster Parameters, such as creating an EC2 key pair (kubernetescoreos),

KMS key, and External DNS name (oramagsearch.com).

3. Create an Asset Directory for a cluster CloudFormation.

4. Initialize the cluster CloudFormation.

5. Render the Contents of the asset directory.

A typical command to create an EC2 key pair is as follows:

aws ec2 create-key-pair --key-name kubernetes-coreos --query 'KeyMaterial' --output text >

kubernetes-coreos.pem

chmod 400 kubernetes-coreos.pem

The command to create a KMS key is as follows:

aws kms --region=us-east-1 create-key --description="kube-aws assets"

Copy the KeyMetadata.Arn string and use it to initialize a CloudFormation stack; for example, a cluster

called kubernetes-coreos-cluster with the asset directory kube-coreos-cluster is initialized as follows:

mkdir kube-coreos-cluster

cd kube-coreos-cluster

kube-aws init --cluster-name=kubernetes-coreos-cluster --external-dns-name=ORAMAGSEARCH.COM

--region=us-east-1 --availability-zone=us-east-1c --key-name=kubernetes-coreos --kms-keyarn="arn:aws:kms:us-east-1:xxxxxxxxxx:key/xxxxxxxxxxxxxxxxxxx"

The command to render the contents of an assets directory is as follows:

kube-aws render

Configuring cluster.yaml for Multiple Zones

By default a single zone is used to launch a CloudFormation. Next, we shall customize the CloudFormation

to configure multiple zones. Open the cluster.yaml file in a vi editor:

sudo vi cluster.yaml

The region to provision the CloudFormation is set to us-east-1 as specified in the kube-aws init

command. The availabilityZone is set to us-east-1c also as specified in the kube-aws init command.

For a multi-availability zone or multiple zones, comment out the availabilityZone. By default

workerCount, which specifies the number of worker nodes to create, is set to 1. To demonstrate a multiplezone

cluster, the worker nodes must be set to at least the number of zones to configure. Set workerCount to 6

as shown in Figure 4-6.

95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!