0
votes

I'm running kubernetes cluster in azure environment and I want to access kubernetes service apis from inside a pod container. But I cannot connect to https://kubernetes/ from inside a pod.

kubectl get services
NAME               CLUSTER_IP      EXTERNAL_IP   PORT(S)
kubernetes         10.16.0.1       <none>        443/TCP 

Even trying

curl -v --cacert /var/run/kubernetes/apiserver.crt https://10.16.0.1:443/api/v1/namespaces/default/pods

results in

  • Trying 10.16.0.1...
  • Connected to 10.16.0.1 (10.16.0.1) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
  • successfully set certificate verify locations:
  • CAfile: /var/run/kubernetes/apiserver.crt CApath: /etc/ssl/certs
  • TLSv1.2 (OUT), TLS header, Certificate Status (22):
  • TLSv1.2 (OUT), TLS handshake, Client hello (1):
  • Unknown SSL protocol error in connection to 10.16.0.1:443
  • Closing connection 0 curl: (35) Unknown SSL protocol error in connection to 10.16.0.1:443
1
Does it work if you run curl -k ... (e.g. is it just the SSL verification that is failing)?Robert Bailey
Already tried with -k option. same issue.Phagun Baya
Debugged this issue further. In gce environment from within a pod I can run curl -v -k https://kubernetes but in azure environment kubernetes is not getting resolved to corresponding IP address.Phagun Baya
Can you check to see if the kubernetes service has any endpoints registered (run kubectl get endpoints)?Robert Bailey
Yes endpoint is assigned but port is 6443Phagun Baya

1 Answers

1
votes

Following fix worked:

  1. Changed line https://github.com/kubernetes/kubernetes/blob/v1.2.0/docs/getting-started-guides/coreos/azure/cloud_config_templates/kubernetes-cluster-main-nodes-template.yml#L218 to have --bind-address=0.0.0.0 option also.
  2. Created kubernetes cluster
  3. Made kubernetes api port accessible from outside.

You can access kubernetes api using host as node's ip address and the port.