Git Product home page Git Product logo

azureproj4's Introduction

Infrastructure deployment of VM, VM Scale sets and AKS using Terraform

In Capstone project 3,we created an automated provisioned infrastructure using Terraform, EKS cluster, EC2 instances. In this we will create similar in in azure using terraform, AKS and Virtual machine and VM scale sets.

For Virtual machine scale sets configuration, we would need to configure the below:

  • Resource Group
  • Virtual network
  • Subnet
  • Public ip
  • Load balance and backend pools
  • Virtual machine scale sets
  • Virtual machine
  • Public ip and network interface for the Virtual machine

Steps done:

1. Check terraform setup:

We will use terraform from azure cloud shell.

First we will check if the cloud shell has terraform:

It will already have the terraform.

Now we have to check the subsciption it is using:

It is using the correct subscription.

If you are using from other systems you will have to install azure cli and run az login command.

We will now create new directory for terraform and initalize the git because we want to send the files to git once we have completed the task for future use

2. Write the script for a virtual machine and a Virtual machine scale sets:

First we wil create providers.tf file which will have provider and version details:

https://github.com/kotianrakshith/AzureProj4/blob/main/providers.tf

Next we will create resourcegroup.tf :

https://github.com/kotianrakshith/AzureProj4/blob/main/resourcegroup.tf

One for randomstring.tf:

https://github.com/kotianrakshith/AzureProj4/blob/main/randomstring.tf

Next we will write for virtual network: vn.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/vn.tf

Next we will write for subnet: subnet.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/subnet.tf

Next we will write for publicip: publicip.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/publicip.tf

Next write for loadbalancer: lb.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/lb.tf

This will include the load balancer, backend address pool, load balancer probe, load balancer rule:

Now you can write for virtual machine scale sets: vmss.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/vmss.tf

Now write the configuration for virtual machine: vm.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/vm.tf

We have created required files for the virtual machine scale sets:

We will push it to github our porgress till here.

We have added the files and comitted:

Then we can push using git push -u origin main

We will have all the required files in github

3. Write terraform configuration file for AKS

First we will create a new resource group for kubernetes cluser:

aksrg.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/aksrg.tf

First we will write a configuration for log analytics workspace (optional), we can assign this to our aks cluser

loganalyticsworkspace.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/loganalyticsworkspace.tf

Now we will write a configuration file for AKS: aks.tf

https://github.com/kotianrakshith/AzureProj4/blob/main/aks.tf

Now we will add this also to staging and commit it and push it to github.and then we will have all the files both in our system and github:

Github link: https://github.com/kotianrakshith/AzureProj4

4. Apply the terraform configuration

First we will run initializing command to download required providers:

terrafrom init

Then we will run terraform plan to check if there are any errors and if not, what are the resource which will be built:

terraform plan

Now we will run the apply command to build all this 16 resource

terraform apply

This will prompt for approval, type yes

This will take some time and once all are created it will inform that all resource are created:

5. Check the deployed infrastructure

First you can go to All resource in azure portal and you can see all the resource that is created

Now you can check the required deployment:

VM: You can see our virtual machine is created in the resource group we specified

VMSS: You can see that our scale set is created(One for AKS cluster, One which we created)

AKS: You can go to kubernetes service and check that your cluster is created in mentioned resource group:

That completes the building infrastrcutre using IaC tool Terraform. We can see all the required dependency are created with minimal time and the code can be reused.

6. Destroy the infrastructure:

You can delete all the infrastructure using simple command: terraform destroy

It will ask for approval:

Once completed all the resource will be deleted. You can check in all resources if ther resources has been removed:

azureproj4's People

Contributors

kotianrakshith 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.