kubenetes can't create pod/can't automatically create pod when creating RC

Question 1: 
Although every time the rc is created through yaml, it shows that it is successful, but 
kubectl get pod does not show any pods.

Question 2: 
Creating a pod directly through yaml prompts apixxx

Problem 3: 
Creating pods via .json file 
is not validating


The reason is that there are two authentication 
solutions, the first one I use:

1. Skip authentication

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.service服务:

#vim /etc/kubernetes/apiserver
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"

#systemctl restart kube-apiserver.service
之后重新创建pod:

# kubectl create -f nginx.yaml
pods/nginx
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

2. Solve the authentication

Source: 
http://stackoverflow.com/questions/34464779/pod-mysql-is-forbidden-no-api-token-found-for-service-account-default-default

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

现在再来看看pod: 
这里写图片描述

OK了!。至此,问题解决。

 

http://blog.csdn.net/jinzhencs/article/details/51435020

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326672854&siteId=291194637