⏱️3 min read · 595 words
Helm هو مدير الحزم في Kubernetes. في عام 2026، فإن Helm 3 مع دعم OCI وخطافات دورة الحياة المحسنة ومستودع ArtifactHub الضخم يجعلها الطريقة القياسية لتثبيت تطبيقات Kubernetes وترقيتها وإدارتها. يأخذك هذا الدليل من المخطط الأول إلى عمليات نشر Helm على مستوى الإنتاج.
📋 Table of Contents
لماذا هيلم؟
- إدارة الحزمة— تثبيت التطبيقات المعقدة (PostgreSQL، وRedis، وPrometheus) بأمر واحد
- قوالب– إعادة استخدام بيانات Kubernetes عبر البيئات ذات المتغيرات
- إدارة الإصدار— العودة إلى أي إصدار سابق على الفور
- إدارة التبعية– الإعلان عن تبعيات الرسم البياني وإدارتها
- ArtifactHub– أكثر من 10000 مخطط مجتمعي للتطبيقات الشائعة
تثبيت
# macOS
brew install helm
# Linux
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
# Verify
helm version
# Add popular repositories
helm repo add stable https://charts.helm.sh/stable
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
تثبيت المخططات
# Search for charts
helm search repo postgres
helm search hub nginx
# Install PostgreSQL
helm install my-postgres bitnami/postgresql --namespace database --create-namespace --set auth.postgresPassword=secretpassword --set primary.persistence.size=20Gi
# Install with custom values file
helm install my-app ./my-chart -f values.prod.yaml
# Check release status
helm list -n database
helm status my-postgres -n database
# Get notes after install
helm get notes my-postgres -n database
# Upgrade release
helm upgrade my-postgres bitnami/postgresql --namespace database --set auth.postgresPassword=newpassword
# Rollback
helm rollback my-postgres 1 # rollback to revision 1
# Uninstall
helm uninstall my-postgres -n database
إنشاء المخطط الأول الخاص بك
# Scaffold a new chart
helm create myapp
# Structure:
# myapp/
# Chart.yaml - chart metadata
# values.yaml - default values
# templates/ - Kubernetes manifests (templated)
# deployment.yaml
# service.yaml
# ingress.yaml
# _helpers.tpl - template helpers
# NOTES.txt - post-install notes
# charts/ - dependency charts
# .helmignore
Chart.yaml
apiVersion: v2
name: myapp
description: My production application
type: application
version: 0.1.0 # chart version (semver)
appVersion: "1.2.3" # app version
dependencies:
- name: postgresql
version: "13.x.x"
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: redis
version: "17.x.x"
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
value.yaml — التكوين
replicaCount: 2
image:
repository: mycompany/myapp
tag: "1.2.3"
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 8000
ingress:
enabled: true
className: nginx
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
hosts:
- host: myapp.example.com
paths:
- path: /
pathType: Prefix
tls:
- secretName: myapp-tls
hosts:
- myapp.example.com
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 128Mi
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70
postgresql:
enabled: true
auth:
database: myapp_db
existingSecret: myapp-db-secret
redis:
enabled: true
architecture: standalone
أمثلة القالب
# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "myapp.fullname" . }}
labels:
{{- include "myapp.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "myapp.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "myapp.selectorLabels" . | nindent 8 }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.port }}
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: myapp-db-secret
key: database-url
- name: APP_VERSION
value: {{ .Chart.AppVersion | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
livenessProbe:
httpGet:
path: /health
port: {{ .Values.service.port }}
initialDelaySeconds: 30
periodSeconds: 10
بيئات متعددة
# values.dev.yaml — development overrides
# helm install myapp ./myapp -f values.yaml -f values.dev.yaml
# values.prod.yaml — production overrides
# helm install myapp ./myapp -f values.yaml -f values.prod.yaml
# values.prod.yaml
replicaCount: 5
image:
tag: "1.2.3-stable"
resources:
limits:
cpu: 2000m
memory: 2Gi
requests:
cpu: 500m
memory: 512Mi
autoscaling:
enabled: true
minReplicas: 5
maxReplicas: 50
خوذة في CI/CD
# .github/workflows/deploy.yml
- name: Deploy with Helm
run: |
helm upgrade --install myapp ./charts/myapp --namespace production --create-namespace --set image.tag=${{ github.sha }} --set image.repository=ghcr.io/${{ github.repository }} -f values.prod.yaml --wait --timeout 10m --atomic # rollback automatically on failure
أوامر خوذة مفيدة
# Lint chart before install
helm lint ./myapp
# Render templates without installing
helm template myapp ./myapp -f values.prod.yaml
# Diff current vs proposed changes
helm plugin install https://github.com/databus23/helm-diff
helm diff upgrade myapp ./myapp -f values.prod.yaml
# Show all values (defaults + overrides)
helm get values myapp -n production --all
# History
helm history myapp -n production
يعد Helm في 2026 ضروريًا لأي نشر لـ Kubernetes يتجاوز أعباء العمل التجريبية البسيطة. ابدأ بتثبيت مخططات المجتمع للتبعيات (PostgreSQL، وRedis، وPrometheus)، ثم قم بإنشاء مخططاتك الخاصة لعمليات نشر التطبيقات. يجعل نظام القوالب إدارة بيئات متعددة نظيفة وقابلة للتكرار.
🔗 Share this article
✍️ Leave a Comment