Giter Site home page Giter Site logo

learn-terraform-provision-aks-cluster-at-sag's Introduction

Learn Terraform - How to provision Azure Kubernetes Service Cluster @ Software AG Environment

This tutorial is cloned from Terraform provision an AKS Cluster tutorial and extended for use in Software AG environment.

At the end of the tutorial, you have provisioned a Kubernetes Service in Azure (AKS) by using Terraform.

Why deploy with Terraform?

While you could use the built-in Azure provisioning processes (UI, CLI) for AKS clusters, Terraform provides you with several benefits:

  • Unified Workflow - If you are already deploying infrastructure to Azure with Terraform, your AKS cluster can fit into that workflow. You can also deploy applications into your AKS cluster using Terraform.

  • Full Lifecycle Management - Terraform doesn't only create resources, it updates, and deletes tracked resources without requiring you to inspect the API to identify those resources.

  • Graph of Relationships - Terraform understands dependency relationships between resources. For example, an Azure Kubernetes cluster needs to be associated with a resource group, Terraform won't attempt to create the cluster if the resource group failed to create.

Prerequisites

To create resources in Azure, you need a subscription. You can use your Visual Studio Professional Subscription. Furthermore, we need following installed software from Company Portal ...

  • Terraform
  • Microsoft Azure CLI

This combination is currently available only on Windows. Therefore, we can run only this OS.

To access the AKS, install from Company Portal ...

  • kubectl

Provisioning

Clone Repository

Clone Git repository https://github.com/thomas-2020/learn-terraform-provision-aks-cluster-at-sag

git clone https://github.com/thomas-2020/learn-terraform-provision-aks-cluster-at-sag.git

Start Command Line

Start new command prompt after software installation. The commands terraform and az should be available. Go to sub-directory of cloned repository with your command shell.

Initialize Terraform

Initialize Terraform: terraform init. You should get the output ...

Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/azurerm versions matching "2.66.0"...
- Installing hashicorp/azurerm v2.66.0...
- Installed hashicorp/azurerm v2.66.0 (signed by HashiCorp)

Login to Azure

Login to your Azure account: az login. This command (typed in command prompt) starts the login into your default browser. After successfully login, you will find the subscription ID in the terminal window ...

...
    "cloudName": "AzureCloud",
    "homeTenantId": "11111111-1111-1111-1111-111111111111",
    "id": "22222222-2222-2222-2222-222222222222",
    "isDefault": true,
    "managedByTenants": [],
    "name": "Visual Studio Professional Subscription",
...

Copy/past the ID in field id (of the subscription which you want to use) to file terraform.tfvars ...

subscriptionId =  "xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxx"

Start Provisioning

Start provisioning with Terraform: terraform apply. After input validation, Terraform prints following output ...

...
Plan: 4 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + kubernetes_cluster_name = "MyCluster"
  + resource_group_name     = "MyCluster-rg"

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value:

Enter yes to start the provisioning. For changing the cluster name MyCluster, there are 2 possibilities ...

  • set another name on changing the property in terraform.tfvars or
  • overwrite properties with terraform apply -var clusterName=FirstTestCluster

Note: You can use in this tutorial only alphanumeric characters as cluster name because a container registry is also created with this name. The container registry name can have only alphanumeric characters.

Configure kubectl

Now that you've provisioned your AKS cluster, you need to configure kubectl. Run the following command to retrieve the access credentials for your cluster and automatically configure kubectl.

az aks get-credentials --resource-group $(terraform output -raw resource_group_name) --name $(terraform output -raw kubernetes_cluster_name)

Windows CMD cannot resolve $(...) expressions. You must do it manually ...

az aks get-credentials --resource-group MyCluster-rg --name MyCluster

Using Container Registry

The provisioning creates a container registry (with cluster name) and do the attaching (role assignment) to AKS cluster. You can use webMethods Image Creator to create images and push them to registry.

Cleanup Provisioning

With terraform destroy you can destroy previously-created infrastructure.

Conclusion

At the end of successfully provisioning, it is time to document and visualize the infrastructure. You can use terraform graph. It generates file in DOT format. You can rendering the graph e.g. on https://edotor.net. AKS Cluster Provisioning

learn-terraform-provision-aks-cluster-at-sag's People

Watchers

 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.