This has only been tested and run on macOS. If you're trying this out with Linux and Windows you will have to adapt some commands.
-
AWS CLI to manage AWS resources
pip install --upgrade --user awscli
aws configure
-
terraform to create a DB on AWS
brew install terraform
j
-
jq to parse JSON results returned by the AWS CLI
brew install jq
-
chronic to suppress output unless there's a non-zero exit code
brew install moreutils
-
envsubst to replace environment variables in templates
brew install gettext
-
kops to create the Kubernetes cluster
brew install kops
-
kubectl to manage Kubernetes resources
brew install kubernetes-cli
The first script 1-create-cluster.sh
will:
- Generate a new ssh key for the cluster
- Create S3 buckets for the cluster configuration
- Create IAM groups, users and policies for
kops
- Create the Kubernetes cluster with
kops
- Extract the
kubeconfig
from the new cluster - Encrypt the
kubeconfig
withopenssl
- Upload the encrypted
kubeconfig
to S3
The second script 2-create-database.sh
will:
- Set up the Database credentials
- Create a PostGres database with AWS RDS
- Create an S3 bucket for the database config
- Encrypt the terraform DB state with
openssl
- Upload the encrypted terraform DB state to S3
- Generate a Kubernetes secret for the backend services to be able to connect to the DB
The third script 3-create-services.sh
will:
- Set up a new subdomain for the cluster
- Create all specified kubernetes deployments and services
- Create a Kubernetes ingress controller and ingress resource
- Set up SSL using kube-lego which uses Let's Encrypt internally
- Set up monitoring and logging services
- Set up autoscaling through kops' cluster-autoscaler addon