How to access Kubernetes API when using minkube?

What is the correct way to configure a kubernetes cluster with minikube via the kubernetes api? At the moment, I can’t find the port through which I can access the cluster of the kubernetes.

+4
source share
3 answers

Startup minikube startwill automatically configure kubectl.

You can run minikube ipto get the IP address on which your mini cube is enabled. The API server runs by default at 8443.


. API , SSL-. . : ~/.minikube/apiserver.crt ~/.minikube/apiserver.key. HTTPS .

curl, --cert --key . . docs.

+8

API Kubernetes minikube -

kubectl proxy --port=8080

API

curl http://localhost:8080/api/

API . -,

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

kubectl proxy http://localhost:8080/swagger-ui/ .

API Kubernetes curl,

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

. minikube, , API , kubectl proxy.

+3

I went through many answers, but many of them are wrong.

Before we do this, we need an IP and a token.

How to get IP : minikube ip How to create a token :

$export secret=kubectl get serviceaccount default -o json | jq -r '.secrets[].name'

$kubectl get secret $secret -o yaml | grep "token:" | awk {'print $2'} |  base64 -D > token

Note: base64 uses -D for mac, but -d for Linux.

Then the correct command:

#curl -v -k -H --cacert ~/.minikube/ca.crt -H "Authorization: Bearer $(cat ~/YOUR_TOKEN)"  "https://{YOUR_IP}:8443/api/v1/pods"
+1
source

Source: https://habr.com/ru/post/1661459/


All Articles