How to do it...

We can easily run up a Kubernetes cluster using a single command with parameters containing complete configurations. These parameters are described in the following table:

Parameter

Description

Value in example

--name

This is the name of the cluster. It will also be the domain name of the cluster's entry point. So you can utilize your Route53 DNS domain with a customized name, for example, {your cluster name}.{your Route53 domain name}.

my-cluster.k8s-cookbook.net

--state

This indicates the S3 bucket that stores the status of the cluster in the format s3://{bucket name}.

s3://kubernetes-cookbook

--zones

This is the availability zone where you need to build your cluster.

us-east-1a

--cloud

This is the cloud provider.

aws

--network-cidr

Here, kops helps to create independent CIDR range for the new VPC.

10.0.0.0/16

--master-size

This is the instance size of Kubernetes master.

t2.large

--node-size

This is the instance size of Kubernetes nodes.

t2.medium

--node-count

This is the number of nodes in the cluster.

2

--network

This is the overlay network used in this cluster.

calico

--topology

This helps you decide whether the cluster is public facing.

private

--ssh-public-key

This helps you assign an SSH public key for bastion server, then we may log in through the private key.

~/.ssh/id_rsa.pub

--bastion

This gives you an indication to create the bastion server.

N/A

--yes

This gives you the confirmation for executing immediately.

N/A

 

Now we are ready to compose the configurations into a command and fire it:

$ kops create cluster --name my-cluster.k8s-cookbook.net --state=s3://kubernetes-cookbook --zones us-east-1a --cloud aws --network-cidr 10.0.0.0/16 --master-size t2.large --node-size t2.medium --node-count 2 --networking calico --topology private --ssh-public-key ~/.ssh/id_rsa.pub --bastion --yes
...
I0408 15:19:21.794035 13144 executor.go:91] Tasks: 105 done / 105 total; 0 can run
I0408 15:19:21.794111 13144 dns.go:153] Pre-creating DNS records
I0408 15:19:22.420077 13144 update_cluster.go:248] Exporting kubecfg for cluster
kops has set your kubectl context to my-cluster.k8s-cookbook.net
Cluster is starting. It should be ready in a few minutes.
...

After a few minutes, the command takes out the preceding logs showing what AWS services have been created and served for you kops-built Kubernetes cluster. You can even check your AWS console to verify their relationships, which will look similar to the following diagram:

The components of Kubernetes cluster in AWS created by kops
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.28.107