Skip to content

hammedakinwale/aks-terrafform-azure-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Deploying a web application into AKS using terraform(IAC)

This application requires a scalable, secure infrastructure with a focus on automation and best practices in cloud infrastructure management.

Objectives:

1. Infrastructure Setup Using Terraform and Azure Kubernetes Services (AKS)

Steps

  • I created an organization and created a workspace in the organization on terraform cloud

alt text

  • I added the credentials required by terraform to communicate with azure and also create resources on AZURE to terraform cloud

alt text

  • Configured the infrastructure to deploy AKS

you can find the Terraform configuration HERE.

  • I also automate the the github workflows using YAML files

you can find the YAML files HERE

2. Implement CI/CD Pipelines using GitHub Actions:

Branch Naming:

  • Descriptive and clear: Names should reflect the purpose of the branch (e.g., "feature-add-user-roles", "bugfix-incorrect-joins").

  • Consistent prefix: Consider using a standard prefix for different branch types (e.g., feature/, bugfix/, hotfix/).

  • Avoid special characters: Stick to alphanumeric characters, hyphens, and underscores for ease of use and compatibility.

Branching Off:

  • Branch from a stable version: Start new branches from a well-tested and integrated version, like develop or main.

  • Isolate changes: Each branch should focus on a single feature, bug fix, or release.

  • Use feature flags: If deploying incomplete features, utilize feature flags to control their visibility.

Merging Strategies:

  • Feature flags for risky merges: When merging risky branches, use feature flags to rollback if needed.

  • Pull requests for review: Encourage pull requests for code review before merging.

  • Merge conflicts resolution: Address conflicts promptly and thoroughly before merging.

  • Merge into stable branches: Merge approved branches into develop or main.

Handling Conflicts:

  • Clear communication: Discuss potential conflicts early and establish resolution procedures.

  • Version control tools: Utilize version control tools like Git to track changes and revert if needed.

  • Manual resolution: When automated merging fails, resolve conflicts manually.

  1. Azure Administration with Terraform:

Use Terraform to set up monitoring, logging, and alerts for the Kubernetes services using Azure Monitor and Log Analytics.

  • Azure Administration with Terraform

It is configurated with the below codes:

name: Azure AKS Monitroring With Prometheus and Grafana
on:
  workflow_dispatch:

permissions:
      id-token: write
      contents: read
jobs: 
  AKS-Cluster-Monitoring:
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash
        working-directory: AKS
    steps:
      - name: Checkout
        uses: actions/[email protected]
        
      - name: 'Az CLI login'
        uses: azure/login@v1
        with:
          client-id: ${{ secrets.ARM_CLIENT_ID }}
          tenant-id: ${{ secrets.ARM_TENANT_ID }}
          subscription-id: ${{ secrets.ARM_SUBSCRIPTION_ID }}
  
      - name: Setup Terraform
        uses: hashicorp/[email protected]
        with:
          terraform_version: latest
          cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

      - name: Terraform Init
        id: init
        run: terraform init
      
      - name: Terraform Validate
        id: validate
        run: terraform validate

      - name: Terraform Plan
        id: plan
        run: terraform plan
        continue-on-error: true

      - name: Terraform Plan Status
        if: steps.plan.outcome == 'failure'
        run: exit 1

      - name: Terraform Apply
        run: terraform apply -auto-approve

      - name: Terraform Output
        run: terraform output

       - name: AKS Monitroing Enabler
        run: |
          az aks get-credentials -n "cluster-definite-seahorse" -rg "rg-hip-urchin"
          helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
          helm repo update
          helm install prometheus prometheus-community/kube-prometheus-stack --namespace monitoring --create-namespace
          rm -rf ~/.kube

alt text

CHALLENGES:

  • The major challenges faced is deploying to azure using github action using secret key/ID i was able to fix that by creating federated credential on AZURE DEVOPS after alot of research, googling and consulting documantations

  • Another blocker is installing prometheus to the resources it is conplaining about flags but i am still working on fixing the blocker i just have to stop here for now due to the fact that i don't have enough time for delivering this i will have to update this after finding solutions to the problem or hopefully i will be able to get a solution to it with my potential team mates

alt text

THANK YOU

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published