How to refer to the value defined in the template in the subgraph in the steering wheel for the cockernets?

I am starting to write steering charts for our services.

There are two things that I don’t know how they should work or what to do with them.

First: release name. When you install the chart, you specify the name that helm uses to create the release. Is this release name often referenced in the chart to properly isolate the chart settings from each other? For example, a postgres diagram contains:

{{- define "postgresql.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

Which is then used for the service:

metadata:
  name: {{ template "postgresql.fullname" . }}

After all, in kubernetes it looks like "myrelease-postgresql". I wonder what a good release name is? What is commonly used for this? Version? Or some codename like Ubuntu releases?

Second: value references.

postgresql -. postgresql (. ).

, {{template "postgresql.fullname". }} ? ( , , ).

:

      env:
        - name: DB_HOST
          value: {{ template "mychart.postgresql.fullname" . }}

:

template "mychart.postgresql.fullname" not defined

, , , odoo. postgresql .

? ?

!

: Subcharts Globals .

:

_helpers.tpl () postgres:

{{- define "postgresql.fullname" -}}
{{- $name := .Values.global.name -}}
{{- printf "%s-%s" $name "postgresql" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

, . , - - .

, , .

, : -/

+19
2

postgresql ( requirements.yaml)? , postgresql () , .Release.Name - ,

  env:
    - name: DB_HOST
      value: {{ printf "%s-postgresql" .Release.Name }}

postgresql, : values.yaml:

postgresql:
  nameOverride: your-postgresql

env :

  env:
    - name: DB_HOST
      value: {{ printf "%s-%s" .Release.Name .Values.postgresql.nameOverride }}
+4

, : https://github.com/kubernetes/helm/blob/master/docs/chart_template_guide/subcharts_and_globals.md

, ( ), .

, .Values ​​ , , - . , , , {{ template "name" . }}, - {{ .Values.database.service.name }}

mychart/.Values ​​

mysubchart:
   service:
      name: my-database

mychart//deployment.yaml

env:
   - name: DB_HOST
     value: {{ .Values.mysubchart.service.name }}

mychart//mysubchart/.Values ​​

service:
   name: my-database

mychart//mysubchart//service.yaml:

apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.service.name }}

- , https://github.com/kubernetes/helm/blob/master/docs/chart_template_guide/subcharts_and_globals.md

+1

Source: https://habr.com/ru/post/1690443/


All Articles