您好Kubernetes开发人员,
如果在kubernetes中部署pod,我会收到错误'ImagePullBackOff'。从git-hub仓库中调用docker来获取映像没有问题。但是我的配置有什么问题?
我尝试过使用以下命令创建一个密钥。
kubectl create secret docker-registry secretkey \
--docker-server=registry.hub.docker.com \
--docker-username=reponame \
--docker-password=repopassword \
--docker-email=repoemail
这是用于创建kubernetes pod的yaml文件。
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
io.kompose.service: gps-restful-server
name: gps-restful-server
spec:
containers:
- image: tux/gps:latest
name: gps-restful-server
ports:
- containerPort: 8080
resources: {}
volumeMounts:
- mountPath: /var/www/html/modules
name: gps-modules
- mountPath: /var/www/html/profiles
name: gps-profile
- mountPath: /var/www/html/themes
name: gps-theme
- mountPath: /var/www/html/sites
name: gps-sites
imagePullPolicy: Always
restartPolicy: OnFailure
imagePullSecrets:
- name: secretkey
volumes:
- name: gps-modules
persistentVolumeClaim:
claimName: gps-modules
- name: gps-profile
persistentVolumeClaim:
claimName: gps-profile
- name: gps-theme
persistentVolumeClaim:
claimName: gps-theme
- name: gps-sites
persistentVolumeClaim:
claimName: gps-sites
status: {}
要在kubernetes中部署Pod,我执行以下命令:
kubectl create -f gps-restful-server-pod.yaml.
从Pod获取状态:
kubectl get all
NAME READY STATUS RESTARTS AGE
pod/telemetry-restful-server 0/1 ImagePullBackOff 0 12m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
pod的描述:
kubectl describe pod gps-restful-server
Name: gps-restful-server
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: minikube/192.168.178.92
Start Time: Thu, 14 Feb 2019 16:56:25 +0100
Labels: io.kompose.service=gps-restful-server
Annotations: <none>
Status: Pending
IP: 172.17.0.3
Containers:
gps-restful-server:
Container ID:
Image: tux/gps:latest
Image ID:
Port: 8080/TCP
Host Port: 0/TCP
State: Waiting
Reason: ImagePullBackOff
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-4t28k (ro)
/var/www/html/modules from gps-modules (rw)
/var/www/html/profiles from gps-profile (rw)
/var/www/html/sites from gps-sites (rw)
/var/www/html/themes from gps-theme (rw)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
gps-modules:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: gps-modules
ReadOnly: false
gps-profile:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: gps-profile
ReadOnly: false
gps-theme:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: gps-theme
ReadOnly: false
gps-sites:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: gps-sites
ReadOnly: false
default-token-4t28k:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-4t28k
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 4m default-scheduler Successfully assigned default/gps-restful-server to minikube
Normal Pulling 2m (x4 over 4m) kubelet, minikube pulling image "tux/gps:latest"
Warning Failed 2m (x4 over 4m) kubelet, minikube Failed to pull image "tux/gps:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for tux/gps, repository does not exist or may require 'docker login'
Warning Failed 2m (x4 over 4m) kubelet, minikube Error: ErrImagePull
Warning Failed 2m (x6 over 4m) kubelet, minikube Error: ImagePullBackOff
Normal BackOff 2m (x7 over 4m) kubelet, minikube Back-off pulling image "tux/gps:latest"
怎么可能从kubernetes的docker-hub中提取图像?
4条答案
按热度按时间llycmphe1#
Image tux/gps:latest不存在,因为它是伪值。ImagePullBackoff的解决方案:
1.请确保您的映像指向最新版本repouser/reponame:latest
1.创建一个秘密的docker-registry(看上面)
1.服务器地址[docker-hub registry]
1.在pod yaml文件中添加以下属性(查看上面):
图像提取秘密:
uz75evzq2#
此问题是由于密钥
pods.spec.containers.image
的值错误所致。容器的image属性支持与docker命令相同的语法,包括私有注册表和标记。
k8s Images
ovfsdjhp3#
imagebackpulloff
可能由以下原因引起:mf98qq944#
当你在kubernetes中得到一个imagepullbackoff错误时,可能是docker存储库名称指定错误或者图像标记不正确.
返回到你的Docker集线器并确认标签版本是否正确。
如果image标记是V3,而您在kubernetes部署清单中指定了V1,那么它就会抱怨。
还要仔细检查存储库名称和部署清单中的内容。
这些小疏忽可能是令人头痛的故障排除。