代码之家  ›  专栏  ›  技术社区  ›  rockyroad

在升级前的hook-in-helm中传递参数

  •  0
  • rockyroad  · 技术社区  · 7 年前

    apiVersion: batch/v1
    kind: Job
    metadata:
      name: "{{.Release.Name}}-preupgrade"
      labels:
        heritage: {{.Release.Service | quote }}
        release: {{.Release.Name | quote }}
        chart: "{{.Chart.Name}}-{{.Chart.Version}}"
      annotations:
        # This is what defines this resource as a hook. Without this line, the
        # job is considered part of the release.
        "helm.sh/hook": pre-upgrade
        "helm.sh/hook-weight": "0"
        "helm.sh/hook-delete-policy": hook-succeeded
    spec:
      template:
        metadata:
          name: "{{.Release.Name}}"
          labels:
            heritage: {{.Release.Service | quote }}
            release: {{.Release.Name | quote }}
            chart: "{{.Chart.Name}}-{{.Chart.Version}}"
        spec:
          restartPolicy: Never
          securityContext:
    #       Because we are running as non root user and group id/User id of the flink user is 1000/1000.
            fsGroup: {{ .Values.spec.securityContext.fsGroup }}
            runAsNonRoot: {{ .Values.spec.securityContext.runAsNonRootFlag }}
            runAsUser: {{ .Values.spec.securityContext.runAsUser }}
          containers:
          - name: pre-upgrade-job
            image: {{ .Values.registry }}/{{ .Values.imageRepo }}:{{ .Values.imageTag }}
            imagePullPolicy: {{ .Values.imagePullPolicy }}
    # Got error /bin/sleep: invalid time interval 'lcm_hook'
            args:
            - lcm_hook
            env:
    #       Need to add this env variable so that the custom flink conf values will be written to $FLINK_HOME/conf.
    #       This is needed for the hook scripts to connect to the Flink JobManager
            - name: FLINK_KUBE_CONFIGMAP_PATH
              value: {{ .Values.spec.config.mountPath }}
            volumeMounts:
            - name: {{ template "fullname" . }}-flink-config
              mountPath: {{ .Values.spec.config.mountPath }}
            - mountPath: {{ .Values.pvc.shared_storage_path }}/{{ template "fullname" . }}
              name: shared-pvc
            command: ["/bin/sh", "-c", "scripts/preUpgradeScript.sh","{{ .Values.pvc.shared_storage_path }}/{{ template "fullname" . }}"]
            command: ["/bin/sleep","10"]
          volumes:
            - name: {{ template "fullname" . }}-flink-config
              configMap:
                name: {{ template "fullname" . }}-flink-config
            - name: shared-pvc
              persistentVolumeClaim:
                claimName: {{ template "fullname" . }}-shared-pv-claim
    

    在这里,我需要将一个名为“lcm-hooks”的参数传递给我的docker容器。但是当我这样做时,这个参数似乎覆盖了我的第二个命令[“/bin/sleep”,“10”]的参数,我得到一个错误

    在升级阶段。什么是正确的方法来确保我能够将一个参数传递给我的容器,以及完全不同于头盔挂钩中bash命令的参数?

    1 回复  |  直到 7 年前
        1
  •  2
  •   itaysk    7 年前

    你的钩子有一个容器 lcm_hooks pre-upgrade-job

    我需要把一个论点传给我的码头集装箱

    command args 因此图像的原始 entrypoint cmd 从山药和覆盖

    我建议您查看容器规范和helm hooks文档,这些文档可能会澄清: