Kops is an official Kubernetes project for managing a Kubernetes clusters in aws.
Kops Stands for Kubernetes Operations.
Kops is currently the best tool to deploy Kubernetes clusters to Amazon Web Services.
Kops has commands for creating clusters, updating settings, and applying changes , Kops automates a large part of operating Kubernetes on AWS.
Kops only availabe for Linux and Mac Platforms.
Prepare AWS for Kops
Management Node (Local System - ubuntu 20.0.4)
In this management node below requirements must be required for kops.
1.kops
2.kubectl
3.aws cli
4.s3 bucket access
AWS
- Create an IAM User
- Assign the Permissions
- Create S3 bucket for storing KOPS_STORE_STATE
- Route53
Install kops on Ubuntu 20.0.4
curl -Lo kops 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
sudo mv kops /usr/local/bin/kops
Install kubectl on Ubuntu 20.0.4
Update the apt package index and install packages needed to use the Kubernetes apt repository
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
Download the Google Cloud public signing key:
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
Add the Kubernetes apt repository
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Update apt package index with the new repository and install kubectl
sudo apt-get update
sudo apt-get install -y kubectl
Installing AWS CLI
sudo apt install awscli
Verify AWS CLI using command
aws
Create/Log-in AWS Console Account.
SetUp AWS IAM permission for Kops.
Create a user(kops) and give them permission.
Permission required for Kops user
AmazonEC2FullAccess
AmazonRoute53FullAccess
AmazonS3FullAccess
IAMFullAccess
AmazonVPCFullAccess
OR
AdministratorAccess
Configure User with AWS Account.
Run command on your machine
aws configure
Provide AWS access Key and AWS Secret Access Key.
Specify Default region or Output format.
Verify credentials and config.
ls -lrt ~/.aws/
S3 bucket for the KOPS_STATE_STORE.
KOPS_STATE_STORE is the source of truth for all clusters managed by Kops.
Get fastest Region for Deploy the S3 Bucket.
Create an S3 bucket for KOPS_STATE-STORE
aws s3 mb s3://<bucket-name>
aws s3 mb s3://k8s-test-123
User can use cloudping to choose the fastest region as per their location.
Kops clusters must be valid DNS names.
We need to SetUp DNS for the Kops Clusters.
SetUp DNS in AWS Route53.
I have a Domain cloudmates.in which is availabe in Godaddy
For creating DNS in Route53
Go to Route53
Create Hosted Zone
Zone Name kops.cloudmates.in
Copy The NS records and create NS in your Domain Name Provider once completes validate the dns
dig -t ns=kops.cloudmates.in
With Kops 1.6.2 or later, then DNS configuration is optional.
The only requirement to trigger this is to have the cluster name end with .k8s.local
SetUp Kubernetes Cluster on AWS with Kops
Generate SSH Key
ssh-keygen -f .ssh/id_rsa
Create Cluster Syntax
kops create cluster --yes --state=<s3://<Define S3 Bucket Name>> --zones=<One or more Zones> --node-count=<Number of Nodes> --node-size=<Define Machine Size> --master-size=<Master Node Size> --name=<Define DNS Name>
Create Cluster with Route53 hosted zone
kops create cluster --yes --state=s3://k8s-storage-a12345 --zones=ap-south-1a --node-count=2 --node-size=t2.micro --master-size=t2.micro --name=kops.cloudmates.in
Verify Node Status
kubectl get node
Validate Cluster
kops validate cluster --state=<s3://<Define S3 Bucket Name>
kops validate cluster --state=s3://k8s-test-123`
### Execute Custom Image on AWS kubernetes
*Create AWS Kubernetes Cluster Without Domain Name *
kops create cluster --yes --state=s3://k8s-test-123 --zones=ap-south-1a --node-size=t2.micro --node-count=2 --master-size=t2.micro --name=test.k8s.local
Verify Kubernetes Cluster.(Different Formats)
kops validate cluster
kops validate cluster -o json
kops validate cluster -o yaml
Start the Deployment on Kubernetes Cluster.
kubectl create deployment myweb --image=cloudmates/customnginx
Get Information of Running Deployments
kubectl get deployments
Describe the Running Deployment
kubectl describe deployment myweb
Make the myweb container accessible via the internet loadbalancer
kubectl create service loadbalancer myweb --tcp=80:80
Get Running Services
kubectl get svc
Remove Services
kubectl delete services myweb
Remove Deployment
kubectl delete deployment myweb
Delete Cluster
kops delete cluster cloudmates.in --yes --state=s3://k8s-test-123
Top comments (0)