简体   繁体   中英

Connecting to Kubernetes API from pod

I'm trying to use Kubernetes API from inside a pod. Going to list/watch pods and custom defined resources.

Construct url as " https://KUBERNETES_SERVICE_HOST:KUBERNETES_SERVICE_PORT_HTTPS " Authorization header = "Bearer /var/run/secrets/kubernetes.io/serviceaccount/token" CaCert = /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

When running inside minikube, the request fails with "Error: connect ETIMEDOUT 10.96.0.1:443" Same code running in GCP fails with: "Error: unable to verify the first certificate"

If you are using curl , you can skip certificate checks with the -k flag.

Try

curl -k  https://10.96.0.1:443/api/v1/namespaces -H "Authorization: Bearer <content of /var/run/secrets/kubernetes.io/serviceaccount/token here>"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM