Can not find out the leader over HTTP in "Simple leader election with Kubernetes"

4/23/2019

I am currently doing some tests based on this link

Everything works well until this step: http://localhost:8001/api/v1/proxy/namespaces/default/pods/(leader-pod-name):4040/

I receive error when I access to this link:

kind    "Status"
apiVersion  "v1"
metadata    {}
status  "Failure"
message "pods \"leader-elector-5f456c7b49-4rdd6:4040\" not found"
reason  "NotFound"
details 
name    "leader-elector-5f456c7b49-4rdd6:4040"
kind    "pods"
code    404

Is there any wrong in the format?

Note: I can get the pod leader when I access into a pod (by kubectl exec -it ...) and use "curl localhost:4040"

-- nguyennd
kubernetes

1 Answer

4/23/2019

Just use this URL: http://localhost:8001/api/v1/namespaces/default/pods/<leader-pod-name>:4040/proxy in order to reach proxy port on the target Pod via Kubernetes API. Find useful tutorial here.

-- mk_sta
Source: StackOverflow