转自:http://www.voidcn.com/blog/jinzhencs/article/p-5975011.html
问题1: 虽然每次通过yaml创建rc都显示成功了,但是 kubectl get pod却没显示任何的pod.
问题2: 直接通过yaml创建pod提示apixxx
问题3: 通过.json文件创建pod 未验证
原因是身份认证 解决方法有两种,我用的第一种:
- 跳过认证
http://www.sunmite.com/linux/installing-kubernetes-cluster-on-centos7-to-manage-pods-and-services/
创建pod:
# kubectl create -f nginx.yaml
此时有如下报错:
Error from server: error when creating "nginx.yaml": Pod "nginx" is forbidden: no API token found for service account default/default, retry after the token is automatically created and added to the service account
解决办法:
编辑/etc/kubernetes/apiserver
去除 KUBE_ADMISSION_CONTROL
中的SecurityContextDeny,ServiceAccount
,并重启kube-apiserver
服务:
vim /etc/kubernetes
/apiserverKUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"
ystemctl restart kube-apiserver
之后重新创建pod:
kubectl create -f nginx.yamlpods/nginx
- 解决认证
出处:pod出错解决
To get your setup working, you can do the same thing local-up-cluster.sh is doing:
Generate a signing key: openssl genrsa -out /tmp/serviceaccount.key 2048
Update /etc/kubernetes/apiserver: KUBE_API_ARGS=”–service_account_key_file=/tmp/serviceaccount.key”
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
完了之后可以看到pod了,但是发现是挂起状态,pending,于是查了下发现是因为无法从gcr.io拉取pause0.8.0的镜像。那么很简单 就找个可用的镜像拉取即可。 docker pull docker.io/kubernetes/pause
OK了!。至此,问题解决。