Introduction
EKS is a managed Kubernetes service provided by AWS. It cost $0.01 per hour while it provides a scalable and high availability service. It is actually very convenient and you can treat it as a control panel for k8s.
But as a poor guy like me, I am always looking for a cheaper way to get the same/similar outcome. KOPS is the alternative tool. It will create a master node which can help us to manage the k8s cluster. The master node is an instance similar to the EKS. The different is that we can select a different instance type for it. For the pricing, we can purchase reserved instances to lower the cost also.
Let’s have a look to see how to use KOPS to create k8s cluster on AWS. For the workloads deployment, we can reuse kubectl, it should be the same as this story.
Reference
Learn from here.
Docker file for Kops
Steps
Cluster management
The workflow of using KOPS is like this. You need to login to AWS CLI with a user who has the correct permission. After that, you need to create a cluster configuration by selecting the zone, instance type, number of nodes etc..
Then you can deploy your configuration to the cloud.
IAM on AWS for KOPS user
You need to create a group with the following permissions.
You can then create a user and get the access key and id for AWS CLI login
Create cluster
You can use the docker file from the above section and run the following commands to create your cluster.
export CLUSTER_REGION=us-east-1 export CLUSTER_NAME=thecluster.k8s.local # must end with *.k8s.local export KOPS_S3=thecluster-kops-state-storage export KOPS_STATE_STORE=s3://${KOPS_S3} aws configure set aws_access_key_id "$AWS_KOPS_USER_ID" aws configure set aws_secret_access_key "$AWS_KOPS_USER_PW" aws configure set region "$CLUSTER_REGION" # create S3 bucket for kops configuration storage aws s3api create-bucket --bucket ${KOPS_S3} --region ${CLUSTER_REGION} # create cluster configuration kops create cluster --zones ${CLUSTER_REGION}a,${CLUSTER_REGION}b --name=${CLUSTER_NAME} --node-size t3.medium --master-size t3.medium --node-count 2
kubectrl cheatsheet
## view / edit cluster ## # list clusters with: $ kops get cluster --name=${NAME} # edit this cluster with: $ kops edit cluster --name=${NAME} # edit your node instance group: $ kops edit ig --name=${NAME} nodes-us-east-1a # edit your master instance group: $ kops edit ig --name=${NAME} master-us-east-1a # list your full instance group: $ kops get ig --name=${NAME} # apply your instance group and create the cluster: $ kops update cluster --name=${NAME} --yes --admin=87600h # check if the cluster is up and running: $ kops validate cluster --name=${NAME} ## create cluster ## # create cluster on cloud $ kops update cluster --name=${CLUSTER_NAME} --yes --admin=87600h # check if the cluster is up and running: $ kops validate cluster --name=${NAME} ## delete cluster ## # delete cluster $ kops delete cluster --name=${CLUSTER_NAME} --yes
Done



Comments
Post a Comment