Skip to content

adecoker/kops-k8s-aws-setup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

kops-kubernetes-cluster-configuration

Landmark Technologies, - Landmark Technologies

Tel: +1 437 215 2483, - +1 437 215 2483

Setting up Kubernetes (K8s) Cluster on AWS Using KOPS

1.kops is a software use to create production ready k8s cluster in a cloud provider like AWS.

  1. kOPS SUPPORTS MULTIPLE CLOUD PROVIDERS

  2. Kops compete with managed kubernestes services like EKS, AKS and GKE

  3. Kops is cheaper than the others.

  4. Kops create production ready K8S.

  5. KOPS create resources like: LoadBalancers, ASG, Launch Configuration, woker node Master node (CONTROL PLANE.

  6. KOPS is IaaC

#!/bin/bash

1) Create Ubuntu EC2 instance in AWS

2) install AWSCLI

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 sudo curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip sudo apt install unzip python -y sudo unzip awscli-bundle.zip sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

3) Install kops software on ubuntu instance:

#Install wget if not installed
sudo apt install wget -y
sudo wget https://github.com/kubernetes/kops/releases/download/v1.22.0/kops-linux-amd64
sudo chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops

4) Install kubectl

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 aws s3 mb s3://nubonglegah.k8.local aws s3 ls

5) Create an IAM role from AWS Console or CLI with below Policies.

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://class21.k8s.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=class21.k8s.local
export KOPS_STATE_STORE=s3://class21.k8s.local

source .bashrc

7) Create sshkeys before creating cluster

ssh-keygen

8) Create kubernetes cluster definitions on S3 bucket

kops create cluster --zones us-east-2c --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

9) Create kubernetes cluser

 kops update cluster ${NAME} --yes

10) Validate your cluster(KOPS will take some time to create cluster ,Execute below commond after 3 or 4 mins)

   kops validate cluster

11) connect to the master node

sh -i ~/.ssh/id_rsa ubuntu@ipAddress
ssh -i ~/.ssh/id_rsa [email protected]

11) To list nodes

  kubectl get nodes 

12) To Delete Cluster

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]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published