Skip to content

A container control plane, powered by infrastructure-as-code tools like Packer, Terraform and Nomad

Notifications You must be signed in to change notification settings

thiskevinwang/container-control-plane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Container Control Plane

CleanShot 2023-10-14 at 01 08 35@2x

What is this?

This is a small project that consist of several infrastructure-as-code tools. Packer for machine images as code, Terraform for infrastructure-as-code, and Nomad for containerized jobs as code.

I am working towards make this fully portable to anyone else with an AWS account, but for now, it makes some assumptions, like assuming a Route53 hosted zone exists, and there are a few hard coded values that have yet to be converted to variables.

There are also some additional AWS glue scripts that I have yet to find a "best" place for.

Overview

There are three main folders:

  • /packer - For infrequently updating an AWS AMI
  • /terraform - For quick spin up and tear down of and EC2 instance, mostly to avoid wasted money.
  • /nomad - For quick iteration and running of Nomad jobs, assuming a Nomad instance is ready.

Prerequisites

  • packer CLI
  • terraform CLI
  • nomad CLI
  • aws CLI
  • AWS Credentials; used by packer and terraform and aws
  • A ./nomad/acme.json file, for TLS support

    [!WARNING]

    Annecdotally, this file poses a bit of a 🐔/🥚 scenario. I'm not sure if nomad template references to the file will break if the file doesn't exist yet, so those might have to be commented out if so.

    Traefik will bootstrap this file on container start. You can docker exec -it $TRAEFIK_CONTAINER /bin/sh into the container and find the acme.json file, and copy-paste it into your local machine. A persist file will make sure Traefik doesn't run into Let's Encrypt rate limits, especialyl it it needs to restart often.

Quickstart

Packer

Build a Amazon machine image

packer/build.sh

Terraform

Start an EC2 instance with nomad running.

terraform -chdir ./terraform apply

Warning

This will create a permissive security group. I need to look into reducing access.

Nomad

Traefik

nomad run ./nomad/traefik.nomad

Prometheus

nomad run ./nomad/prometheus.nomad

Grafana

nomad run ./nomad/grafana.nomad

Note

admin user is not created on start up. grafana/grafana#12638

Postgres

nomad run -var hostname=postgres.thekevinwang.com ./nomad/postgres.nomad
# or
export NOMAD_VAR_hostname="postgres.thekevinwang.com"
nomad run ./nomad/postgres.nomad

Whoami

AWS Route53

aws/route53.sh

About

A container control plane, powered by infrastructure-as-code tools like Packer, Terraform and Nomad

Topics

Resources

Stars

Watchers

Forks