koki / short

Manageable Kubernetes manifests through a composable, reusable syntax
https://docs.koki.io/short
Apache License 2.0
122 stars 14 forks source link

httpGet on liveness probes broken: inability to address pod's IP in NetAction? #208

Open sthetz opened 6 years ago

sthetz commented 6 years ago

Hello!

After converting my Kubernetes configs into Short format I noticed that my container with a Rails web app started failing liveness/readiness checks. Quick investigation revealed that the problem is default value of host in httpGet.

Here is the probe part of the original Kubernetes config:

livenessProbe:
  httpGet:
    path: /status/online
    port: 3000

When run through Short, it translates into this:

liveness_probe:
  net:
    url: HTTP://localhost:3000/status/online

Which in turn (when translated back into Kubernetes format) translates into this:

livenessProbe:
  httpGet:
    host: localhost
    path: /status/online
    port: 3000
    scheme: HTTP

So, Short adds explicit param host which defaults to localhost. However, Kubernetes documentation on probes states that the host param in httpGet defaults to pod's internal IP. So when liveness probe tries to access localhost instead of pod's IP, the probe fails.

sthetz commented 6 years ago

I found out that to avoid creating host: localhost line in Kubernetes config I have to simply remove the host from Short config, like this:

liveness_probe:
    delay: 15
    net:
      url: HTTP://:3000/status/online
wlan0 commented 6 years ago

Glad it worked out! Feel free to add any other issues if you face them!

The issue you've mentioned should be fixed, since it deviates from kube-api spec. I'll reopen it so that we can track it.