How to create a AWS kubernetes cluster easy and quickly
- Download and Install kops:
# 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
# mv kops-linux-amd64 /usr/local/bin/kops
# kops version
Version 1.15.0 (git-9992b4055)
- Install AWS cli:
# pip3 install awscli --upgrade --user
# aws --version
aws-cli/1.14.28 Python/2.7.5 Linux/3.10.0-1062.9.1.el7.x86_64 botocore/1.8.35
- Configure AWS cli to work with your AWS account:
# aws configure
We need configure:
- AWS Acces Key ID
- AWS Secret Access Key
- Default region and
- Default output format: is "blank" and ENTER.
- Create a bucket in your AWS for the cluster configurations:
# aws s3api create-bucket --bucket <name new bucket> --region <AWS region> --create-bucket-configuration LocationConstraint=<AWS region>
For example:
# aws s3api create-bucket --bucket mycluster-k8s-demo --region us-west-2 --create-bucket-configuration LocationConstraint=us-west-2
- Set the KOPS_STATE_STORE environment variable:
# export KOPS_STATE_STORE=s3://mycluster-k8s-demo
- Create a kubernetes cluster with kops:
# kops create cluster mycluster-k8s-demo.k8s.local --zones us-west2 --yes
Wait something minutes...
- Validate your kubernetes cluster:
# kops validate cluster
- List nodes:
# kubectl get nodes --show-labels
At this point, your k8s cluster is ready for jobs.
- To connect to master node, check your EC2 instances public URL (In your AWS Console - EC2 instances) and connect with ssh using:
# ssh .i ~/.ssh/id_rsa admin@<your public address to master node>
For example:
# ssh -i ~/.ssh/id_rsa admin@ec2-54-244-170-110.us-west-2.compute.amazonaws.com
- To End, AWS charges! If you are not going to use the cluster, delete it, if you don't do it then pay what you consume, AWS Law.
# kops delete cluster <full name cluster>
For example:
# kops delete cluster mycluster-k8s-demo.k8s.local
Remember check your AWS Console to ensure the deleted of resources or close or delete your AWS account for more security.
Comentarios
Publicar un comentario