OpsForDevs

devops bootcamp material that I have taught at previous companies


Project maintained by debaghtk Hosted on GitHub Pages — Theme by mattgraham

Exercise 6: Cloud Deployment with Infrastructure as Code and Advanced Configuration

Objective

Extend your local deployment from Exercise 5 to a cloud environment using Infrastructure as Code (IaC) and either Helm for Kubernetes package management or Chef for configuration management. Deploy your application to a cloud provider of your choice, setting up a basic production-like environment.

Prerequisites

Instructions

  1. Choose a Cloud Provider and IaC Tool
    • Cloud Providers: AWS, Google Cloud, Azure
    • IaC Tool: Terraform
  2. Define Your Infrastructure with Terraform Create Terraform templates to define:
    • Virtual Private Cloud (VPC) or equivalent
    • Subnets (public and private)
    • Security Groups
    • Compute instances (e.g., EC2, Compute Engine)
    • Managed Database service (e.g., RDS, Cloud SQL)
  3. Containerize Your Application
    • Ensure your application is properly containerized
    • Push your container image to a container registry (e.g., Docker Hub, ECR)
  4. Choose Your Configuration Path Select either Path A (Helm with Kubernetes) or Path B (Chef) for the next steps.

Path A: Helm with Kubernetes

A1. Set Up Kubernetes Cluster - Use Terraform to create a managed Kubernetes cluster (e.g., EKS, GKE, AKS)

A2. Create Helm Charts - Create a Helm chart for your application - Include necessary Kubernetes resources (Deployments, Services, etc.) - Configure your chart to connect to the managed database service

A3. Deploy with Helm - Use Helm to deploy your application to the Kubernetes cluster

A4. Implement Continuous Deployment - Extend your CI/CD pipeline to: - Build and push your container image - Update your Helm chart version - Deploy to your Kubernetes cluster using Helm

Path B: Chef

B1. Set Up Chef Workstation - Install Chef Workstation on your local machine - Set up a Chef repository for your project

B2. Create Chef Cookbooks - Write Chef cookbooks to configure your servers - Include recipes for: - Installing necessary software - Configuring your application - Setting up connections to the database

B3. Set Up a Chef Server or use Chef Zero - Either set up a Chef Server or use Chef Zero for a serverless approach

B4. Apply Chef Configurations - Use Chef to apply your cookbooks to the servers

B5. Implement Continuous Deployment - Extend your CI/CD pipeline to: - Build and push your container image - Update and apply Chef cookbooks

  1. Verify Deployment
    • Access your application
    • Verify that your application is connecting to the managed database
  2. Clean Up
    • Create scripts to tear down your infrastructure to avoid unnecessary costs

Bonus Tasks

  1. Set up a staging environment in addition to production
  2. Implement a simple update strategy (rolling updates for Kubernetes or blue-green for Chef)

Deliverables

  1. Terraform templates for your cloud infrastructure
  2. Helm charts (Path A) or Chef cookbooks (Path B)
  3. Updated CI/CD pipeline configuration
  4. Screenshots or logs showing:
    • Successful cloud deployment
    • Application running in the cloud
  5. Brief documentation including:
    • Your cloud architecture diagram
    • Deployment process

Remember, this exercise focuses on setting up a basic production-like environment in the cloud using Infrastructure as Code and either Helm or Chef for advanced configuration management.