我正在尝试在 GCP 的 Kubernetes 集群中执行我的第一次应用程序部署。
我在容器注册中有我的应用程序的图像。
eu.gcr.io/diaphanum/bonsai-landing:v1
Run Code Online (Sandbox Code Playgroud)
我使用的清单文件是 deploy-ironia.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: bonsai-landing
spec:
selector:
matchLabels:
app: bonsai-landing
replicas: 3
template:
metadata:
labels:
app: bonsai-landing
spec:
containers:
- name: bonsai-landing
image: "eu.gcr.io/diaphanum/bonsai-landing:v1"
ports:
- containerPort: 8080
Run Code Online (Sandbox Code Playgroud)
使用以下命令从 GCP shell 进行部署:
kubectl apply -f deploy-ironia.yaml
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
error: error validating "deploy-ironia.yaml": error validating data: [ValidationError (Deployment.spec): unknown field "containers" in io.k8s.api.apps.v1.DeploymentSpec, ValidationError (Deployment.spec) : "mandatory" field selector "is missing in io.k8s.api.apps.v1.DeploymentSpec, ValidationError (Deployment.spec): the mandatory field" template "is missing …Run Code Online (Sandbox Code Playgroud)