podテスト
7260 ワード
[root@master ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE192.168.3.228:5000/test/s v1 fdcfe04e9ea4 3 days ago 398MBsshd v1 fdcfe04e9ea4 3 days ago 398MB192.168.3.228:5000/test/n v1 588bb5d559c2 5 days ago 127MBnginx 1.16 588bb5d559c2 5 days ago 127MBregistry 2 708bc6af7e5e 2 months ago 25.8MBregistry latest 708bc6af7e5e 2 months ago 25.8MB192.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
[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=falsepod"nginx"created(ここでは成功を表します)
[root@master~]#kubectl get podNAME READY STATUS RESTARTS AGEnginx 0/1 ContainerCreating 0 4 m問題ここでは、どんどん作成中
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の
上記の問題を解決するには、すべてのregisrtyにpull個のミラーが必要です.
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=falsepod "nginx"created[root@master~]#kubectl get podNAME READY STATUS RESTARTS AGEnginx 1/1 Running 0 43 s 1/1 Runningが正常
[root@master ~]# kubectl get pods -o wideNAME READY STATUS RESTARTS AGE IP NODEnginx 1/1 Running 0 10m 172.16.91.2 192.168.3.229
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=falsepod"nginx"created(ここでは成功を表します)
[root@master~]#kubectl get podNAME READY STATUS RESTARTS AGEnginx 0/1 ContainerCreating 0 4 m問題ここでは、どんどん作成中
[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:
Status: Pending
IP:
Controllers:
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:
Environment Variables:
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations:
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の
上記の問題を解決するには、すべてのregisrtyにpull個のミラーが必要です.
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=falsepod "nginx"created[root@master~]#kubectl get podNAME READY STATUS RESTARTS AGEnginx 1/1 Running 0 43 s 1/1 Runningが正常
[root@master ~]# kubectl get pods -o wideNAME READY STATUS RESTARTS AGE IP NODEnginx 1/1 Running 0 10m 172.16.91.2 192.168.3.229