问题描述
我正在GKE中创建一个具有以下(标准)部署的部署
I am creating a deployment in GKE with a following (standard) deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-deployment
spec:
replicas: 1
selector:
matchLabels:
component: api
template:
metadata:
labels:
component: api
spec:
containers:
- name: api
image: eu.gcr.io/xxxx-xxx/api:latest
imagePullPolicy: Always
resources:
requests:
memory: "320Mi"
cpu: "100m"
limits:
memory: "450Mi"
cpu: "150m"
ports:
- containerPort: 5010
但是,由于某些原因,GKE抱怨权限问题.容器位于同一项目和PRIVATE的容器注册表中,但是据我所知,如果它与GCP项目一起使用,则GKE应该可以访问. GKE群集是vpc原生的(如果可能会有所作为),因为这是我可以想到的唯一区别,与我以前使用相同的容器和安装程序运行的群集相比.
However, for some reason GKE complains about a permission issue. The containers are in container registry of the same project and PRIVATE, but as far as I am aware if it with a GCP project GKE should be able to have access. The GKE cluster is vpc-native (if that might make a difference) as that is the only difference I can think of compared a cluster I used to run with the same containers and installers.
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 34m default-scheduler Successfully assigned default/api-deployment-f68977b84-fmhdx to gke-gke-dev-cluster-default-pool-6c6bb127-nw61
Normal Pulling 32m (x4 over 33m) kubelet, gke-gke-dev-cluster-default-pool-6c6bb127-nw61 pulling image "eu.gcr.io/xxxx-xxx/api:latest"
Warning Failed 32m (x4 over 33m) kubelet, gke-gke-dev-cluster-default-pool-6c6bb127-nw61 Failed to pull image "eu.gcr.io/xxxx-xxx/api:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for eu.gcr.io/xxxx-xxx/api, repository does not exist or may require 'docker login'
Warning Failed 32m (x4 over 33m) kubelet, gke-gke-dev-cluster-default-pool-6c6bb127-nw61 Error: ErrImagePull
Normal BackOff 32m (x6 over 33m) kubelet, gke-gke-dev-cluster-default-pool-6c6bb127-nw61 Back-off pulling image "eu.gcr.io/xxxx-xxx/api:latest"
Warning Failed 3m59s (x131 over 33m) kubelet, gke-gke-dev-cluster-default-pool-6c6bb127-nw61 Error: ImagePullBackOff
我是否还需要为带有Google云存储库的GKE群集添加ImageSecrets,还是可能会有其他问题?
Do I need to add ImageSecrets as well for GKE clusters with the google cloud repository or might there be another problem?
GKE集群是使用TerraForm和以下用于GKE的gke.tf创建的
The GKE cluster was created using TerraForm with the following gke.tf for GKE
resource "google_container_cluster" "primary" {
name = "gke-${terraform.workspace}-cluster"
zone = "${var.region}-b"
additional_zones = [
"${var.region}-c",
"${var.region}-d",
]
# minimum kubernetes version for master
min_master_version = "${var.min_master_version}"
# version for the nodes. Should equal min_master_version on create
node_version = "${var.node_version}"
initial_node_count = "${var.gke_num_nodes[terraform.workspace]}"
network = "${var.vpc_name}"
subnetwork = "${var.subnet_name}"
addons_config {
http_load_balancing {
disabled = false # this is the default
}
horizontal_pod_autoscaling {
disabled = false
}
kubernetes_dashboard {
disabled = false
}
}
# vpc-native network
ip_allocation_policy {
# use_ip_aliases = true
}
master_auth {
username = "${var.gke_master_user}"
password = "${var.gke_master_pass}"
}
node_config {
oauth_scopes = [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
]
labels = {
env = "${var.gke_label[terraform.workspace]}"
}
disk_size_gb = 10
machine_type = "${var.gke_node_machine_type}"
tags = ["gke-node"]
}
}
运行gcloud gcloud容器集群描述了[CLUSTER]给出的
running gcloud gcloud container clusters describe [CLUSTER] gives
nodePools:
- config:
diskSizeGb: 10
diskType: pd-standard
imageType: COS
labels:
env: dev
machineType: n1-standard-1
metadata:
disable-legacy-endpoints: 'true'
oauthScopes:
- https://www.googleapis.com/auth/monitoring
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/compute
serviceAccount: default
所以devstorage.read_only似乎在那里
so devstorage.read_only seems to be there
推荐答案
您的GKE群集节点池是否配置了https://www.googleapis.com/auth/devstorage.read_only
OAuth范围?
Are your GKE cluster node pools configured with the https://www.googleapis.com/auth/devstorage.read_only
OAuth scope?
要检查,您可以运行gcloud container clusters describe [CLUSTER NAME]
:作用域在oauthScopes
属性下列出.或在GCP信息中心查看您的节点池详细信息:
To check you can run gcloud container clusters describe [CLUSTER NAME]
: scopes are listed under the oauthScopes
property. Or check your node pool details at the GCP dashboard:
Storage
应该启用.
这篇关于具有私有Google Cloud存储库的GKE上的ImagePullBackOff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!