【问题标题】:How to install Helm 3 Chart on Air Gapped System如何在气隙系统上安装 Helm 3 Chart
【发布时间】:2021-02-22 11:48:54
【问题描述】:

我正在尝试在气隙系统上安装舵图。该图表应该从私有 docker 注册表中提取图像并部署到 kubernetes 集群(两者都在气隙系统上)。我的图表通过了 linting,但是当我尝试安装它时,我一直看到错误:

$ helm install my-mongodb . --debug
install.go:172: [debug] Original chart version: ""
install.go:189: [debug] CHART PATH: /opt/helm-charts/my-mongodb

Error: unable to build kubernetes objects from release manifest: the server could not find the requested resource
helm.go:94: [debug] the server could not find the requested resource
unable to build kubernetes objects from release manifest
helm.sh/helm/v3/pkg/action.(*Install).Run
    /home/circleci/helm.sh/helm/pkg/action/install.go:257
main.runInstall
    /home/circleci/helm.sh/helm/cmd/helm/install.go:242
main.newInstallCmd.func2
    /home/circleci/helm.sh/helm/cmd/helm/install.go:120
github.com/spf13/cobra.(*Command).execute
    /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842
github.com/spf13/cobra.(*Command).ExecuteC
    /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950
github.com/spf13/cobra.(*Command).Execute
    /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main
    /home/circleci/helm.sh/helm/cmd/helm/helm.go:93
runtime.main
    /usr/local/go/src/runtime/proc.go:203
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1373

Helm 已安装:

$ helm version
version.BuildInfo{Version:"v3.3.4", GitCommit:"a61ce5633af99708171414353ed49547cf05013d", GitTreeState:"clean", GoVersion:"go1.14.9"}

Kubernetes 也是如此:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-06-06T13:19:52Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"269f928217957e7126dc87e6adfa82242bfe5b1e", GitTreeState:"clean", BuildDate:"2017-06-06T13:19:52Z", GoVersion:"go1.7.6", Compiler:"gc", Platform:"linux/amd64"}

$ kubectl config get-clusters
NAME
dev-cluster

$ kubectl get node -n kube-system
NAME          STATUS    AGE
kube-node01   Ready     14d
kube-node02   Ready     14d
kube01        Ready     14d

这是我的 Helm Chart.yaml:

apiVersion: v2
name: my-mongodb
description: A Helm chart for My MongoDB Kubernetes
type: application
version: 0.1.0
appVersion: 5.0.0-1
annotations:
  category: Database

还有我的 values.yaml

replicaCount: 1

image:
  repository: docker01.dev.local:5000/my-mongodb
  pullPolicy: Always
  pullSecrets: 
     - name: regcred  
     
serviceAccount:
  create: true
  annotations: {}
  name: ""

podAnnotations: {}

podSecurityContext: {}

securityContext: {}

service:
  type: ClusterIP
  port: 80

ingress:
  enabled: false
  annotations: {}
  hosts:
    - host: chart-example.local
      paths: []
  tls: []

resources: {}

autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

affinity: {}

我的 docker 镜像在 docker 容器中成功运行,所以我相当有信心该镜像不是问题。我做错了什么?

编辑:我正在运行 helm install 命令:/opt/helm-charts/my-mongodb 这是 Charts.yaml 文件的位置。文件结构为:

my-mongodb
 - Chart.yaml
 - values.schema.json
 - values.yaml
 - charts
 - templates
   - deployment.yaml
   - _helpers.tpl
   - hpa.yaml
   - ingress.yaml
   - NOTES.txt
   - serviceaccount.yaml
   - service.yaml
   - tests
     - test-connection.yaml

这个图表是使用命令创建的:helm create my-mongodb,然后我编辑了 Charts.yaml、values.yaml 和 deployment.yaml 文件

这也是 deployment.yaml 文件:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "my-mongodb.fullname" . }}
  labels:
    {{- include "my-mongodb.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
{{- end }}
  selector:
    matchLabels:
      {{- include "my-mongodb.selectorLabels" . | nindent 6 }}
  template:
    metadata:
    {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      labels:
        {{- include "my-mongodb.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "my-mongodb.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
            - name: mongoDB
              containerPort: 27017
              protocol: TCP
            - name: mongoDBShardSvr
              containerPort: 27018
              protocol: TCP
            - name: mongoDBConfigSvr
              containerPort: 27019
              protocol: TCP                                         
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}

【问题讨论】:

  • 能否请您在执行helm install 的本地文件树中扩展该问题?
  • @AndreasJägle 我已经编辑了这个问题。我还添加了有关如何创建掌舵图的更多详细信息

标签: kubernetes kubernetes-helm


【解决方案1】:

这可能是版本兼容性问题。 Helm v3.3.x 与 Kubernetes v1.5.2 不兼容。

根据Supported Version Skew

当 Helm 的新版本发布时,它会针对 Kubernetes 的特定次要版本。例如,Helm 3.0.0 使用 Kubernetes 1.16.2 客户端与 Kubernetes 交互,所以它是 与 Kubernetes 1.16 兼容。

|---------------------|--------------------------------------|
|      Helm Version   |     Supported Kubernetes Versions    |
|---------------------|--------------------------------------|
|         3.4.x       |           1.19.x - 1.16.x            |
|         3.3.x       |           1.18.x - 1.15.x            |
|         3.2.x       |           1.18.x - 1.15.x            |
|---------------------|--------------------------------------|

不仅如此,您还在为您的部署版本使用apiVersion: apps/v1。此 API 版本是在 Kubernetes v1.9.0 上引入的。

【讨论】:

    猜你喜欢
    • 2021-04-29
    • 1970-01-01
    • 1970-01-01
    • 2020-12-04
    • 1970-01-01
    • 2020-06-02
    • 2020-03-18
    • 2022-08-18
    • 2020-01-24
    相关资源
    最近更新 更多