文件 pod_nginx.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
创建 kubectl create
kubectl create -f pod_nginx.yml
使用命令查看 pods 状态,很久还是没有启动成功
zousiliangdeMacBook-Pro:pod-basic zousiliang$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 ContainerCreating 0 30m 172.17.0.2 minikube
查看详情
zousiliangdeMacBook-Pro:pod-basic zousiliang$ kubectl describe pod nginx
Name: nginx
Namespace: default
Node: minikube/192.168.99.100
Start Time: Mon, 08 Apr 2019 00:24:03 +0800
Labels: app=nginx
Annotations: <none>
Status: Pending
IP:
Containers:
nginx:
Container ID:
Image: nginx
Image ID:
Port: 80/TCP
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-5bz7m (ro)
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes:
default-token-5bz7m:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-5bz7m
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 14s default-scheduler Successfully assigned nginx to minikube
Normal SuccessfulMountVolume 14s kubelet, minikube MountVolume.SetUp succeeded for volume "default-token-5bz7m"
Warning FailedCreatePodSandBox 0s kubelet, minikube Failed create pod sandbox.
错误提示为:
Warning FailedCreatePodSandBox 0s kubelet, minikube Failed create pod sandbox.
获知为使用地址 gcr.io/google_containers/pause-amd64:3.0 进行拉取镜像,但是这个地址被墙了
$ docker pull docker.io/kubernetes/pause
$ docker tag kubernetes/pause:latest gcr.io/google_containers/pause-amd64:3.0
最后把原来的 pod 删除掉,再重新启动即可。
zousiliangdeMacBook-Pro:pod-basic zousiliang$ kubectl delete -f pod_nginx.yml
pod "nginx" deleted
zousiliangdeMacBook-Pro:pod-basic zousiliang$ kubectl create -f pod_nginx.yml
pod "nginx" created
zousiliangdeMacBook-Pro:pod-basic zousiliang$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 14m
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于