Starter for a Kubernetes cluster deployed to Digital Ocean with
kube-prometheus
plugged in for monitoring/alerting
Apply changes to cluster (after completing all below setup steps):
npm run apply
-
Manually create DO space/bucket for terraform state specified in s3 terraform backend
-
Export tokens to env:
DIGITALOCEAN_ACCESS_TOKEN
: do personal access tokenAWS_ACCESS_KEY_ID
: do spaces access key id for tf state backendAWS_SECRET_ACCESS_KEY
: do spaces secret access key for tf state backendSPACES_ACCESS_KEY_ID
: do spaces access key id for managing do spacesSPACES_SECRET_ACCESS_KEY
: do spaces secret access key for managing do spaces
-
Install terraform to exact version used by terraform code
-
Init terraform state
terraform init terraform
- Provision k8s cluster
terraform apply terraform
-
Install
kubectl
within one minor version of k8s cluster https://kubernetes.io/docs/tasks/tools/install-kubectl/ -
Install
doctl
-
Authenticate DO CLI with
personal
context:
doctl auth init --context personal
doctl auth switch --context personal
- Pull cluster configuration:
doctl kubernetes cluster kubeconfig save personal
- Add the following lines to your
/etc/hosts
file:
127.0.0.1 monitoring-kube-prometheus-alertmanager.monitoring
127.0.0.1 monitoring-kube-prometheus-prometheus.monitoring
- Create the namespaces:
kubectl apply -f kubernetes/namespaces.yaml
To bootstrap the cluster we need to install Flux: https://toolkit.fluxcd.io/guides/installation/
- Install the Flux CLI:
brew install fluxcd/tap/flux
-
Generate a Github Personal Access token with private repo access
-
Bootstrap Flux
GITHUB_TOKEN=<your token from prev step> flux bootstrap github \
--owner=<github username> \
--repository=<github repo name> \
--branch=master \
--components=source-controller,kustomize-controller,helm-controller,notification-controller \
--path=clusters/personal
The webhook URI to send alerts to must be created in Discord and added to the slack_api_url
in prometheus-config.yaml
.
-
Open the server settings in Discord
-
Goto the Integrations tab and click on Webhooks
-
Create a new webhook or select an existing one
-
Copy the Webhook URL and set the value for
slack_api_url
inprometheus-config.yaml
-
Add
/slack
to the end of the webhook URI
To connect to internal-only services, forward the port to your local machine.
- Forward Grafana
npm run forward grafana
-
Open Grafana in your web browser: http://localhost:3000
-
Login:
Username: admin
Password: poleax-lay-levitate
- Forward AlertManager
npm run forward alertmanager
- Open Alertmanager in your web browser: http://localhost:9093
- Forward Prometheus
npm run forward prometheus
- Open Prometheus in your web browser: http://localhost:9090