gpt4 book ai didi

azure - 无法将 yaml 部署到 Azure 中的 Kubernetes 集群

转载 作者:行者123 更新时间:2023-12-02 12:04:09 24 4
gpt4 key购买 nike

我有一个镜像,我正在尝试将其部署到 AKS 群集。该图像存储在 Azure 容器注册表中,我只是尝试使用以下命令应用 YAML 文件将其加载到 AKS 中:

kubectl apply -f myPath\myimage.yaml

kubectl 一直提示我缺少必需的“选择器”字段,并且“规范”字段未知。这似乎是一个基本的图像配置,所以我不知道还能尝试什么。

kubectl : error: error validating "myimage.yaml": error validating data: [ValidationError(Deployment.spec): unknown field "spec" in io.k8s.api.apps.v1.DeploymentSpec, ValidationError(Deployment.spec): missing required field "selector" in io.k8s.api.apps.v1.DeploymentSpec]; if you choose to ignore these errors, turn validation off with --validate=false At line:1 char:1

apiVersion: apps/v1
kind: Deployment
metadata:
name: myimage
spec:
replicas: 1
template:
metadata:
labels:
app: myimage
spec:
containers:
- name: myimage
image: mycontainers.azurecr.io/myimage:v1
ports:
- containerPort: 5000

最佳答案

您的第二个 spec 字段缩进不正确,并且您还错过了第一个 spec 中的 selector:

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: myimage
spec:
replicas: 1
selector:
matchLabels:
app: myimage
template:
metadata:
labels:
app: myimage
spec:
containers:
- name: myimage
image: mycontainers.azurecr.io/myimage:v1
ports:
- containerPort: 5000

关于azure - 无法将 yaml 部署到 Azure 中的 Kubernetes 集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56300332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com