Type something to search...
Health check with Uptime Kuma, complete setup guide in kubernetes

Health check with Uptime Kuma, complete setup guide in kubernetes

I have been in this situation a lot. The services we set up went down for some reason and we are not aware of it. The customer knows about it the first and let us know. This is one of the worst situation to be in. All the services that we setup should be under our control or we should be the one to know about it or we should know about the failure as soon as things goes wrong.

The application we deploy might go wrong any time and it’s possible that we are not aware of it. To bring us all out of this worst situation we need to setup a monitoring tools that will continuously monitor our sytem or appliation and let us know as soon as something goes wrong.

There are multiple ways to do it:

  • you can write script of your own, which needs a way more time investment
  • install monitoring tools nagios, prometheus with alertmanager and grafana
  • use third party services like NewRelic, DataDog and many more in the market
  • setup an opensource tool like uptime kuma.

The choice is yours which one you prefer. It also depends on the budget you have. Here we are going to use the opensource tool called uptime kuma which I found to be the best tool so far for the purpose.

Why uptime kuma?

  • I find it way easier to setup then any other tools available
  • The configuration part is pretty easy and has many options available.
  • It’s opensource.
  • The best part is it provides a monthly SLA report for the service being monitored.

Our Goal

  • We will setup uptime kuma using helm chart
  • we will setup a simple nginx service and try to monitor it in uptime kuma
  • The notification will be sent to MicroSoft teams as an alert.

Installing uptime kuma with helm chart:

Adding helm chart repo and installing it on uptime-kuma namespace

helm repo add uptime-kuma https://helm.irsigler.cloud
helm install uptime-kuma uptime-kuma/uptime-kuma -n uptime-kuma --create-namespace 

Make necessary changes in kuberenetes:

These are few things you can do for setting up domain for the uptime kuma.

  • update helm chart to enable ingress and setup proper domain for the service
  • update helm chart to add proper domain to set for the ingress

Here: we will simply check by port-forwarding the service

simple nginx deployment and service for testing purpose

Simply create a deployment and service for testing purpose. I will be creating it on “testing” namespace.

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  namespace: testing
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: testing
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: ClusterIP

Setting up workflow in Teams

The way we used to setup webhook in microsoft teams is deprecated now, so we do it via workflow instead. We choose a flow which will trigger an action when post request is received on the webhook as shown in the screenshot image.

Alt text

Do the necessary settings as requested like setting up flow-name, choosing the channel name and many more.

We get a webhook url as shown in image , put it safe which we would need and thats where all the post request will be done for notifications.

Alt text

Finally configuring the uptime kuma setting up monitor and notification:

  • add the new monitor in uptime kuma
  • for us as we are monitoring the kubernetes service with no external url or might not even have it in case of kubernetes so we would choose to do health check with TCP protocol
  • set the proper names for monitor, for url for our case it will be nginx-service.testing.svc.cluster.local`

notification settings

 {
       "type":"message",
       "attachments":[
          {
         "contentType":"application/vnd.microsoft.card.adaptive",
             "contentUrl":null,
             "content":{
                "$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
                "type":"AdaptiveCard",
                "version":"1.2",
                "body":[
                    {
                    "type": "TextBlock",
                    "text": "{{msg}}",
                    "description": 
                     "size": "large",
                      "weight": "bolder"
                      
                    }
                ]
             }
          }
       ]
    }

Related Posts

DevOps Engineer Roadmap for beginners

DevOps Engineer Roadmap for beginners

In this blog, I want to share my experience of how someone can become a DevOps Engineer. This is not a 30-day tutorial or a set of resources to make you a DevOps Engineer in a specific number of days

read more
Getting familiar with Private and Public network with real-time project (bastion host)

Getting familiar with Private and Public network with real-time project (bastion host)

The purpose of this article is to familiarize readers with private and public networks using examples and real-time use cases. You might have seen many tutorials on setting up OpenVPN, but most of t

read more