tczekajlo / kube-consul-register

a tool to register Kubernetes PODs as Consul Services
Apache License 2.0
105 stars 50 forks source link

Pods fail to register when using liveness command #32

Closed arunvelsriram closed 5 years ago

arunvelsriram commented 6 years ago

I am using register_mode: pod for registering the pods to consul agent running on the same node. The pod spec has a liveness probe command:

...
kind: Pod
...
livenessProbe:
  exec:
    command:
      - redis-cli
      - ping
  initialDelaySeconds: 5
  periodSeconds: 5
...

In this case, the liveness probe cannot be converted to consul health check. kube-consul-register is failing to register the pods because only httpGet and tcpSocket are handled here: controller/pods/controller.go#L492.

This forces users to modify the livenessProbe to either httpGet or tcpSocket. Most of the community helm charts uses command as livenessProbe. Instead of failing to register the pods to consul we can register them without consul health check. This allows users to use the community helm charts without patching them.

Am happy to implement this fix in kube-consul-register. Let me know if you are okay with the idea.

m4ce commented 5 years ago

Same issue here 👍

aswinkarthik commented 5 years ago

It is possible for Consul to exec into a docker container and then run a command. It is also possible to get the container ID from the Kubernetes Pod Status. This could be an alternative approach instead of skipping. Consul might need some extra previlege to run shell command into a container ID.