1

运行命令时:helm install singer --dry-run packages/helm-chart/charts/csm-im在下图中,args根本没有设置。为什么?

值.yaml:

spec:
  template:
    spec:
      containers:
        - args:
          - node
          - -r
          - ./.pnp.cjs
          - packages/csm-im/dist/src/index.js 

模板/statefulset.yaml:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  annotations:
    meta.helm.sh/release-name: {{ .Release.Name }}
    meta.helm.sh/release-namespace: {{ .Release.Namespace }}
    field.cattle.io/publicEndpoints: '[{"addresses":[""],"port":443,"protocol":"HTTPS","serviceName":"default:csm-im","ingressName":"default:singer-csm-im","hostname":"singer-csm-im.octopol.io","path":"/","allNodes":false}]'
  labels:
    app.kubernetes.io/managed-by: Helm
    cattle.io/creator: norman
    workload.user.cattle.io/workloadselector: statefulSet-default-csm-im
  name: csm-im
  namespace: {{ .Release.Namespace }}
spec:
  podManagementPolicy: OrderedReady
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      workload.user.cattle.io/workloadselector: statefulSet-default-csm-im
  serviceName: csm-im
  template:
    metadata:
      annotations:
        field.cattle.io/ports: '[[{"containerPort":8080,"dnsName":"csm-im","hostPort":0,"kind":"ClusterIP","name":"tcpport01","protocol":"TCP","sourcePort":0}]]'
      labels:
        workload.user.cattle.io/workloadselector: statefulSet-default-csm-im
    spec:
      containers:
        - env:
            - name: RESEARCH_ENABLE_CALL
              value: 'false'
          image: image1
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 20
            periodSeconds: 2
            successThreshold: 1
            timeoutSeconds: 2
          name: csm-im
          ports:
            - containerPort: 8080
              name: tcpport01
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /readiness
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 2
            successThreshold: 2
            timeoutSeconds: 2
          resources: {}
          securityContext:
            allowPrivilegeEscalation: false
            capabilities: {}
            privileged: false
            readOnlyRootFilesystem: false
            runAsNonRoot: false
          stdin: true
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          tty: true
      dnsPolicy: ClusterFirst
      imagePullSecrets:
        - name: octopol-dockerhub-credentials
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
  updateStrategy:
    rollingUpdate:
      partition: 0
    type: RollingUpdate

4

1 回答 1

0

要将值添加到模板中,values.yaml您需要为模板中的值留出空间。要添加baz的示例

foo:
  bar: baz

在模板中,您需要添加

{{ .Values.foo.bar }}

由于您的模板中已经有容器清单,您可以添加

{{ .Values.spec.template.containers.args }}

由于这是一个列表,因此您必须使用{{ range }}

{{ range .Values.spec.template.containers.args }}

所以,像

...
spec:
      containers:
        - env:
            - name: RESEARCH_ENABLE_CALL
              value: 'false'
          image: image1
          imagePullPolicy: Always
        - args: {{ range .Values.spec.template.containers.args | nindent 10 }}
...

nindent 10添加带有前导换行符的缩进。

于 2021-10-28T10:49:46.993 回答