Project 1: Static Nginx Site
تشغيل موقع static بسيط باستخدام Nginx، مع Deployment بثلاث نسخ، Service داخلي، resources، وport-forward للاختبار المحلي.
المطلوب
Section titled “المطلوب”Deploymentباسمstatic-site.Serviceباسمstatic-site.replicas: 3.readinessProbe.resources.requestsوresources.limits.
manifest كامل
Section titled “manifest كامل”static-site.yaml:
apiVersion: apps/v1kind: Deploymentmetadata: name: static-site labels: app: static-sitespec: replicas: 3 selector: matchLabels: app: static-site template: metadata: labels: app: static-site spec: containers: - name: nginx image: nginx:1.27 ports: - name: http containerPort: 80 readinessProbe: httpGet: path: / port: http resources: requests: cpu: "100m" memory: "128Mi" limits: cpu: "500m" memory: "256Mi"---apiVersion: v1kind: Servicemetadata: name: static-site labels: app: static-sitespec: type: ClusterIP selector: app: static-site ports: - name: http port: 80 targetPort: httpLab: تشغيل موقع Nginx
الهدف: تطبيق manifest واختبار الموقع محليا.
kubectl apply -f static-site.yamlkubectl rollout status deployment/static-sitekubectl get deploy,pods,svc -l app=static-sitekubectl port-forward svc/static-site 8080:80افتح:
http://127.0.0.1:8080Expected output
Section titled “Expected output”deployment "static-site" successfully rolled outNAME READY STATUSpod/static-site-... 1/1 RunningCleanup
Section titled “Cleanup”kubectl delete -f static-site.yamlAcceptance criteria
Section titled “Acceptance criteria”- كل Pods بحالة
Running. - Service يملك endpoints.
- الموقع يفتح من port-forward.
- تستطيع شرح لماذا لم نستخدم Pod مباشر.