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.
Get terraform package.
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.
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.
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
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.
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.