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

marco.cirilli
from marco.cirilli More from this publisher
19.06.2021 Views

Initializing a CloudFormationChapter 4 ■ Using Multiple ZonesInitializing a CloudFormation stack is discussed in detail in Chapter 2. The procedure to create an AWSCloudFormation is as follows:1. Install Kube-aws (required to be installed only once for the Amazon Linuxinstance).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.pemchmod 400 kubernetes-coreos.pemThe 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 clustercalled kubernetes-coreos-cluster with the asset directory kube-coreos-cluster is initialized as follows:mkdir kube-coreos-clustercd kube-coreos-clusterkube-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 renderConfiguring cluster.yaml for Multiple ZonesBy default a single zone is used to launch a CloudFormation. Next, we shall customize the CloudFormationto configure multiple zones. Open the cluster.yaml file in a vi editor:sudo vi cluster.yamlThe region to provision the CloudFormation is set to us-east-1 as specified in the kube-aws initcommand. 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 defaultworkerCount, which specifies the number of worker nodes to create, is set to 1. To demonstrate a multiplezonecluster, the worker nodes must be set to at least the number of zones to configure. Set workerCount to 6as shown in Figure 4-6.95

Chapter 4 ■ Using Multiple ZonesFigure 4-6. Setting workerCount to 6Cluster.yaml is configured for a single availability zone by default, and the instanceCIDR settingspecifies the CIDR for the Kubernetes subnet. For multiple availability zones the instanceCIDR must becommented out, as we need to configure multiple subnets in cluster.yaml. In setting subnets, specify theKubernetes subnets and their CIDRs and availability zones. The objective of high availability is that failureof a single zone does not result in interruption in the service. At least two subnets must be specified for highavailability of zones. Each subnet is specified as an availabilityZone setting and an instanceCIDR setting.The availability zones that could be specified must be available to create subnets. If an availability zone is notavailable, an error such as the one shown in Figure 4-7 is generated when the CloudFormation is launched.96

Chapter 4 ■ Using Multiple Zones

Figure 4-6. Setting workerCount to 6

Cluster.yaml is configured for a single availability zone by default, and the instanceCIDR setting

specifies the CIDR for the Kubernetes subnet. For multiple availability zones the instanceCIDR must be

commented out, as we need to configure multiple subnets in cluster.yaml. In setting subnets, specify the

Kubernetes subnets and their CIDRs and availability zones. The objective of high availability is that failure

of a single zone does not result in interruption in the service. At least two subnets must be specified for high

availability of zones. Each subnet is specified as an availabilityZone setting and an instanceCIDR setting.

The availability zones that could be specified must be available to create subnets. If an availability zone is not

available, an error such as the one shown in Figure 4-7 is generated when the CloudFormation is launched.

96

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

Saved successfully!

Ooh no, something went wrong!