Skip to content

Deployment of my docker containers on a Kubernetes cluster in AKS

Notifications You must be signed in to change notification settings

dishadas168/azure-aks-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Terraform AKS Cluster Deployment on Azure

This repository contains Terraform manifests for deploying an Azure Kubernetes Service (AKS) cluster with a Linux node pool. Additionally, it sets up a Blob Storage in Azure to store the Terraform state file (tfstate) securely.

Table of Contents

Prerequisites

Before using these Terraform manifests, make sure you have the following prerequisites in place:

  • Azure CLI: You must have Azure CLI installed and configured. You can download it from here.

  • Terraform: Install Terraform on your local machine. You can find the installation guide here.

  • Kubectl: Make sure you have kubectl installed to manage your Kubernetes cluster. You can find the installation guide here.

  • Create SSH Public Key for Linux VMs: Run the following commands to create an SSH Public key. This public key is referenced in 02-variables.tf file.

# Create Folder
mkdir $HOME/.ssh/aks-prod-sshkeys-terraform

# Create SSH Key
ssh-keygen \
    -m PEM \
    -t rsa \
    -b 4096 \
    -C "azureuser@myserver" \
    -f ~/.ssh/aks-prod-sshkeys-terraform/aksprodsshkey \
    -N mypassphrase

# List Files
ls -lrt $HOME/.ssh/aks-prod-sshkeys-terraform

Customization

You can customize the Terraform deployment by modifying the following files:

  • 01-main.tf: Customize the Azure resource group, storage account, container, and key for storing the Terraform state. Replace the default values with your own.
  • 02-variables.tf: Customize Azure Region, environment (Dev or Prod), resource group name in which the AKS instance resides
  • 07-aks-cluster.tf: Customize the AKS cluster settings
  • 09-aks-cluster-linux-user-nodepools.tf: Customize the Linux Nodepool settings

Usage

  1. Clone this repository to your local machine:

    git clone https://github.com/dishadas168/azure-aks-deployment.git
  2. Navigate to the project directory:

    cd terraform-manifests-aks

Deploying AKS Cluster

To deploy the AKS cluster using Terraform, follow these steps:

# Initialize Terraform from this folder
terraform init

# Validate Terraform manifests
terraform validate

# Review the Terraform Plan
terraform plan

# Deploy Terraform manifests
terraform apply 

Wait for Terraform to complete the deployment.

Applying Kube Manifests

Once the AKS cluster is up and running, use kubectl to apply Kubernetes manifests to the cluster. Place the Kubernetes manifests (YAML files) in kube-manifests directory and use the following commands to apply them:

# Configure `kubectl` to use your AKS cluster:
az aks get-credentials --resource-group terraform-aks-dev --name terraform-aks-dev-cluster --admin

# Navigate to the directory containing your Kubernetes manifests folder kube-manifests
cd ..

# Apply the manifests to your AKS cluster:
kubectl apply -R -f kube-manifests/

The AKS cluster is now configured and ready to run our applications.

Destroying Terraform Cluster

# Change directory to terraform-manifests-aks
cd terraform-manifests-aks

# Destroy all Terraform Resources
terraform destroy

Credits and Acknowledgments

About

Deployment of my docker containers on a Kubernetes cluster in AKS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages