Kubernetes deployment on AWS using Terraform

Amazon Web Services (AWS) is a secure cloud services platform, offering compute power, database storage, content delivery and other functionality to help businesses scale and grow. Running web and application servers in the cloud to host dynamic websites.

You’ll need to have the following resources for deploy kubernetes cluster on aws using terraform





Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently.Terraform can help manage infrastructure and resources necessary to run a Kubernetes cluster and schedule the underlying resources.

Terraform Installation

Get terraform package.

wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip 

Unzip the package.

unzip terraform_0.11.13_linux_amd64.zipsudo apt-get install unzip - if you don't have unzip in your system

Move the package to /usr/local/bin.

sudo mv terraform /usr/local/bin/ && rm terraform_0.11.13_linux_amd64.zip

Check if terraform working properly.

terraform --version

Get help terraform.

terraform <command> --help

Kubectl is a client for the Kubernetes API.The Kubernetes API is an HTTP REST API. This API is the real Kubernetes user interface. Kubernetes is fully controlled through this API. This means that every Kubernetes operation is exposed as an API endpoint and can be executed by an HTTP request to this endpoint.

Kubectl Installation

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s  https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectlchmod +x ./kubectlsudo mv ./kubectl /usr/local/bin/kubectl

AWS CLI Installation

Get AWS CLI package.

curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zipapt install unzip python

Unzip the package.

unzip awscli-bundle.zip./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Configure AWS

aws configure

You need access key Id ,region details etc; for configure aws and using kops and kubectl.

Kubernetes Operations (kops) simplifies getting a production-grade Kubernetes cluster up and running.Kops allows deployment of highly available Kubernetes clusters on aws and automatically completes the whole task.

How kops works / K8s running in an AWS VPC (Virtual Private Cloud )

Note- Kubernetes deployment requires custom settings or specific add-ons, then one way to achieve this is by using kops and Terraform.

Kops Installation

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-amd64chmod +x kops-linux-amd64sudo mv kops-linux-amd64 /usr/local/bin/kops

Expose environment variable and create cluster and also create ssh key before creating cluster .Then validate your kubernetes cluster after validation we can list the nodes and also deploy cluster with help of exporters , expose the services using at time of deployment after deployment we can delete the cluster using kops commands.




Learner !!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Understanding APIs and using LinkedIn’s API to make a post

What’s behind the Yahaha mobile application

Get start with NODE-RED

Install Google Assistant In Gnome Shell

Why is DevOps so hard to get right?

Logbook 2: Refining research for Master’s project!

Post Processing on Gson Deserialization

Android and iOS View/Logic Decoupling With Examples

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kritank sharma

Kritank sharma

Learner !!

More from Medium

OpenShift Local Lab Setup on RHEL VM

Kubernetes Architecture from 10,000 feet

Jenkins Pipeline Loads Another Pipeline

Creating Amazon Elastic Container Service for Kubernetes (Amazon EKS)