Kubernetes容器挂在ContainerCreating上

我已经创build了一个我知道可用的容器,并且已经在一个“只有主人”的Kubernetes上进行了testing。 我现在想要在一个奴隶上运行pod。 我已经使用kubeadm init出一个集群,并且kubeadm join <IP>:6443 --discovery-token-unsafe-skip-ca-verification --token XXXXXXjoin一个从VM。 尝试从以下YAML创build一个吊舱时吊舱挂在ContainerCreating:

 apiVersion: apps/v1beta1 kind: StatefulSet metadata: name: psql spec: serviceName: "psql-svc" replicas: 3 template: metadata: labels: app: psqllogical spec: terminationGracePeriodSeconds: 10 containers: - name: psqllogical image: psqllogical:v1 imagePullPolicy: Never ports: - containerPort: 5432 name: dbport volumeMounts: - name: db mountPath: /var/lib/postgresql/data volumeClaimTemplates: - metadata: name: db spec: accessModes: [ "ReadWriteOnce" ] storageClassName: psql-pv resources: requests: storage: 100Mi 

该图像是本地存储的,并成功地在单个主机上build立。 还有其他的YAML(PV,一些服务)。

kubectl describe pod POD_NAME回应:

 Name: psql-0 Namespace: default Node: <NODEIP> Start Time: Sun, 10 Dec 2017 07:30:20 +0000 Labels: app=psqllogical controller-revision-hash=psql-7857d68df8 Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"StatefulSet","namespace":"default","name":"psql","uid":"fc981daa-dd7b-11e7-9ce6-005056bd34c3","apiVersion"... Status: Pending IP: Created By: StatefulSet/psql Controlled By: StatefulSet/psql Containers: psqllogical: Container ID: Image: psqllogical:v1 Image ID: Port: 5432/TCP State: Waiting Reason: ContainerCreating Ready: False Restart Count: 0 Environment: <none> Mounts: /var/lib/postgresql/data from db (rw) /var/run/secrets/kubernetes.io/serviceaccount from default-token-h4j6k (ro) Conditions: Type Status Initialized True Ready False PodScheduled True Volumes: db: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: db-psql-0 ReadOnly: false default-token-h4j6k: Type: Secret (a volume populated by a Secret) SecretName: default-token-h4j6k Optional: false QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.alpha.kubernetes.io/notReady:NoExecute for 300s node.alpha.kubernetes.io/unreachable:NoExecute for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal SuccessfulMountVolume 4m kubelet, <SlaveIP> MountVolume.SetUp succeeded for volume "pv1" Normal SuccessfulMountVolume 4m kubelet, <SlaveIP> MountVolume.SetUp succeeded for volume "default-token-h4j6k" Normal Scheduled 4m default-scheduler Successfully assigned psql-0 to <IP> Warning FailedCreatePodSandBox 21s kubelet, <SlaveIP> Failed create pod sandbox. Warning FailedSync 21s kubelet, <SlaveIP> Error syncing pod Normal SandboxChanged 20s kubelet, <SlaveIP> Pod sandbox changed, it will be killed and re-created. 

kubectl logs psql-0

 Error from server (BadRequest): container "psqllogical" in pod "psql-0" is waiting to start: ContainerCreating 

kubectl describe node <SlaveIP>报告有足够的资源,据说就绪。

这两个虚拟机都运行CentOS 7,K8s版本1.85,Docker版本1.12.6。 我已经testing过,这也发生在其他的Docker镜像上,而不仅仅是我自定义的postgres镜像。 虚拟机由Openstackpipe理。

我做了以下:

  • 确保港口是开放的
  • 确保selinux已禁用
  • 与奴隶拼合
  • 尝试了另外的Docker容器,它也挂在ContainerCreating上
  • 确保psql YAML成功地在单个节点集群上工作
  • 在主机和从机上构build自定义映像(如果需要,不确定)