Quickly deploy a K8s Cluster using Kong as an ingress. All built with Terraform. βΈπ¦π£
GPL-3.0 License
You will need a few things to use this project:
An Azure account (this project uses AKS)
tfenv (for managing Terraform versions)
kubectl (for applying K8s manifests)
A Terraform Cloud account to store your TF state remotely
terraform-cloud
docs in this repo for more info (required if you are using Terraform Cloud)An Azure Service Principal for deploying your Terraform changes - Create a Service Principal
Your Azure Service Principal will need owner
permissions to your Azure Subscription. This is due to K8s needing to bind your ACR registiry to your K8s cluster with pull permissions - Assign Roles to a Service Principal
You will need to skim through the following files and edit the lines with "(CHANGE ME)
" comments:
Example: Updating values with your own unique K8s cluster name and pointing to your own Terraform cloud workspaces
Build a K8s cluster with a single command!
Go make a coffee while this runs because it can take up to 15 minutes
$ make build
π¨ Let's build a K8s cluster!
β
tfenv is installed
β
Azure CLI is installed
β
kubectl is installed
β
terraform/k8s-cluster/terraform.auto.tfvars.json exists
β
terraform/k8s-cluster/terraform.auto.tfvars.json contains non-default credentials
π Deploying 'terraform/k8s-cluster'...
β΅ Configuring kubectl environment
π¨ Time to build K8s resources and apply their manifests on the cluster!
β
All manifests applied successfully
π¦ Kong LoadBalancer IP: 123.123.123.123
π Run 'script/grafana' to connect to the Kong metrics dashboard
β¨ Done! β¨
The K8s cluster uses Kong as a Kubernetes Ingress Controller and comes with a sample NGINX backend to serve HTTP requests
To get the external IP of your kong-proxy
, log into your Azure account and check your Services and Ingresses
section of your newly deployed K8s cluster. You will see a link to the extranal IP of your new LoadBalancer to make an HTTP request for testing.
When you are done using your K8s cluster, you may destroy it by executing the following command:
$ make destroy
π₯ Let's DESTROY your K8s cluster!
Continue with the complete destruction of your K8s cluster (y/n)? y
β
Approval for destroy accepted
β
tfenv is installed
β
terraform/k8s-cluster/terraform.auto.tfvars.json exists
β
terraform/k8s-cluster/terraform.auto.tfvars.json contains non-default credentials
π₯ Destroying 'terraform/k8s-cluster'...
β¨ Done! β¨
This is a bonus / expirmental section. It "works on my machine β’" but it will take a smidge of manual setup, knowledge of letsencrypt, DNS, etc
What you need first (pre-reqs):
make build
(above) - Copy down your Kong Proxy IPThese are a mix of steps and an outline of the make enable-tls
helper script
make enable-tls
script/
- Contains various scripts for deployments and maintenanceterraform/k8s-cluster
- The main terraform files for building the infrastructure of the K8s cluster. This folder contains configurations for the amount of K8s nodes, their VM size, their storage, etcterraform/k8s/*
- Kubernetes deployment manifests and Terraform files for Kong, Grafana/Prometheus, and the NGINX example http serverThe purpose of this project/repo is to quickly build a minimal K8s cluster with Kong + Terraform to get a project going.
The diagram below shows an example of what a K8s cluster would look like with this deployment.
Note: Rather than having a
kermit
,cat
, anddog
service - you would just have one service, thenginx-example
Once your cluster is up and running the NGINX example will look like this:
You can also view the Grafana dashboard either with script/grafana
or by visiting your configured hostname when you configure TLS:
Once you have successfully built your K8s cluster and tested its functionality, you can deploy it using CI/CD with GitHub actions!
To do so, check out the following documentation in this repo: github-actions
All contributions are welcome! If you have any questions or suggestions, please open an issue or fork this repo and create a pull request!