Skip to content

Instantly share code, notes, and snippets.

@EvilFreelancer
Created April 25, 2023 23:17
Show Gist options
  • Select an option

  • Save EvilFreelancer/7f7ea72af839e43c22018112846a3939 to your computer and use it in GitHub Desktop.

Select an option

Save EvilFreelancer/7f7ea72af839e43c22018112846a3939 to your computer and use it in GitHub Desktop.
Использование вложенных шаблонов
# templates/_helpers.tpl
{{- define "my-chart.labels" }}
labels:
app: {{ .Release.Name }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- end }}
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
{{- include "my-chart.labels" . }}
spec:
replicas: {{ .Values.deployment.replicas }}
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
{{- include "my-chart.labels" . }}
spec:
containers:
- name: {{ .Release.Name }}
image: "{{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }}"
ports:
- containerPort: {{ .Values.deployment.containerPort }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment