Our course you can check :- Udemy course
Que:-
The DevOps team has noticed performance issues in some Kubernetes-hosted applications due to resource constraints. To address this, they plan to set limits on resource utilization. Here are the details:
Create a pod named httpd-pod with a container named httpd-container. Use the httpd image with the latest tag (specify as httpd:latest). Set the following resource limits:
Requests: Memory: 15Mi, CPU: 100m
Limits: Memory: 20Mi, CPU: 100m
Ans:-
thor@jumphost ~$ cat pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: httpd-pod
labels:
app: httpd
spec:
containers:
- name: httpd-container
image: httpd:latest
resources:
requests:
memory: "15Mi"
cpu: "100m"
limits:
memory: "20Mi"
cpu: "100m"
ports:
- containerPort: 80
thor@jumphost ~$
thor@jumphost ~$ kubectl apply -f pod.yaml
pod/httpd-pod created
thor@jumphost ~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
httpd-pod 1/1 Running 0 12s
thor@jumphost ~$ kubectl describe pod httpd-pod
Name: httpd-pod
Namespace: default
Priority: 0
Service Account: default
Node: kodekloud-control-plane/172.17.0.2
Start Time: Fri, 03 Oct 2025 07:00:16 +0000
Labels: app=httpd
Annotations: <none>
Status: Running
IP: 10.244.0.5
IPs:
IP: 10.244.0.5
Containers:
httpd-container:
Container ID: containerd://bbd80ea55fe8cd5b9f3ac74b9cb10a368c1a0a1e33a06192268c6d2bcf58c39e
Image: httpd:latest
Image ID: docker.io/library/httpd@sha256:ca375ab8ef2cb8bede6b1bb97a943cce7f0a304d5459c05235b47bc2dccb98cd
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 03 Oct 2025 07:00:22 +0000
Ready: True
Restart Count: 0
Limits:
cpu: 100m
memory: 20Mi
Requests:
cpu: 100m
memory: 15Mi
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-jrm74 (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-jrm74:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 99s default-scheduler Successfully assigned default/httpd-pod to kodekloud-control-plane
Normal Pulling 98s kubelet Pulling image "httpd:latest"
Normal Pulled 93s kubelet Successfully pulled image "httpd:latest" in 5.133084161s (5.1331417s including waiting)
Normal Created 93s kubelet Created container httpd-container
Normal Started 93s kubelet Started container httpd-container
thor@jumphost ~$
No comments:
Post a Comment