Helm


اصلاح Helm Chart🔗

برای دیپلوی سرویسی، Helm Chartی نوشته شده است که به واسطه‌ی Image های تعریف شده در values.yml اقدام به اجرای Container های یک Pod می کند.

# deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: "{{ .Release.Name }}-deployment"
  labels:
    app: "{{ .Release.Name }}"
spec:
  replicas: 3
  selector:
    matchLabels:
      app: "{{ .Release.Name }}"
  template:
    metadata:
      labels:
        app: "{{ .Release.Name }}"
    spec:
      containers:
        {{ range $image := .Values.images }}
        - name: "{{ .Release.Name }}-{{ $image }}"
          image: "{{ $image }}"
        {{ end }}
Plain text
# values.yml
images:
  - nginx
  - php
Plain text

شرح مسئله🔗

پس از اجرای helm template، خطای زیر رخ می دهد:

$ helm template -n test test ./ --debug
install.go:172: [debug] Original chart version: ""
install.go:189: [debug] CHART PATH: /home/salarmgh/Workspace/quera/helm/test

Error: template: test/templates/deployment.yaml:19:28: executing "test/templates/deployment.yaml" at <.Release.Name>: can't evaluate field Release in type interface {}

helm.go:81: [debug] template: test/templates/deployment.yaml:19:28: executing "test/templates/deployment.yaml" at <.Release.Name>:
can't evaluate field Release in type interface {}
Plain text

با حل مشکل، Deploymentی با یک Pod که متشکل از ۲ کانتینر nginx و php می باشد، باید ساخته شود. بدیهی است که در صورت اضافه کردن image به values.yaml این تعداد افزایش پیدا می کند.

نحوه‌ی ارسال جواب🔗

تغییرات خودتان را بر روی deployment.yaml در محیط تست اعمال کنید و فایل zip شده ارسال نمایید. محتویات فایل zip شده می بایست به صورت زیر می باشد (فایل ها را از لینک انتهای صفحه دریافت نمایید):

.
├── charts
├── Chart.yaml
├── templates
│   ├── deployment.yaml
│   ├── _helpers.tpl
│   └── NOTES.txt
└── values.yaml
Plain text

نکته: از ورژن ۳ Helm استفاده شود.

نکته: فقط deployment.yaml را تغییر بدهید.

دریافت فایل های محیط تست🔗

فایل های مورد نیاز تست از طریق این لینک قابل دسترس می باشد.

ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.