Azure CLI 错误 json:无法将数组解组为 unstructured.detector 类型的 Go 值

Azure CLI error json: cannot unmarshal array into Go value of type unstructured.detector

我是 Azure Kubernetes 服务的新手。我创建了一个 Azure Kubernetes 集群并尝试在其中部署一些工作负载。 .yaml文件如下

- apiVersion: v1
  kind: Namespace
  metadata:
    name: azure-vote
  spec:
    finalizers:
      - kubernetes
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: azure-vote-back
    namespace: azure-vote
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: azure-vote-back
    template:
      metadata:
        labels:
          app: azure-vote-back
      spec:
        nodeSelector:
          beta.kubernetes.io/os: linux
        containers:
          - name: azure-vote-back
            image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
            env:
              - name: ALLOW_EMPTY_PASSWORD
                value: 'yes'
            resources:
              requests:
                cpu: 100m
                memory: 128Mi
              limits:
                cpu: 250m
                memory: 256Mi
            ports:
              - containerPort: 6379
                name: redis
- apiVersion: v1
  kind: Service
  metadata:
    name: azure-vote-back
    namespace: azure-vote
  spec:
    ports:
      - port: 6379
    selector:
      app: azure-vote-back
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: azure-vote-front
    namespace: azure-vote
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: azure-vote-front
    template:
      metadata:
        labels:
          app: azure-vote-front
      spec:
        nodeSelector:
          beta.kubernetes.io/os: linux
        containers:
          - name: azure-vote-front
            image: mcr.microsoft.com/azuredocs/azure-vote-front:v1
            resources:
              requests:
                cpu: 100m
                memory: 128Mi
              limits:
                cpu: 250m
                memory: 256Mi
            ports:
              - containerPort: 80
            env:
              - name: REDIS
                value: azure-vote-back
- apiVersion: v1
  kind: Service
  metadata:
    name: azure-vote-front
    namespace: azure-vote
  spec:
    type: LoadBalancer
    ports:
      - port: 80
    selector:
      app: azure-vote-front

当我通过 Azure CLI 部署这个 .yaml 时,它给我一个验证错误,但没有指出它在哪里?当我 运行 kubectl apply -f ./filename.yaml --validate=false 它给出 "cannot unmarshal array into Go value of type unstructured.detector" 错误。但是,当我 运行 在 Azure 门户 UI 中使用相同的 yaml 时,它 运行 没有任何错误。感谢是否有人可以提及此问题的原因以及如何解决此问题。

我尝试运行您在门户以及[中提供的代码=41=]Azure CLI。它通过添加 YAML codePortal UI 中成功创建,但使用 Azure CLI 我收到了与您相同的错误:

在您的 YAML file 中进行一些修改并验证后,我再次 运行 相同的命令,它成功部署在 Azure CLI:

YAML 文件:

apiVersion: v1
kind: Namespace
metadata:
  name: azure-vote
spec:
  finalizers:
    - kubernetes
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: azure-vote-back
  namespace: azure-vote
spec:
  replicas: 1
  selector:
    matchLabels:
      app: azure-vote-back
  template:
    metadata:
      labels:
        app: azure-vote-back
    spec:
      nodeSelector:
        "kubernetes.io/os": linux
      containers:
      - name: azure-vote-back
        image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
        env:
        - name: ALLOW_EMPTY_PASSWORD
          value: "yes"
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 250m
            memory: 256Mi
        ports:
        - containerPort: 6379
          name: redis
---
apiVersion: v1
kind: Service
metadata:
  name: azure-vote-back
spec:
  ports:
  - port: 6379
  selector:
    app: azure-vote-back
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: azure-vote-front
  namespace: azure-vote
spec:
  replicas: 1
  selector:
    matchLabels:
      app: azure-vote-front
  template:
    metadata:
      labels:
        app: azure-vote-front
    spec:
      nodeSelector:
        "kubernetes.io/os": linux
      containers:
      - name: azure-vote-front
        image: mcr.microsoft.com/azuredocs/azure-vote-front:v1
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 250m
            memory: 256Mi
        ports:
        - containerPort: 80
        env:
        - name: REDIS
          value: "azure-vote-back"
---
apiVersion: v1
kind: Service
metadata:
  name: azure-vote-front
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: azure-vote-front

输出: