【发布时间】:2021-11-25 08:17:12
【问题描述】:
这个让我摸不着头脑
gke-deploy 无法在容器注册表中找到映像。 在检查 Pod 时,我看到以下内容:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 15m gke.io/optimize-utilization-scheduler Successfully assigned <namespace>/<app>-78c9f7dc4b-svgds to gke-<cluster>-d-preemptible-node-e150c774-pmtw
Normal Pulling 13m (x4 over 15m) kubelet Pulling image "gcr.io/<project>/<image>"
Warning Failed 13m (x4 over 15m) kubelet Failed to pull image "gcr.io/<project>/<image>": rpc error: code = Unknown desc = Error response from daemon: manifest for gcr.io/<project>/<image>:latest not found: manifest unknown: Failed to fetch "latest" from request "/v2/<projet>/<image>/manifests/latest".
Warning Failed 13m (x4 over 15m) kubelet Error: ErrImagePull
Warning Failed 5m8s (x42 over 15m) kubelet Error: ImagePullBackOff
Normal BackOff 3s (x64 over 15m) kubelet Back-off pulling image "gcr.io/<project>/<image>"
除了上面的错误,我使用了GCR的特定标签,并且部署成功。
我知道所有的拼写都是正确的,因为我检查了很多次。我复制 GCP 路径并将其与 deployment.yaml 进行比较
我的 deployment.yaml 如下所示:
(元数据)
apiVersion: apps/v1
kind: Deployment
metadata:
name: <app>
namespace: <namespace>
labels:
app: <app>
(规格)
replicas: 1
selector:
matchLabels:
app: <app>
template:
metadata:
labels:
app: <app>
spec:
containers:
- name: <image>
image: gcr.io/<project>/<image>
env:
# a bunch of env
resources:
requests:
memory: '100Mi'
cpu: '50m'
limits:
memory: '500Mi'
cpu: '100m'
(自动缩放)
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: <app>-hpa
namespace: <namespace>
labels:
app: <app>
spec:
scaleTargetRef:
kind: Deployment
name: <app>
apiVersion: apps/v1
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 60
我不知道为什么它只适用于特定的图像标签!任何帮助将不胜感激
编辑和更新:
原来问题出在cloudbuild.yaml(我之前省略了)。
我的云构建包含以下部分:
steps:
- 使用
-t gcr.io/<project>/<image>:$BUILD_ID标签构建镜像 - 推图
gcr.io/<project>/<image>:$BUILD_ID - 带有标志的 GKE Deploy:文件名、图像(尝试使用和不使用)、位置、集群、输出(出于某些不相关的原因)
images:
'gcr.io/<project>/<image>:$BUILD_ID'
保持 deployment.yaml 不变,我更改了 cloudbuild.yaml,构建工作正常:
- 在第 3 步 GKE 部署中包含
image=gcr.io/<project>/<image>:$BUILD_ID标志 - 删除了
images:部分。
由于某种原因,当您在 cloudbuild 文件中包含图像时,它会限制 gke-deploy 访问除这些图像之外的任何内容。
另一种方法是将'gcr.io/<project>/<image>:latest' 添加到标签和图像中,但我认为这不是一个好习惯。
【问题讨论】:
标签: google-kubernetes-engine google-container-registry