Skip to content

Instantly share code, notes, and snippets.

@anthonyagresta
Last active April 14, 2020 02:09
Show Gist options
  • Save anthonyagresta/abc2564670272a7f702bda732c4ba9ae to your computer and use it in GitHub Desktop.
Save anthonyagresta/abc2564670272a7f702bda732c4ba9ae to your computer and use it in GitHub Desktop.
Cloud Ops and Python lesson plan

Bootstrapping a development environment!

  • Register for a Dockerhub account
  • Register for an Amazon Web Services account
  • Install a text editor
  • Get access to a Linux-ish terminal of some sort
    • VSCode might provide Git Bash
    • Could install Ubuntu on Windows from the app store
    • just run linux 4Head
  • Install some Cloud Computing basics:
    • AWS CLI
    • Docker
    • Terraform
    • kubectl

Docker basics

  • What is any of this
  • does docker run nginx work
  • Writing a docker file
  • Building a docker container image
  • Pushing a docker container image to DockerHub
  • Running a dockerized service locally with docker-compose

Python basics

  • Setting up a Python dev environment
    • Installing a version of python
      • virtualenv
      • requirements.txt
      • In my opinion just use docker instead of dealing with virtualenv but it's still good to know
    • Python: Hello World
    • Python: Hello World+, like helloworld but with one trivial dependency to prove our build tools work
    • Sample Dockerized service: Flask and trivial endpoint
      • Make a single HTTP REST endpoint at GET /, it should return a JSON message containing the value of a few environment variables in your container
      • Get a trivial web service running locally
    • Docker build and push it to public Dockerhub repo so you can use it in the cloud

Terraform Basics

  • Set up AWS credentials file
  • What is terraform
  • Why is terraform
  • How do things
  • Set up Terraform AWS provider
  • Use Docker to build an AWS Lambda .zip package out of your Hello World+ python script and its dependencies
  • Create an AWS Lambda function in Terraform
  • Use Terraform to upload your Lambda function to the cloud
  • Use the AWS CLI to invoke your test lambda function and see the output

Running a docker container in the AWS cloud

  • AWS EC2

    • Create (In terraform probably. Maybe demo the AWS UI first.):
      • VPC module from Terraform repo, including...
        • security groups - If needed, output the ID(s) of these so we can add more rules manually
        • Security group rules
        • Subnet(s)
        • Route table(s)
      • EC2 Instance
      • Create or output DNS hostname for your EC2 instance
    • Install Docker on EC2 Instance
    • SSH to instance, copy docker-compose.yml to EC2 instance, do docker-compose build and docker-compose up to run the service
    • Change the environment variables in the docker-compose file, restart with docker-compose, check new output
  • AWS ECS

    • Given the previous step, create in terraform...
      • A different EC2 instance running the official ECS optimized image
      • Create an ECS Service Definition
      • Create an ECS Task Definition that references your Docker container in DockerHub
      • Create a DNS hostname for your docker task
  • AWS Fargate

    • Given the network resources in the previous step, create...
    • An ECS Service Definition
    • An ECS Task Definition
    • Create a DNS hostname for your docker task

Running a docker container on Kubernetes

  • Set up a local Kubernetes master using Docker Desktop because running Kubernetes in the cloud can be expensive or hard to set up at first
  • Write Kubernetes YAML describing...
    • An application Pod
    • A Deployment that creates a ReplicaSet of N pods
    • A Service that exposes the pods in the ReplicaSet
  • Write new YAML to change some environment variables, kubectl apply, change the Deployment and watch the service change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment