[root@master ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.3.228:5000/test/s v1 fdcfe04e9ea4 3 days ago 398MB
sshd v1 fdcfe04e9ea4 3 days ago 398MB
192.168.3.228:5000/test/n v1 588bb5d559c2 5 days ago 127MB
nginx 1.16 588bb5d559c2 5 days ago 127MB
registry 2 708bc6af7e5e 2 months ago 25.8MB
registry latest 708bc6af7e5e 2 months ago 25.8MB
192.168.3.228:5000/test/1 v1 708bc6af7e5e 2 months ago 25.8MB
mkdir -p /opt/yml/test
cd /opt/yml/test
vim k8s_pod.yml
apiVersion: v1 kind: Pod metadata: name: nginx lablels: app: web spec: containers: - name: n1 image: 192.168.3.228:5000/test/n:v1 ports: - containerPort: 80
[root@master test]# kubectl create -f k8s_pod.yml
error: error validating "k8s_pod.yml": error validating data: found invalid field lablels for v1.ObjectMeta; if you choose to ignore these errors, turn validation off with --validate=false (这里提示上面标签出错。lables部分)
[root@master test]# kubectl create -f k8s_pod.yml --validate=false
pod "nginx" created (这里代表成功了)
[root@master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 0/1 ContainerCreating 0 4m 问题在这里,不断创建中
[root@master ~]# kubectl describe pods nginx Name: nginx Namespace: default Node: 192.168.3.229/192.168.3.229 Start Time: Sun, 05 Apr 2020 14:02:25 -0400 Labels: <none> Status: Pending IP: Controllers: <none> Containers: n1: Container ID: Image: 192.168.3.228:5000/test/n:v1 Image ID: Port: 80/TCP State: Waiting Reason: ContainerCreating Ready: False Restart Count: 0 Volume Mounts: <none> Environment Variables: <none> Conditions: Type Status Initialized True Ready False PodScheduled True No volumes. QoS Class: BestEffort Tolerations: <none> Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 6m 6m 1 {default-scheduler } Normal ScheduleSuccessfully assigned nginx to 192.168.3.229 6m 1m 6 {kubelet 192.168.3.229} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)" 6m 7s 25 {kubelet 192.168.3.229} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""
Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)"
6m 7s 25 {kubelet 192.168.3.229} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\""
错误提示中文件pull去红帽pull的
解决上述问题需要pull个镜像到所有regisrty上
docker pull docker.io/tianyebj/pod-infrastructure
docker tag docker.io/tianyebj/pod-infrastructure:latest 192.168.3.228:5000/test/pod-infrastructure:latest
docker push 192.168.3.228:5000/test/pod-infrastructure:latest
node节点改vim /etc/kubernetes/kubelet
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=192.168.3.228:5000/test/pod-infrastructure:latest"
systemctl restart kubelet
mastar节点删除nginx:kubectl delete pod nginx
重建nginx
[root@master ~]# kubectl create -f /opt/yml/test/k8s_pod.yml --validate=false
pod "nginx" created
[root@master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 43s 1/1 Running为正常
[root@master ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 Running 0 10m 172.16.91.2 192.168.3.229
来源:https://www.cnblogs.com/Leaders543/p/12640362.html