Pod و Image Security
الأمان يبدأ قبل Kubernetes
Section titled “الأمان يبدأ قبل Kubernetes”لو Image نفسها خطرة أو مليئة بثغرات، Kubernetes لن يحل المشكلة وحده. يجب الاهتمام بـ:
- اختيار Base image صغيرة وموثوقة.
- تثبيت أقل عدد ممكن من packages.
- عدم وضع secrets داخل Image.
- فحص الثغرات.
- توقيع Images عند الحاجة.
تشغيل Container بدون root
Section titled “تشغيل Container بدون root”securityContext: runAsNonRoot: true runAsUser: 10001 allowPrivilegeEscalation: falseمنع صلاحيات خطيرة
Section titled “منع صلاحيات خطيرة”securityContext: capabilities: drop: - ALL readOnlyRootFilesystem: truePod Security Standards
Section titled “Pod Security Standards”Kubernetes يصف مستويات أمان للـ Pods:
- Privileged.
- Baseline.
- Restricted.
في Production حاول الاقتراب من Restricted قدر الإمكان.
Admission Controls
Section titled “Admission Controls”Admission Controller يفحص الطلب قبل قبوله في Kubernetes. يمكن استخدامه لمنع Pods خطرة، مثل Pod يعمل privileged بدون سبب.
أدوات شائعة في هذا المجال:
- Kyverno.
- OPA Gatekeeper.
- السياسات المدمجة مثل Pod Security Admission.
Lab: تشغيل Pod بدون root
الهدف: إضافة securityContext إلى Deployment واختبار تشغيله.
أضف securityContext إلى Deployment، ثم نفذ:
kubectl apply -f deployment.yamlkubectl describe pod -l app=webkubectl exec deploy/web -- idمعيار الإتقان
Section titled “معيار الإتقان”تكون فاهم هذا الدرس عندما تستطيع النظر إلى Pod YAML وتحدد 3 مخاطر أمنية محتملة.