- kops
- kubectl
- awscli configured
- For cluster creating we need to add more env variables. NAME will be the name of the cluster, since we wont do DNS settings we will use gossip based DNS and for that cluster name needs to end with
.k8s.local
and before that you can put almost anything.
export NAME=vhd-demo.k8s.local
- Create a bucket for kops to use a backend.
aws s3api create-bucket --bucket ${NAME}-state --region ap-south-1 --create-bucket-configuration LocationConstraint=ap-south-1
- Add env var for bucket state store.
export KOPS_STATE_STORE=s3://${NAME}-state
- Create the kops cluster.
kops create cluster \
--name=${NAME} \
--zones=ap-south-1a \
--master-size="t3.medium" \
--node-size="t3.medium" \
--node-count="3" \
--master-count="1" \
--ssh-public-key="~/.ssh/id_rsa.pub"
- Update the kops cluster to make actual changes in AWS.
kops update cluster --name ${NAME} --yes
- Validate the created cluster, it might take a while to get it up and running.
kops validate cluster
- Get the instance group names.
kops get ig
- Edit the instance group for the nodes and set maxSize and minSize to 0.
kops edit ig nodes
- Edit the instance group for the master and set maxSize and minSize to 0.
kops edit ig master-ap-south-1a
- Lastly, update the cluster to apply changes.
kops update cluster --yes
- Changes may require instances to restart.
kops rolling-update cluster
- If you want to turn your cluster back on, revert the settings, changing your master to at least 1, and your nodes to your liking, example 2. Then perform
update cluster
as earlier.
- Delete the kops cluster.
kops delete cluster ${NAME} --yes
- Delete the s3 bucket backend.
aws s3api delete-bucket --bucket ${NAME}-state --region ap-south-1
PS : This is not production ready.