Giter Site home page Giter Site logo

ravisivajiraavi / kubernetes-installation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saikiranpi/kubernetes-installation

0.0 0.0 0.0 16 KB

I build this project to create my own lab for Kuberntes cluster on AWS cloud using EC2 instances. I found Terraform is best tool to create my K8S lab fastly with one command ๐Ÿš€. Terraform

Shell 46.03% HCL 53.97%

kubernetes-installation's Introduction

Terraform to Bulding Kubernetes Cluster using EC2 instances

LinkedIn GitHub

I built this project to create my own lab for Kuberntes cluster on AWS cloud using EC2 instances. I found Terraform is the best tool to create my K8S lab fastly with one command ๐Ÿš€.

Terraform

Terraform Resources Used

  • EC2
    • One Master Node
    • Two Worker Node (can be increased)
  • VPC
    • Public Subnet
    • Internet Gateway
    • Route Table
    • Security Group
  • S3 Bucket

How Will the Kubernetes Cluster Be Built?

The goal is to build a K8S cluster with one master node and two worker nodes.

  • First, the master node will boot up and will start installing kubeadm, kubelet, kubectl, and docker. Then will run kubeadm init to initial the k8s cluster.
    Here the challenge becomes how we can get the join command that showed after init the cluster and send it to the workers node for joining the worker node into the cluster ๐Ÿค”?
    To solve this problem I use s3 bucket. First I extracted the join command and saved it into a file, and then pushed it to the s3 object. Now we finish from the master node and is ready.

  • Second, the workers node will boot up and will start installing kubeadm, kubelet, kubectl, and docker. Then will fetch the joined command from s3 bucket and execute to join the worker node into the cluster.

Incress Number of Worker Nodes

  • By default there are two workers on the cluster, to increase it go to variables.tf file and looking for number_of_worker variable, you can increase the default number.

Requirements Before Running

1- Make sure you have the Terraform tools installed on your machine.

2- Add your Access key, Secret key, and Key Pair name on variables.tf file.

3- Make sure your IAM user has the right permission to create EC2, VPC, S3, Route Table, Security Group, and Internet Gateway.

Running the Script

After doing the requirements, you are ready now, start cloning the repo to your machine:

git clone https://github.com/Ahmad-Faqehi/Terraform-Bulding-K8S.git
cd Terraform-Bulding-K8S/

Now execute terraform commands:

terraform init
terraform plan #to show what going to build
terraform apply

Accessing Your Cluster

  • You can access your cluster by accessing the master node through ssh, you can get the public IP of the master node from terraform outputs. Below is an example of the ssh command:
ssh -i <Your_Key_Piar> ubuntu@<MasterNode_Public_IP>
  • Another way to access the cluster is by downloading the admin.conf file from the master node to your machine, find below the way to download it and access the cluster remotely.
scp -i <Your_Key_Piar> ubuntu@<MasterNode_Public_IP>:/tmp/admin.conf .

This will download the Kubernetes config file on your machine. Before using this config file, you have to replace the private IP with the public IP of the master node. Then you can use the following command to start accessing the cluster.

kubectl --kubeconfig ./admin.conf get nodes

Removing and Destroying Kubernetes Cluster

To destroy all the resources that were created after applying the script, just run the following command:

terraform destroy

kubernetes-installation's People

Contributors

saikiranpi avatar devesh-n avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.