How to access Kubernetes API when using minkube?

KarateKid picture KarateKid · Nov 21, 2016 · Viewed 15.6k times · Source

What is correct way to kubernetes cluster setup using minikube through the kubernetes api ? At the moment, I can't find a port through which the kubernetes cluster can be accessed.

Answer

Sven Marnach picture Sven Marnach · Sep 13, 2017

The easiest way to access the Kubernetes API with when running minikube is to use

kubectl proxy --port=8080

You can then access the API with

curl http://localhost:8080/api/

This also allows you to browse the API in your browser. Start minikube using

minikube start --extra-config=apiserver.Features.EnableSwaggerUI=true

then start kubectl proxy, and navigate to http://localhost:8080/swagger-ui/ in your browser.

You can access the Kubernetes API with curl directly using

curl --cacert ~/.minikube/ca.crt --cert ~/.minikube/client.crt --key ~/.minikube/client.key https://`minikube ip`:8443/api/

but usually there is no advantage in doing so. Common browsers are not happy with the certificates minikube generates, so if you want to access the API with your browser you need to use kubectl proxy.