Kubernetes ingress for leader follower system

9/10/2018

I have a kubernetes service that works in a leader/follower fashion, so only one of 2 pods (for HA) can accept the connection. I want to make my service publicly available with traefik ingress controller.

One of the ways to achieve that - tweaks the readiness probe for the service, so slave pod will fail on readiness checks until it becomes a master. But I don't like this approach, because it will be confusing to distinguish if the pods are indeed failing, or just waiting to become a master?

Any thoughts are welcome

-- Serge
kubernetes
kubernetes-ingress
traefik

1 Answer

9/10/2018

So you don't need to use the k8s readiness probe for the traefik ingress, you can use a traefik backend health check defined in your k8s ingress through annotations. This way you don't forward to backends that are not active. For example:

kind: Ingress
metadata:
  name: specific-deployment
  annotations:
    traefik.backend.healthcheck.port: 8080
    traefik.backend.healthcheck.scheme: http
    traefik.backend.healthcheck.path: /health   
spec:
  rules:
  - host: specific.minikube
    http:
      paths:
      - path: /
        backend:
          serviceName: stilton
          servicePort: http

This way you can use the k8s readiness probes for your pods.

-- Rico
Source: StackOverflow