Jonathan
Jonathan

Reputation: 11375

Pod "mysql" is forbidden: no API token found for service account default/default

I have the following mysql.yaml file:

apiVersion: v1beta3
kind: Pod
metadata:
  name: mysql
  labels:
    name: mysql
spec:
  containers:
    - resources:
        limits :
          cpu: 1
      image: mysql
      name: mysql
      env:
        - name: MYSQL_ROOT_PASSWORD
          # change this
          value: yourpassword
      ports:
        - containerPort: 3306
          name: mysql

Running kubectl create -f mysql.yaml gives the error:

Error from server: error when creating "mysql.yaml": Pod "Unknown" is forbidden: no API token found for service account default/default, retry after the token is automatically created and added to the service account

I have a master and a node both centos 7.1.

Upvotes: 3

Views: 3241

Answers (1)

Jonathan
Jonathan

Reputation: 11375

To get your setup working, you can do the same thing local-up-cluster.sh is doing:

  1. Generate a signing key:

openssl genrsa -out /tmp/serviceaccount.key 2048

  1. Update /etc/kubernetes/apiserver:

KUBE_API_ARGS="--service_account_key_file=/tmp/serviceaccount.key"

  1. Update /etc/kubernetes/controller-manager:

KUBE_CONTROLLER_MANAGER_ARGS="--service_account_private_key_file=/tmp/serviceaccount.key"

From https://github.com/kubernetes/kubernetes/issues/11355#issuecomment-127378691

Upvotes: 3

Related Questions