DevOps Sessions - Week 13 - Orchestration

devops kubernetes aws ecs 24-10-2024 ​​

DevOps Sessions - Week 13 - Orchestration

Welcome to Week 13 of our “Becoming a DevOps Engineer” series! This week, we will focus on orchestration, a critical aspect of modern DevOps practices that enables the automation and management of complex workflows and services. Orchestration ensures that various components of your application ecosystem work together seamlessly. We will explore key concepts, tools like Kubernetes, Docker Swarm, and Apache Mesos, and best practices for effective orchestration. Let’s get started!

Session Overview

1. Introduction to Orchestration

2. Kubernetes

3. Docker Swarm

4. Apache Mesos

5. Practical Examples

6. Best Practices and Tools

1. Introduction to Orchestration

What is Orchestration?

Orchestration in DevOps refers to the automated arrangement, coordination, and management of complex computer systems, middleware, and services. It integrates multiple automated tasks to create workflows that can be managed and monitored from a central location.

Importance of Orchestration in DevOps

2. Kubernetes

Overview of Kubernetes

Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It groups containers into logical units for easy management and discovery.

Setting Up Kubernetes

  1. Install Minikube: Minikube sets up a local Kubernetes cluster on your machine.

  2. Start Minikube:

    minikube start

Managing Workloads with Kubernetes

  1. Create a Deployment:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-app
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: my-app
      template:
        metadata:
          labels:
            app: my-app
        spec:
          containers:
          - name: my-app
            image: my-app:latest
            ports:
            - containerPort: 80
  2. Apply the Deployment:

    kubectl apply -f deployment.yaml
  3. Expose the Deployment:

    kubectl expose deployment my-app --type=LoadBalancer --port=80 --target-port=80
  4. Scale the Deployment:

    kubectl scale deployment my-app --replicas=5

3. Docker Swarm

Overview of Docker Swarm

Docker Swarm is Docker’s native clustering and orchestration tool. It turns a pool of Docker hosts into a single virtual host, enabling you to manage and scale your containerized applications easily.

Setting Up Docker Swarm

  1. Initialize Swarm Mode:

    docker swarm init
  2. Add Nodes to the Swarm:

    docker swarm join --token <token> <manager-ip>:2377

Managing Services with Docker Swarm

  1. Create a Service:

    docker service create --name my-web --replicas 3 -p 80:80 nginx
  2. List Services:

    docker service ls
  3. Scale a Service:

    docker service scale my-web=5
  4. Remove a Service:

    docker service rm my-web

4. Apache Mesos

Overview of Apache Mesos

Apache Mesos is an open-source cluster manager that abstracts CPU, memory, storage, and other compute resources away from machines (physical or virtual), enabling fault-tolerant and elastic distributed systems to be built and run effectively.

Setting Up Apache Mesos

  1. Install Mesos:

  2. Start Mesos Master:

    mesos-master --ip=<master-ip> --work_dir=/var/lib/mesos
  3. Start Mesos Agent:

    mesos-agent --master=<master-ip>:5050 --work_dir=/var/lib/mesos

Managing Resources with Apache Mesos

  1. Launch a Framework:

    • Use a framework like Marathon to deploy and manage applications on Mesos.
    • Follow the Marathon setup guide from the official Marathon website.
  2. Deploy an Application with Marathon:

    {
      "id": "my-app",
      "cmd": "sleep 1000",
      "cpus": 1,
      "mem": 128,
      "instances": 3
    }
  3. Submit the Application:

    curl -X POST http://<marathon-ip>:8080/v2/apps -d @my-app.json -H "Content-type: application/json"

5. Practical Examples

Deploying a Multi-Service Application with Kubernetes

  1. Create a Kubernetes Manifest File:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: frontend
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: frontend
      template:
        metadata:
          labels:
            app: frontend
        spec:
          containers:
          - name: frontend
            image: my-frontend:latest
            ports:
            - containerPort: 80
    
    ---
    
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: backend
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: backend
      template:
        metadata:
          labels:
            app: backend
        spec:
          containers:
          - name: backend
            image: my-backend:latest
            ports:
            - containerPort: 80
  2. Apply the Manifest:

    kubectl apply -f multi-service.yaml

Scaling Services with Docker Swarm

  1. Create a Docker Compose File:

    version: '3'
    services:
      web:
        image: nginx
        deploy:
          replicas: 3
          resources:
            limits:
              cpus: '0.50'
              memory: 50M
          restart_policy:
            condition: on-failure
        ports:
          - "80:80"
  2. Deploy the Stack:

    docker stack deploy -c docker-compose.yml my-stack

6. Best Practices and Tools

Best Practices for Orchestration


By mastering orchestration with tools like Kubernetes, Docker Swarm, and Apache Mesos, you can automate and manage complex workflows and services efficiently. Stay tuned for next week’s session, where we will explore monitoring and logging practices. Happy orchestrating!

Author's photo

Nihit Jain

Architecting DevOps 🏗️ with Data, AI, Security, & IoT on Cloud ☁️




See other articles:

Sessions