Ingress Monitor Controller — Uptime Alerts for Kubernetes Services
There’s a common practice in Kubernetes space in which you would want to monitor your running services in Kubernetes. When you think of monitoring, there are a couple of solutions out there like UptimeRobot, StatusCake, Cabot etc that let you create monitors for your services. The problem with this is that you have to micromanage each and every single service you want to monitor i.e., creating / updating / deleting monitors manually from the vendor’s website. This is where you can benefit from our Ingress Monitor Controller.
Solution
Ingress Monitor Controller is a Kubernetes controller that will continuously watch ingresses created from services in the namespace it is running, and automatically add / remove monitors in any of the available uptime checkers. This helps you keep a check on your services and see whether they’re up and running and live. And most of all, you don’t have to manage these monitors yourself.
Pre-requisites
Since Ingress Monitor Controller runs on kubernetes and it watches ingresses, it is required that you have the following things setup:
- A kubernetes cluster
- Ingresses created for your services
Supported Uptime Services
Currently we support the following services for monitoring:
Installing it on your cluster
You can deploy Ingress Monitor Controller via 2 methods
- Applying Vanilla Manifests
- Installing via Helm
Pre-install Configuration
You can configure IMC for installation in 2 steps
- Add annotation to your ingresss
- Modify config.yaml file in ConfigMap
Adding Annotations
By default, the controller ignores the ingresses without a specific annotation on it. You will need to add the following annotation on your ingresses so that the controller is able to recognize and monitor the ingresses.
"monitor.stakater.com/enabled": "true"
The annotation key is monitor.stakater.com/enabled
and you can toggle the value of this annotation between true
and false
to enable or disable monitoring of that specific ingress.
Config.yaml
First of all you need to modify configmap.yaml
's config.yaml
file. You can see a sample of the config file below:
providers:
- name: UptimeRobot
apiKey: your-api-key
apiURL: https://google.com
alertContacts: some-alert-contacts
enableMonitorDeletion: true
monitorNameTemplate: "{{.Namespace}}-{{.IngressName}}"
Following are the available options that you can use to customize the controller:
For the list of providers, there’s a number of options that you need to specify. We will be using UptimeRobot for the example. The table below lists them:
You can get your UptimeRobot API Key and URL from here. Once you have them, the next step is to create alert contacts in the dashboard which will be used to send notifications.
Go to the dashboard and choose My Settings
from the top menu and scroll down until you see the following:
Click on Add Alert Contact
and create your choice of alert contacts. You can choose from email, slack, and various others.
After adding alert contacts you will need to follow this guide to see how to fetch alertContacts
from UptimeRobot to be used by IMC (IngressMonitorController). Once you have them, add it to the config as well.
At this point your config.yaml
would look like following:
providers:
- name: UptimeRobot
apiKey: u12345-123213vb512412b312b5
apiURL: https://api.uptimerobot.com/v2/
alertContacts: 012345_0_0-123512_0_0
enableMonitorDeletion: true
monitorNameTemplate: "{{.Namespace}}-{{.IngressName}}"
Deploying to Kubernetes
Now that you have your configuration setup, you can deploy IMC to Kubernetes via any of the 2 methods mentioned above.
Applying Vanilla Manifests
You can deploy the controller in the namespace you want to monitor by running the following kubectl commands:
kubectl apply -f configmap.yaml -n <namespace>
kubectl apply -f rbac.yaml -n <namespace>
kubectl apply -f deployment.yaml -n <namespace>
Note: Before applying
rbac.yaml
, You need to modify the namespace in theRoleBinding
subjects section to the namespace you want to applyrbac.yaml
to.
Installing via Helm
If you have configured helm
on your cluster, you can deploy the controller via helm chart located under kubernetes/chart
folder. Simply add the above config values in values.yaml
and run the following commands
cd kubernetes/chart/IngressMonitorController
helm install . --name ingressmonitorcontroller --namespace <your-namespace>
Now IMC will be up and running in the target namespace that you installed it into. Once any of your services goes down, UptimeRobot will send a notification to your alert contacts. For example, if you added a Slack WebHook as your alert contact, you will receive a notification like the following:
You can find Ingress Monitor Controller on GitHub here.
This is how we get notified if any of our services on Kubernetes go down in Stakater. For more information about us and what we do, or professional services regarding your stack / devops, visit stakater.com