Community Tutorials Kubernetes كيفية نشر أول Pod في Kubernetes
كيفية نشر أول Pod في Kubernetes
KUBERNETES

كيفية نشر أول Pod في Kubernetes

SKYLINE Knowledge Base
Photo by Growtika on Unsplash

دليل عملي خطوة بخطوة لـ كيفية نشر أول Pod في Kubernetes. أوامر مختبرة في الإنتاج، متطلبات مسبقة، تحقق نهائي وروابط لمواضيع ذات صلة.

Pod هو الوحدة الذرية في Kubernetes — حاوية أو أكثر تتشارك namespace الشبكة والتخزين. نادرًا ما تنشر Pod مجردًا في الإنتاج، لكن فهمه الأساس.

المتطلبات المسبقة

  • عنقود يعمل — k3s.
  • kubectl مكوّن.

الخطوة 1: الأمر الأمر — شغّل شيئًا

kubectl run nginx --image=nginx:1.27-alpine --restart=Never
kubectl get pods
kubectl get pod nginx -o wide
kubectl wait --for=condition=Ready pod/nginx --timeout=60s

الخطوة 2: تصريحي — اكتب YAML

pod.yaml:

apiVersion: v1
kind: Pod
metadata:
  name: web
  labels:
    app: web
spec:
  containers:
    - name: nginx
      image: nginx:1.27-alpine
      ports:
        - containerPort: 80
      resources:
        requests: { cpu: 50m, memory: 64Mi }
        limits:   { cpu: 200m, memory: 128Mi }
      readinessProbe:
        httpGet: { path: /, port: 80 }
        initialDelaySeconds: 2
        periodSeconds: 5
      livenessProbe:
        httpGet: { path: /, port: 80 }
        initialDelaySeconds: 10
        periodSeconds: 10
kubectl apply -f pod.yaml
kubectl describe pod web | tail -20

الخطوة 3: الوصول إلى Pod

kubectl port-forward pod/web 8080:80 &
curl http://localhost:8080/
kubectl exec -it web -- sh
kubectl logs web -f

الخطوة 4: Init Containers و Sidecars

spec:
  initContainers:
    - name: wait-for-db
      image: busybox:1.36
      command: ['sh', '-c', 'until nc -z db 5432; do sleep 2; done']
  containers:
    - name: app
      image: skyline/api:1.0
    - name: log-shipper
      image: skyline/log-shipper:1.0

الخطوة 5: دورة الحياة و restartPolicy

ثلاث قيم: Always، OnFailure، Never.

kubectl get pods -w

الخطوة 6: الحذف

kubectl delete pod web
kubectl delete -f pod.yaml

التحقق

kubectl get pods
kubectl get events --sort-by=.lastTimestamp | tail -20
kubectl top pod

الخاتمة

Pod هو أصغر وحدة تنشرها. معرفة كتابته وقراءة أحداثه وسجلاته أساس Deployments و StatefulSets.

الخطوات التالية

SKYLINE Engineering

@skyline

The engineering team at SKYLINE Industrial Solutions. We publish field-tested guides drawn from real KSA and GCC deployments.

See author profile
SKYLINE engineering services

Need this implemented for you?

Reading is free — building it right takes a team. SKYLINE engineers ship Kubernetes for Aramco vendors, banks, hospitals and government agencies across Saudi Arabia. Talk to us before you start.

Aramco Approved Contractor ISO 9001 · ISO 27001 SAMA CSF aligned NCA ECC ready 247+ KSA clients

Comments

0 total · 0 threads
Be the first to leave a comment.