What is KOPS in Kubernetes
What is KOPS in Kubernetes
Kops (Kubernetes Operations) used to you create, destroy, upgrade and maintain
production-grade, highly available, Kubernetes clusters using command line.
We can Add and Edit the Cluster configuration such as Master and worker nodes
Below are prerequisites to setup kubernetes on aws using kops.
1. AWS account
2. Create a Domain to Access Kubernetes API
4. Create a S3 bucket with Versioning Enabled to store Kubernetes Kops cluster state
5. IAM user with full S3, EC2, Route53 and VPC access
6. Ubuntu 20.04/18.04/16.04 LTS with minimal installation
7. AWS-CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o
"awscliv2.zip"
if you want download specific version of AWS CLI version then use below command
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64-
awscliversion.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
Output:
sudo ./aws/install
/usr/local/bin/aws --version
Output:
OR
aws --version
Output:
You can create either public or private hosted zone, if you created public hosted zone you
have to point AWS nameservers in Domain.
Here We have domain in GoDaddy, created public hosted zone in AWS and pointed AWS
nameservers in GoDaddy Domain
Configure AWS CLI with your Access Key ID, Secret Access key and region
aws configure
1. AmazonS3FullAccess
2. AmazonEC2FullAccess
3. AmazonRoute53FullAccess
4. IAMFullAccess
5. AmazonVPCFullAccess
Step #7: Creating S3 Bucket using command
line
Create the S3 bucket to store Kubernetes cluster states
aws s3 mb s3://k8s.fosstechnix.info
export KOPS_STATE_STORE=s3://k8s.fosstechnix.info
if you want to install calico networking along with setup of Kubernetes KOPS add –
networking with calico as shown below
If you want to create K8s cluster using multimaster and different availability zone use
below command
Sample Output:
Suggestions:
Sample Output:
Suggestions:
kubectl cluster-info
kops get ig
Output:
Output:
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
creationTimestamp: "2021-03-06T05:29:52Z"
labels:
kops.k8s.io/cluster: k8s.fosstechnix.info
name: master-ap-south-1a
spec:
image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-
20210119.1
machineType: t3.medium
maxSize: 1
minSize: 1
nodeLabels:
kops.k8s.io/instancegroup: master-ap-south-1a
role: Master
subnets:
- ap-south-1a
Troubleshooting:
Error:
Solution:
cd .kube
copy the client-certificate-data and client-key-data values, exit from master node
Error: exactly one ‘admin’ SSH public key can be specified when running with AWS; please
delete a key using `kops delete secret`
Solution:
Output:
TYPE NAME ID
Keypair apiserver-aggregator-ca
6933429814222041362322666137
Keypair ca
6933429813663588303876984541
Keypair etcd-clients-ca
6933429813788008634835356814
Keypair etcd-manager-ca-events
6933429814919214502125133873
Keypair etcd-manager-ca-main
6933429813961434714756350017
Keypair etcd-peers-ca-events
6933429814048350100913985823
Keypair etcd-peers-ca-main
6933429814135513819119005976
Keypair master
6933429813874453479985214673
SSHPublicKey admin
01:98:16:b4:a0:44:99:6c:a8:f7:6c:3b:a2:43:0b:c2
SSHPublicKey admin
6e:14:33:11:9c:4a:0c:0a:70:68:53:c1:b1:7e:cb:bd
SSHPublicKey admin
78:6a:e1:00:74:e6:ee:95:fa:32:fc:ae:2a:d7:63:68
Secret admin
Secret kube
Secret kube-proxy
Secret kubelet
Secret system:controller_manager
Secret system:dns
Secret system:logging
Secret system:monitoring
Secret system:scheduler
Delete the duplicate secret from kops cluster using below command
export KOPS_STATE_STORE=s3://k8s.fosstechnix.info
export CLUSTER_NAME=k8s.fosstechnix.info
export VPC_ID=VPC_ID
export NETWORK_CIDR=172.20.0.0/16
Now create Kubernetes Kops cluster
Conclusion:
We have covered How to Setup Kubernetes on AWS using KOPS, install kops, install
kubectl, creating S3 bucket, genrate ssh keygen.