Minikube: There is an issue with API access using a token

Created on 1 May 2018  路  3Comments  路  Source: kubernetes/minikube

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG

Please provide the following details:

Environment:

minikube version: v0.26.1

OS:
Darwin xxx.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64

VM driver:
"DriverName": "virtualbox",

ISO version
"Boot2DockerURL": "file:///Users/stas/.minikube/cache/iso/minikube-v0.26.0.iso",

What happened:
k8s API authentication with a Bearer token doesn't work
What you expected to happen:
Successful API call

How to reproduce it (as minimally and precisely as possible):
from https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/

minikube start

APISERVER=$(kubectl config view | grep server | cut -f 2- -d ":" | tr -d " ")

TOKEN=$(kubectl describe secret $(kubectl get secrets | grep default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d '\t')

curl "$APISERVER/api/v1/pods" --header "Authorization: Bearer $TOKEN" --insecure

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {

  },
  "status": "Failure",
  "message": "pods is forbidden: User \"system:anonymous\" cannot list pods at the cluster scope",
  "reason": "Forbidden",
  "details": {
    "kind": "pods"
  },
  "code": 403
}

Most helpful comment

@ShoryuKyzan, @StasPerekrestov you should create anonymous role binding first and then it should work for you
kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous

All 3 comments

What fixed it for you?

It's been a long time since I played with minikube.
If I'm not mistaken the issue related to lack of appropriate permissions.
Unfortunately, I've lost the saved command that grants the appropriate permissions.
I believe I was told the right solution here https://kubernetes.slack.com

@ShoryuKyzan, @StasPerekrestov you should create anonymous role binding first and then it should work for you
kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous

Was this page helpful?
0 / 5 - 0 ratings