error: unable to recognize “heapster-deployment.yaml“: no matches for kind “Deployment“ in version “

解决:

error: unable to recognize “heapster-deployment.yaml“: no matches for kind “Deployment“ in version “

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:

修改如下:

---
apiVersion: apps/v1
kind: Deployment

error: error validating "heapster-deployment.yaml": error validating data: 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
 

原文件:


apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: heapster
  namespace: kube-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        task: monitoring
        k8s-app: heapster
    spec:
      serviceAccountName: heapster
      containers:
      - name: heapster
        image: harbor.od.com/k8s/heapster:v1.5.4
        imagePullPolicy: IfNotPresent
        command:
        - /opt/bitnami/heapster/bin/heapster
        - --source=kubernetes:https://kubernetes.default

修改后:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: heapster
  namespace: kube-system
spec:
  replicas: 3
  selector:
   matchLabels:
     app: heapster-deployment

  template:
    metadata:
      labels:
        app: heapster-deployment

    spec:
      serviceAccountName: heapster
      containers:
      - name: heapster
        image: harbor.od.com/k8s/heapster:v1.5.4
        imagePullPolicy: IfNotPresent
        command:
        - /opt/bitnami/heapster/bin/heapster
        - --source=kubernetes:https://kubernetes.default

#重新创建即可

 kubectl apply -f .

你可能感兴趣的:(k8s学习报错)