From a pod, I'm trying to get information about a service, using the kubernetes api. Up until a couple of weeks ago, it was working just fine. I'm not sure what changed. Here's the code I'm using:
SERVICE_NAME="rabbitmq"
KUBE_TOKEN=`cat /var/run/secrets/kubernetes.io/serviceaccount/token`
KUBE_BASE_API_URL="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_PORT_443_TCP_PORT}/api/v1/namespaces/${KUBERNETES_POD_NAMESPACE}"
KUBE_AUTH_HEADER="Authorization: Bearer $KUBE_TOKEN"
SERVICE_INFO=$(/usr/bin/curl -sSk -H "${KUBE_AUTH_HEADER}" "$KUBE_BASE_API_URL/endpoints/$SERVICE_NAME")
I'm populating the KUBERNETES_POD_NAMESPACE
environment variable using the downward api. The value of SERVICE_INFO
is Unauthorized
I don't know if it's related or not, but i noticed when I tried to ping https://kubernetes
, I get ping: unknown host https://kubernetes
. However, I believe kube-dns is running just fine, because it looks up http://rabbitmq
just fine.
I'm on Kubernetes v1.1.1, and I'm using local machines that are running CoreOS.
In order to fix it, I wound up having to recreate the master. I'm still not sure exactly what happened