Showing posts with label DevOps. Show all posts
Showing posts with label DevOps. Show all posts

Saturday 2 March 2024

Kubernetes: Orchestrating Containers like a Maestro 🪄

 



In the ever-evolving world of containerized applications, managing and scaling them effectively becomes paramount. Enter Kubernetes, an open-source container orchestration platform that has revolutionized how we deploy, manage, and scale containerized applications.

Developed by Google and released in 2014, Kubernetes (often abbreviated as "k8s") has become the de facto standard for container orchestration. It acts as a maestro, automating the deployment, scaling, and operations of containerized applications across clusters of hosts. orchestrator ‍

But why Kubernetes?

Traditional application deployments often involved manual processes and complex configurations, making scaling and managing applications cumbersome. Kubernetes simplifies this process by providing a platform to:

  • Automate deployments and scaling: Define your application's desired state, and Kubernetes takes care of deploying and scaling containers to meet that state.
  • Manage container lifecycles: Kubernetes handles container creation, deletion, and health checks, ensuring your application remains healthy and responsive.
  • Facilitate service discovery and load balancing: Kubernetes enables applications to discover and communicate with each other easily, while also providing built-in load balancing for distributing traffic across container instances. ⚖️
  • Self-healing capabilities: If a container fails, Kubernetes automatically restarts it, ensuring your application remains highly available.

How does Kubernetes work? ⚙️

At the heart of Kubernetes lies a cluster architecture composed of various components:

  • Master node: The brain of the operation, responsible for scheduling container workloads across worker nodes and managing the overall state of the cluster.
  • Worker nodes: The workhorses of the cluster, running containerized applications as instructed by the master node. ️
  • Pods: The smallest deployable unit in Kubernetes, consisting of one or more containers that share storage and network resources.
  • Deployments: Manage the desired state of your application by deploying and scaling pods.
  • Services: Abstractions that expose pods to other applications or users within the cluster. ✨

Here's a simplified example:

  1. You define your application as a set of containerized services using YAML files.
  2. You deploy the application using kubectl, the Kubernetes command-line tool.
  3. The master node schedules the pods containing your containers across available worker nodes in the cluster.
  4. Kubernetes manages the lifecycles of your pods, ensuring they run healthy and scaled as needed.

Exploring Further:

For a deeper dive into Kubernetes, check out the following resources:

By embracing Kubernetes, you can streamline your containerized application deployments, gain better control over your infrastructure, and empower your development teams to focus on building innovative applications, not managing infrastructure complexities.

Remember, this is just a glimpse into the vast world of Kubernetes. As you explore further, you'll discover its extensive capabilities and how it can empower you to build and manage modern, scalable applications like a maestro! 🪄

Thursday 29 February 2024

Terraform configuration to build a Zero-trust network



Terraform configuration to build a Zero-trust network for web applications in Azure MS, with Azure Firewall and application gateways:

Terraform
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = ">= 3.0.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "zerotrust" {
  name     = "zerotrust-rg"
  location = "westus"
}

resource "azurerm_virtual_network" "app-vnet" {
  name     = "app-vnet"
  location = azurerm_resource_group.zerotrust.location
  address_prefixes = ["10.0.0.0/16"]

  subnet {
    name         = "app-subnet"
    address_prefix = "10.0.1.0/24"
  }
}

resource "azurerm_application_gateway" "app-gw" {
  name     = "app-gw"
  location = azurerm_resource_group.zerotrust.location
  capacity = 2

  frontend_port {
    name     = "http"
    port     = 80
    protocol = "Http"
  }

  frontend_port {
    name     = "https"
    port     = 443
    protocol = "Https"
  }

  backend_address_pool {
    name = "app-backend-pool"
  }

  frontend_ip_configuration {
    name   = "app-frontend-ip"
    public_ip_address_id = null
  }

  listener {
    name                 = "http-listener"
    protocol             = "Http"
    frontend_port_name   = "http"
    frontend_ip_config_name = "app-frontend-ip"
  }

  listener {
    name                 = "https-listener"
    protocol             = "Https"
    frontend_port_name   = "https"
    frontend_ip_config_name = "app-frontend-ip"
  }

  request_routing_rule {
    name         = "app-http-rule"
    listener_name = "http-listener"
    backend_address_pool_name = "app-backend-pool"
    backend_http_setting_name = "app-http-setting"
  }

  request_routing_rule {
    name         = "app-https-rule"
    listener_name = "https-listener"
    backend_address_pool_name = "app-backend-pool"
    backend_http_setting_name = "app-https-setting"
  }

  backend_http_setting {
    name         = "app-http-setting"
    idle_timeout_in_minutes = 10

    path_rule {
      name         = "app-rule"
      path_patterns = ["/*"]
      backend_pool_name = "app-backend-pool"
      backend_http_setting_name = "app-http-setting"
    }
  }

  backend_http_setting {
    name         = "app-https-setting"
    idle_timeout_in_minutes = 10

    path_rule {
      name         = "app-rule"
      path_patterns = ["/*"]
      backend_pool_name = "app-backend-pool"
      backend_http_setting_name = "app-https-setting"
    }
  }

  probe {
    name        = "app-probe"
    path        = "/"
    interval_in_seconds = 30
    threshold = 3
  }

  health_monitor {
    name     = "app-monitor"
    probe_name = "app-probe"
  }
}
YAML
---
- name: Provision whitelist configuration
  hosts: all
  become: true
  tasks:
    - name: Get whitelist data from database
      uri:
        url: "https://database

OBS: 

Disclaimer

This Terraform and Ansible code is provided for informational purposes only and should not be considered production-ready. Running this code may have unintended consequences and could potentially compromise your Azure environment.

By using this code, you assume all risk and responsibility for any damages or losses that may occur. It is highly recommended to thoroughly understand the code and modify it to fit your specific needs and security requirements before deploying it in a production environment.

Additionally, always consult with qualified Azure and security professionals before implementing any changes in your environment.


Source Code:


How do I force "git pull" to overwrite local files?

 There might be situations where you want to discard your local changes and synchronise your working directory with the latest version from ...