kubernetes报 Deployment in version “v1” cannot be handled as a Deployment:

sandy 发表于: 2019-10-17   最后更新时间: 2019-10-17 23:18:03   6,992 游览

我用Helm安装失败,出现以下错误

安装命令:

helm install --name helloworld helm

一旦我在运行上面的命令,就报错:

Error: release usagemetrics failed: Deployment in version "v1" cannot be handled as a Deployment: v1.Deployment.Spec: v1.DeploymentSpec.Template: v1.PodTemplateSpec.Spec: v1.PodSpec.Containers: []v1.Container: v1.Container.LivenessProbe: readObjectStart: expect { or n, but found 9, error found in #10 byte of ...|ssProbe":9001,"name"|..., bigger context ...|"imagePullPolicy":"IfNotPresent","livenessProbe":9001,"name":"usagemetrics-helm","ports":[{"containe|...

以下是deployment.yaml文件,我感觉liveness和probeness配置存在问题。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: release-name-helm
spec:
  replicas: 1
  selector:
    matchLabels:
      app: release-name-helm
      release: release-name
  template:
    metadata:
      labels:
        app: release-name-helm
        release: release-name
    spec:
      containers:
        - name: release-name-helm
          imagePullPolicy: IfNotPresent
          image: hellworld
          ports:
            - name: "http"
              containerPort: 9001
          envFrom:
            - configMapRef:
                name: release-name-helm
            - secretRef:
                name: release-name-helm
          livenessProbe:
            9001
          readinessProbe:
            9001
发表于 2019-10-17

问题应该跟libvenessProbereadynessProbe都错误有关。

http的livenessProbe的示例是:

livenessProbe

  httpGet:
    path: /healthz
    port: 8080
    httpHeaders:
      - name: Custom-Header
        value: Awesome
    initialDelaySeconds: 3
    periodSeconds: 3

如果你只需要检查port,则yaml应如下所示:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: release-name-helm
spec:
  replicas: 1
  selector:
    matchLabels:
      app: release-name-helm
      release: release-name
  template:
    metadata:
      labels:
        app: release-name-helm
        release: release-name
    spec:
      containers:
        - name: release-name-helm
          imagePullPolicy: IfNotPresent
          image: hellworld
          ports:
            - name: "http"
              containerPort: 9001
          envFrom:
            - configMapRef:
                name: release-name-helm
            - secretRef:
                name: release-name-helm
          livenessProbe:
            tcpSocket:
              port: 9001
            initialDelaySeconds: 5
            periodSeconds: 10
          readinessProbe:
            tcpSocket:
              port: 9001
            initialDelaySeconds: 5
            periodSeconds: 10
你的答案

查看k8s相关的其他问题或提一个您自己的问题