1.kops is a software use to create production ready k8s cluster in a cloud provider like AWS.
-
kOPS SUPPORTS MULTIPLE CLOUD PROVIDERS
-
Kops compete with managed kubernestes services like EKS, AKS and GKE
-
Kops is cheaper than the others.
-
Kops create production ready K8S.
-
KOPS create resources like: LoadBalancers, ASG, Launch Configuration, woker node Master node (CONTROL PLANE.
-
KOPS is IaaC
#!/bin/bash
sudo adduser kops sudo echo "kops ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/kops sudo su - kops sudo apt update -y sudo apt install unzip wget -y curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install
#Install wget if not installed
sudo apt install wget -y
sudo 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
sudo chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl sudo chmod +x ./kubectl sudo mv ./kubectl /usr/local/bin/kubectl
AmazonEC2FullAccess
AmazonS3FullAccess
IAMFullAccess
AmazonVPCFullAccess
Then Attach IAM role to ubuntu server from Console Select KOPS Server --> Actions --> Instance Settings --> Attach/Replace IAM Role --> Select the role which You Created. --> Save.
6) create an S3 bucket Execute below commond in KOPS Server use unique bucket name if you get bucket name exists error.
aws s3 mb s3://cossybagain.k8.local
aws s3 mb s3://bamen.local
aws s3 ls
ex: s3://nubong.k8s.local
Expose environment variable:
# Add env variables in bashrc
vi .bashrc
# Give Unique Name And S3 Bucket which you created.
export NAME=cossybagain.k8s.local
export KOPS_STATE_STORE=s3://cossybagain.k8.local
source .bashrc
ssh-keygen
kops create cluster --zones us-west-1c --networking weave --master-size t2.medium --master-count 1 --node-size t2.medium --node-count=2 ${NAME}
kops create secret --name ${NAME} sshpublickey admin -i ~/.ssh/id_rsa.pub
kops update cluster ${NAME} --yes --admin
10) Validate your cluster(KOPS will take some time to create cluster ,Execute below commond after 3 or 4 mins)
kops validate cluster
ssh -i ~/.ssh/id_rsa ubuntu@ipAddress
ssh -i ~/.ssh/id_rsa [email protected]
kubectl get nodes
kops delete cluster --name=${NAME} --state=${KOPS_STATE_STORE} --yes
====================================================================================================
13 # IF you want to SSH to Kubernetes Master or Nodes Created by KOPS. You can SSH From KOPS_Server
sh -i ~/.ssh/id_rsa ubuntu@ipAddress ssh -i ~/.ssh/id_rsa [email protected]