Kubernetes 创建复制集时出错-未知字段“;“复制品”;在io.k8s.api.apps.v1.ReplicaSet中

Kubernetes 创建复制集时出错-未知字段“;“复制品”;在io.k8s.api.apps.v1.ReplicaSet中,kubernetes,replicaset,kubernetes-pod,Kubernetes,Replicaset,Kubernetes Pod,团队,我正在尝试创建一个副本集,但由于 验证数据时出错: [ValidationError(ReplicaSet):中的未知字段“副本” io.k8s.api.apps.v1.ReplicaSet,ValidationError(ReplicaSet):未知 io.k8s.api.apps.v1.ReplicaSet中的字段“选择器”, ValidationError(ReplicaSet.spec):中缺少必需字段“selector” io.k8s.api.apps.v1.ReplicaSet

团队,我正在尝试创建一个副本集,但由于

验证数据时出错:

[ValidationError(ReplicaSet):中的未知字段“副本” io.k8s.api.apps.v1.ReplicaSet,ValidationError(ReplicaSet):未知 io.k8s.api.apps.v1.ReplicaSet中的字段“选择器”, ValidationError(ReplicaSet.spec):中缺少必需字段“selector” io.k8s.api.apps.v1.ReplicaSetSpec];如果你选择忽略这些 错误,使用--validate=false关闭验证


如果yaml文件中存在缩进问题,则正确的yaml为:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: test-pod-10sec-via-rc1
  labels:
    app: pod-label
spec:
  template:
  metadata:
  name: test-pod-10sec-via-rc1
  labels:
      app: feature-pod-label
  namespace: test-space
spec:
  template:
    spec:
      containers:
      - name: main
        image: ubuntu:latest
        command: ["bash"]
        args: ["-xc", "sleep 10"]
        volumeMounts:
        - name: in-0
          mountPath: /in/0
          readOnly: true
      volumes:
      - name: in-0
        persistentVolumeClaim:
          claimName: 123-123-123
          readOnly: true
      nodeSelector:
       kubernetes.io/hostname: node1
  replicas: 1
  selector:
    matchLabels:
      app: feature-pod-label

我想出来了。我在replicaspost上遗漏了两个右移缩进作为答案
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: test-pod-10sec-via-rc1
  labels:
    app: pod-label
spec:
  template:
  metadata:
  name: test-pod-10sec-via-rc1
  labels:
      app: feature-pod-label
  namespace: test-space
spec:
  template:
    spec:
      containers:
      - name: main
        image: ubuntu:latest
        command: ["bash"]
        args: ["-xc", "sleep 10"]
        volumeMounts:
        - name: in-0
          mountPath: /in/0
          readOnly: true
      volumes:
      - name: in-0
        persistentVolumeClaim:
          claimName: 123-123-123
          readOnly: true
      nodeSelector:
       kubernetes.io/hostname: node1
  replicas: 1
  selector:
    matchLabels:
      app: feature-pod-label