Symptom
When you create object such as pod, service, replicationcontroller in Kubernetes, you may get error information as below:
No API token found for service account “default”, retry after the token is automatically created and added to the service account
Resolution
Disable service account authentication from Kubernetes admission control
- Edit
/etc/kubernetes/apiserver
, delete ServiceAccount item inKUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
- Restart Kubernetes service in Master.
systemctl restart etcd kube-apiserver kube-controller-manager kube-scheduler
Generate service account ssl key
- Generate ssl key
openssl genrsa -out /etc/kubernetes/serviceaccount.key 2048
- Edit
/etc/kubenetes/apiserver
, addKUBE_API_ARGS="--service_account_key_file=/etc/kubernetes/serviceaccount.key"
- Edit
/etc/kubernetes/controller-manager
, addKUBE_CONTROLLER_MANAGER_ARGS="--service_account_private_key_file=/etc/kubernetes/serviceaccount.key"
- Restart Kubernetes service in Master.
systemctl restart etcd kube-apiserver kube-controller-manager kube-scheduler