Giter Club home page Giter Club logo

create-aks-cluster-terraform's Introduction

Introduction

This sample is shows how to bake your docker image, push image to docker hub,create aks cluster with terraform and deploy containers to k8s cluster.

Prerequisites

  • Azure Subscription: If you don’t have an Azure subscription, you can create a free account at https://azure.microsoft.com before start.
  • Azure Service Principal: is an identity used to authenticate to Azure. Below are the instructions to create one
  • Azure DevOps Account: Create an Azure DevOps account because is a separate service from the Azure Portal
  • Terraform extension: Install the Terraform Build & Release Tasks extension from the Marketplace

How to

First of all, you have to do two things.

  1. Fork this repositroy
  2. Create a service connection for uploading Docker images to a Docker Hub private repository

Open the Project, then click Project settings, then click Service connections.Select registry type the Docker Hub and then enter the Docker Hub ID, password,email address and give the connection a meaningful.Click save and verify this connection.

Image

Now we are ready to build our first Azure DevOps Build Pipeline

SampleWebApp Pipeline

Click on the build pipeline button and select GitHub yaml

Image

Image

Select the k8schallenge repository

Image

Select an Existing Azure Pipelines Yaml file

Image

Then select /02-sampleapp/ci/azure-pipelines.yml path

Image

Click at the Docker@2 task settings in yaml editor and then change containerRegistry and repository name in YAML file.

Image

Then click the Save and run button to launch our pipeline.

Infrastructure Pipeline

Follow the steps above.The only difference is the file path (/01-terraform/ci/create-infrastructure.yml)

Image

Change subscriptions for all Azure tasks and click on the authorize button.

Image

Don't forget to change environment variables!!

Image

Then click the Save and run button to launch our pipeline

AKS Pod Pipeline

Follow the steps above.The only difference is the file path (/03-k8sdeployment/ci/azure-pipelines.yml)

Image

You need to change subscription

Image

Let's Get Hands Dirty

We run all pipelines in sequence

Image

Image

Image

You can also see a live feed of the console

Image

Image

As you can see all infrastructure, images, and applications are delivered automatically.

Image

Demonstrate of the Cluster and Pod Autoscaler

We will start a container, and send an infinite loop of queries to the sampleappservice

kubectl run -it --rm load-generator --image=busybox /bin/sh

while true; do wget -q -O- http://40.118.127.126:11130; done

Image

You will see the number of pods increases after the load.

Image

Image

End of the day don't forget to remove infrastructure. Keep Your Money in Your Pocket !!

Bonus : You can use delete-infrastructure.yml for this task.

Image

Everything's gone

Image

create-aks-cluster-terraform's People

Contributors

fthkucuk avatar

Stargazers

 avatar  avatar

Watchers

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