2 min read | by Jordi Prats
Some apps might rely on the host Header to deliver the right content. For example, is quite common for django apps to require an specific host header in order to sent a response. Lucky enough for these kind of applications, we can actually configure livenessProbe and readinessProbe to send a Host header
To do se we will have to set the httpHeaders attribute with the list of headers we can to sent, for the Host header it would be:
livenessProbe: httpGet: path: /health-check/ port: 8000 httpHeaders: - name: Host value: "pet2cattle-com"
We can also use it to set custom headers or even repeat headers multiple times. A full example with livenessProbe and readinessProbe on a Deployment would be:
apiVersion: apps/v1 kind: Deployment metadata: name: pet2cattle spec: (...) spec: containers: - name: pet2cattle image: pet2cattle:3.6 ports: - containerPort: 8000 name: http protocol: TCP livenessProbe: httpGet: httpHeaders: - name: Host value: pet2cattle.com path: /health/liveness port: http readinessProbe: httpGet: httpHeaders: - name: Host value: pet2cattle.com path: /health/readiness port: http (...)
Posted on 22/02/2021