devops-provisioning

Contents

Roadmap info from roadmap website

Provisioning

Provisioning refers to the process of setting up and configuring the necessary IT infrastructure to support an application or service. This includes allocating and preparing resources such as servers, storage, networking, and software environments. Provisioning can be done manually, but in modern DevOps practices, itโ€™s typically automated using tools like Terraform, Pulumi, or CloudFormation. These tools allow for infrastructure-as-code, where the entire provisioning process is defined in version-controlled scripts or templates. This approach enables consistent, repeatable deployments across different environments, reduces human error, and facilitates rapid scaling and disaster recovery.

Learn more from the following resources:

Free Resources


Comparison: Key Differences

FeatureTerraformPulumiNomad
Primary UseInfrastructure provisioning (IaC)Infrastructure provisioning (IaC) with codeApplication and container orchestration
LanguageHCL (Declarative)General-purpose programming languagesHCL (Declarative)
Multi-Cloud SupportExcellent (AWS, Azure, GCP, Kubernetes)Excellent (AWS, Azure, GCP, Kubernetes)Limited (Mostly datacenter, on-prem, cloud)
State ManagementBuilt-in with Terraform CloudManaged by Pulumi or self-hostedNot applicable (used for application workloads)
ComplexityModerateEasy to Moderate (depending on familiarity)Moderate (simpler than Kubernetes)
PricingFree + Paid for collaboration featuresFree + Paid for collaboration featuresFree (Open-source) + Paid for enterprise
Best Use CaseMulti-cloud infrastructure managementDev-focused IaC with complex logic supportLightweight container and workload orchestration
Workload ManagementNoNoYes (supports containers, binaries, VMs)
IntegrationIntegrates with Terraform Cloud, Vault, etc.Integrates with various SDKs and librariesIntegrates with Consul, Vault, Docker

Key Takeaways

  • Terraform is the go-to for multi-cloud infrastructure provisioning, with a declarative syntax and excellent support for various cloud providers. Itโ€™s best when you need to manage infrastructure across multiple platforms in a consistent, scalable way.

  • Pulumi is ideal for developers who want to use programming languages to define infrastructure, allowing them to write logic in their infrastructure code. Itโ€™s excellent when you need complex logic in IaC.

  • Nomad is a simplified alternative to Kubernetes for scheduling and running containers, VMs, and other workloads. Itโ€™s particularly suited for teams that want orchestration without Kubernetesโ€™ complexity.

Each tool serves a different purpose: Terraform and Pulumi are focused on infrastructure provisioning, while Nomad is a workload orchestrator. Choosing between them depends on whether you need to provision infrastructure (Terraform/Pulumi) or orchestrate workloads (Nomad).

Example

1. Terraform Example (AWS EKS + PostgreSQL)

This Terraform script sets up an AWS EKS cluster and a PostgreSQL RDS instance.

# main.tf

provider "aws" {
  region = "us-west-2"
}

# Create a VPC
module "vpc" {
  source = "terraform-aws-modules/vpc/aws"
  name   = "my-vpc"
  cidr   = "10.0.0.0/16"
}

# Create an EKS cluster
module "eks" {
  source          = "terraform-aws-modules/eks/aws"
  cluster_name    = "my-eks-cluster"
  cluster_version = "1.25"
  subnets         = module.vpc.private_subnets
  vpc_id          = module.vpc.vpc_id
  manage_aws_auth = true
  worker_groups = [
    {
      instance_type = "t3.medium"
      asg_max_size  = 3
    }
  ]
}

# Create a PostgreSQL RDS instance
resource "aws_db_instance" "postgres" {
  identifier        = "my-postgres-db"
  engine            = "postgres"
  instance_class    = "db.t3.micro"
  allocated_storage = 20
  name              = "mydb"
  username          = "postgresadmin"
  password          = "Password123"
  parameter_group_name = "default.postgres13"
  skip_final_snapshot = true
  vpc_security_group_ids = [module.vpc.default_security_group_id]
  db_subnet_group_name   = module.vpc.default_db_subnet_group
}

output "eks_cluster_endpoint" {
  value = module.eks.cluster_endpoint
}

output "postgres_db_endpoint" {
  value = aws_db_instance.postgres.endpoint
}

2. Nomad Example (AWS EKS + PostgreSQL)

This Nomad configuration runs PostgreSQL and a Nomad task inside a Kubernetes cluster (AWS EKS).

# kubernetes.nomad

job "k8s-postgres" {
  datacenters = ["dc1"]
  type = "service"

  group "postgres" {
    task "run-postgres" {
      driver = "kubernetes"

      config {
        pod {
          metadata {
            name = "postgres-pod"
          }
          spec {
            containers {
              name  = "postgres"
              image = "postgres:13"
              env {
                name  = "POSTGRES_USER"
                value = "admin"
              }
              env {
                name  = "POSTGRES_PASSWORD"
                value = "Password123"
              }
              ports {
                name = "db"
                containerPort = 5432
              }
            }
          }
        }
      }
    }
  }

  group "app" {
    task "run-app" {
      driver = "kubernetes"

      config {
        pod {
          metadata {
            name = "my-app-pod"
          }
          spec {
            containers {
              name  = "my-app"
              image = "my-app-image:latest"
              ports {
                name = "http"
                containerPort = 8080
              }
            }
          }
        }
      }
    }
  }
}

3. Pulumi Example (AWS EKS + PostgreSQL)

This Pulumi code creates an AWS EKS cluster and a PostgreSQL RDS instance in Python.

import pulumi
import pulumi_aws as aws
import pulumi_eks as eks

# Create a VPC for EKS
vpc = aws.ec2.Vpc('my-vpc',
    cidr_block='10.0.0.0/16',
    enable_dns_support=True,
    enable_dns_hostnames=True)

subnet = aws.ec2.Subnet('my-subnet',
    vpc_id=vpc.id,
    cidr_block='10.0.1.0/24',
    availability_zone='us-west-2a')

# Create an EKS cluster
cluster = eks.Cluster('my-cluster',
    vpc_id=vpc.id,
    subnet_ids=[subnet.id],
    instance_type='t3.medium',
    desired_capacity=2,
    min_size=1,
    max_size=3)

# Create a PostgreSQL RDS instance
db = aws.rds.Instance('my-postgres-db',
    engine='postgres',
    instance_class='db.t3.micro',
    allocated_storage=20,
    name='mydb',
    username='postgresadmin',
    password='Password123',
    skip_final_snapshot=True)

# Export the cluster and DB details
pulumi.export('eks_cluster_endpoint', cluster.endpoint)
pulumi.export('postgres_db_endpoint', db.endpoint)

Summary of Tools

  • Terraform: Declarative tool with vast support for infrastructure, including AWS. Suitable for detailed infrastructure management and best for those already familiar with HCL.
  • Nomad: HashiCorpโ€™s orchestrator that runs across both Kubernetes and traditional server applications, making it flexible for different workloads.
  • Pulumi: Uses programming languages like Python, TypeScript, and Go for infrastructure as code, offering a more intuitive experience for developers familiar with these languages.
#roadmap #Informatic #devops #ready #online