Rollouts و Probes و Resources
Rollout
Section titled “Rollout”Rollout هو عملية تحديث Deployment من إصدار إلى إصدار. Kubernetes لا يحذف كل النسخ مرة واحدة. غالبا ينشئ Pods جديدة تدريجيا ويوقف القديمة تدريجيا.
kubectl set image deployment/web nginx=nginx:1.28kubectl rollout status deployment/webkubectl rollout history deployment/webkubectl rollout undo deployment/webاستراتيجية التحديث
Section titled “استراتيجية التحديث”strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1maxUnavailable: أكبر عدد من Pods يمكن أن يكون غير متاح أثناء التحديث.maxSurge: أكبر عدد إضافي من Pods يمكن تشغيله فوق العدد المطلوب أثناء التحديث.
Probes
Section titled “Probes”Probes تخبر Kubernetes عن صحة التطبيق.
| النوع | السؤال الذي يجيب عليه |
|---|---|
startupProbe | هل التطبيق انتهى من البداية؟ |
readinessProbe | هل التطبيق جاهز لاستقبال traffic؟ |
livenessProbe | هل التطبيق ما زال حيا أم يحتاج restart؟ |
مثال Probes
Section titled “مثال Probes”livenessProbe: httpGet: path: / port: 80 initialDelaySeconds: 10 periodSeconds: 10readinessProbe: httpGet: path: / port: 80 initialDelaySeconds: 5 periodSeconds: 5Requests و Limits
Section titled “Requests و Limits”resources: requests: cpu: "100m" memory: "128Mi" limits: cpu: "500m" memory: "256Mi"requests: الموارد التي يحتاجها Pod حتى يختار scheduler مكانه.limits: الحد الأقصى المسموح به.
Lab: Deployment قابل للتحديث
الهدف: إضافة probes و resources ثم تنفيذ rollout.
أضف readinessProbe و livenessProbe و resources إلى Deployment من درس Deployments، ثم نفذ:
kubectl apply -f deployment.yamlkubectl rollout status deployment/webkubectl describe deployment web