Bleeding-Edge Kubernetes on AWS with KOPS (Kubernetes operations).

Bleeding-Edge Kubernetes on AWS with KOPS (Kubernetes operations).

ONjection Labs - Hire DevOps Developers

KOPS:  Build production grade K8s.

 Why KOPS

  • Automates the provisioning of Kubernetes clusters in AWS  and GCE
  • Deploy Master-Master Kubernetes cluster.
  • Generate terraform managed file (kubernetes.tf)
  • Add master and slave nodes in autoscaling group to ensure nodes are running properly.
  • Supports custom Kubernetes add-ons
  • Enabled CLI tab completion for easy operation
  • Rolling upgrade of cluster resources without downtime.
  • Ability to dry run on templates to ensure there is no syntax errors.

 Setting Up kubernetes cluster in 5 easy steps:

 Requirements

  • Kops and kubectl command line tool.
  • Aws CLI, user access key ID and secret access key
  • Install KOPS command line tool.
      • 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
      • chmod +x kops-linux-amd64
      • cp kops-linux-amd64 /usr/bin/kops
  • Install Kubectl from below link:

 https://kubernetes.io/docs/tasks/tools/install-kubectl/

  • Install AWS CLI to use your access key ID and secret access key:
    • pip install awscli –upgrade
    • pip install awscli –upgrade –ignore-installed six # if get an error then run this command

 Getting start

  1. Create a new IAM user or use an existing IAM user and grant following permissions:
  • AmazonEC2FullAccess
  • AmazonRoute53FullAccess
  • AmazonS3FullAccess
  • AmazonVPCFullAccess
  1. Create Amazon S3 bucket for kops to persist its state. Replace mybucketkops with yours
    • export bucket_name=mybucketkops
    • aws s3api create-bucket –bucket ${bucket_name} –region us-east-1
  1. Enable versioning to revert or recover a previous state store by KOPS.
    • aws s3api put-bucket-versioning –bucket ${bucket_name} –versioning-configuration Status=Enabled
  1. Exporting env variables to bashrc / profile for KOPS

export KOPS_CLUSTER_NAME=mykubernetes.k8s.local

export KOPS_STATE_STORE=s3://${bucket_name}

  1. Generate ssh-keys to interact for KOPSs
  • ssh-keygen -t rsa
  1. Build the cluster using KOPS CLI and save to S3 bucket using below command:

kops create cluster –cloud=aws –node-count=2 –node-size=t2.medium –zones=us-east-1a –yes

  1. Validate kubernetes cluster using the command: `kops validate cluster`. This will take some to up the cluster. It might throw an error connection refused.
  1. Get cluster list: ` kops get cluster `
  1. Checking kubernetes cluster node ready status:- `kubectl get nodes`

Cleaning up

      Delete created infra with Kops using the command: `kops delete cluster –yes`

What’s next?

  • Deploy Kubernetes cluster on Amazon Aws using Kops & Terraform in existing VPC.
  • Manage Kubernetes master node using terraform.
  • Kubeadm to automate the installation and configuration of Kubernetes cluster.
  • Kops vs Kubeadm bootstrapping to build Kubernetes cluster.
  • Deployment of front and backend in Kubernetes cluster.