首页 > 解决方案 > 无法在 minikube 中部署 helm chart

问题描述

我有一个舵图,我在其中部署了 kong 服务。如果我在 EKS (Aws) 中使用远程 kubernetes 集群,则此部署有效。现在我正在部署一个具有相同 K8s 版本的 minikube 集群,但是当我尝试安装 helm chart 时出现下一个错误。

minikube version -> minikube version: v1.19.0

Kubectl version -> Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.12", GitCommit:"7cd5e9086de8ae25d6a1514d0c87bac67ca4a481", GitTreeState:"clean", BuildDate:"2020-11-12T09:18:55Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

helm version: version.BuildInfo{Version:"v3.4.2", GitCommit:"23dd3af5e19a02d4f4baa5b2f242645a1a3af629", GitTreeState:"clean", GoVersion:"go1.14.13"}

错误:无法从发布清单构建 kubernetes 对象:错误验证“”:错误验证数据:未设置 apiVersion

我的 chart.yml 是这样的:

apiversion: v2
name: kong
description: A Helm chart for Kubernetes

type: application
version: 0.1.0

我的 deployment.yaml 是:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}-deployment
  namespace: {{ .Release.Namespace }}
spec:
  replicas: {{ .Values.replicaCount }}
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}
    spec:
      initContainers:
      - name: init-kong
        image: "{{ .Values.image.repository }}{{ .Values.global_version }}"
        command: [ 'kong', 'migrations', 'bootstrap']
        envFrom:
        - configMapRef:
            name: {{ .Release.Name }}-env
      containers:
      - image: "{{ .Values.image.repository }}{{ .Values.global_version }}"
        envFrom:
        - configMapRef:
            name: {{ .Release.Name }}-env
        livenessProbe:
          exec:
            command:
            - kong
            - health
          failureThreshold: 3
          periodSeconds: 90
          timeoutSeconds: 10
        name: {{ .Release.Name }}-pod
        ports:
        - containerPort: 9800
        - containerPort: 9801
      restartPolicy: Always
      volumes:
      - name: {{ .Release.Name }}-configmap
        configMap:
          name: {{ .Release.Name }}-configmap
      nodeSelector:    
        eks.amazonaws.com/nodegroup: "{{ .Values.postgres.WORKER_NODE }}"

我用来安装 helm chart 的命令是(我试图在 chart 目录中执行它,结果相同):

helm install kong kong

标签: dockerkuberneteskubernetes-helmminikube

解决方案


嗯,错误信息很清楚:

错误:无法从发布清单构建 kubernetes 对象:错误验证“”:错误验证数据:未设置 apiVersion

问题是apiVersion您的模板中的 是apiversion,请记住所有 k8s yaml 模板键都应该是驼峰式的:

权利应该是:

apiVersion: v2
name: kong
description: A Helm chart for Kubernetes

type: application
version: 0.1.0

推荐阅读