kops helps you create, destroy, upgrade and maintain production-grade, highly available, Kubernetes clusters from the command line.
AWS (Amazon Web Services) is currently officially supported, with GCE in beta support, and VMware vSphere in alpha and other platforms planned.
- AWS Account
- Domain to create DNS records
Kops Installation (Linux) :
$ curl -LO https://github.com/kubernetes/kops/releases/download/$ (curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64 $ chmod +x kops-linux-amd64 $ sudo mv kops-linux-amd64 /usr/local/bin/kops
AWS CLI Installation :
The primary distribution method for the AWS CLI is pip. This is a package manager for Python that provides an easy way to install, upgrade, and remove Python packages and their dependencies.
$ pip install awscli --upgrade --user $ aws --version aws-cli/1.16.59 Python/2.7.5 Linux/3.10.0-957.1.3.el7.x86_64 botocore/1.12.49
AWS CLI configuration :
To launch a cluster in AWS, it is required to configure aws cli with access key and secret key.
Login into AWS console and go to IAM. Create a user with programmatic access and add Administrator policy.
Download the credentials file and place under $HOME/.aws directory. Or add the credentials with “aws configure”command.
$ aws configure AWS Access Key ID : XXXXXXXXXXXXXXXXXXXXX AWS Secret Access Key : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Default region name [us-east-1]: Default output format [json]:
S3 Bucket to store its state :
kops has the notion of a ‘state store’; a location where we store the configuration of your cluster. State is stored here not only when you first create a cluster, but also you can change the state and apply changes to a running cluster.
Goto S3 service and create a bucket.
If you bought a domain with AWS, then you should already have a hosted zone in Route53. If not you have to create a hosted zone with “kubernetes.your-domain.com”
After hosted zone created, add the NS record values in your domain DNS configuration.
I have a domain with Godaddy and below is the DNS configuration.
You can verify your DNS setup with below command
$ dig ns kubernetes.your-domain.com
Now, We are ready to create kubernetes cluster in AWS Cloud.
Create a Kubernetes cluster:
Create a kubernetes cluster using kops command line flags. This command creates cloud-based resources such as networks and virtual machines.
Once the infrastructure is in place Kubernetes is installed on the virtual machines.
$ kops create cluster --name=kubernetes.yourdomain.com --state=s3://kops-state-test-7569 --zones=us-east-1a,us-east-1b,us-east-1c --node-count=2 --node-size=t2.micro --master-size=t2.micro --master-zones=us-east-1a --dns-zone=kubernetes.s3labs.com --cloud aws
If you didn’t specify “–yes” flag, it will ask to run kops update command with –yes.
$ kops update cluster kubernetes.yourdomain.com --state=s3://kops-state-test-7569 --yes
When cluster creation completed, kops automatically configure for kubectl. Also, read the suggestion.
Check the nodes with kubectl get nodes
$ kubectl get nodes NAME STATUS ROLES AGE VERSION ip-172-20-100-182.ec2.internal Ready node 51s v1.11.6 ip-172-20-35-29.ec2.internal Ready node 1m v1.11.6 ip-172-20-45-162.ec2.internal Ready master 2m v1.11.6
To delete the cluster, run kops delete command:
$ kops delete cluster kubernetes.s3labs.com --state=s3://kops-state-test-7569 --yes
For more info click on below link