Question : Recently some of the performance issues were observed with some applications hosted on Kubernetes cluster. The Nautilus DevOps team has observed some resources constraints where some of the applications are running out of resources like memory, cpu etc., and some of the applications are consuming more resources than needed. Therefore, the team has decided to add some limits for resources utilization. Below you can find more details.
Create a pod named httpd-pod and a container under it named as httpd-container, use httpd image with latest tag only and remember to mention tag i.e httpd:latest and set the following limits:
Requests: Memory: 15Mi, CPU: 1
Limits: Memory: 20Mi, CPU: 2
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.
Please Note :- Perform the below commands based on your question server, user name & other details might differ . So please read task carefully before executing. All the Best 👍
kubectl get namespace
kubectl get pods
https://gitlab.com/nb-tech-support/devops.git
( Refer Below Video for more clarity )
apiVersion:
v1 kind:
Pod metadata:
name: httpd-pod spec:
containers:
- name: httpd-container
image: httpd:latest
resources:
requests:
memory: "15Mi"
cpu: "1"
limits:
memory: "20Mi"
cpu: "2" |
thor@jump_host /$ kubectl create -f /tmp/limit.yaml pod/httpd-pod created thor@jump_host /$ |
thor@jump_host /$ kubectl get pods NAME READY STATUS
RESTARTS AGE httpd-pod 1/1 Running
0 9s thor@jump_host /$ |
5. Validate the task by running
thor@jump_host /$ kubectl describe pods httpd-pod Name: httpd-pod Namespace: default Priority: 0 Node:
node01/172.17.0.25 Start Time: Mon, 07 Jun 2021
14:49:28 +0000 Labels: <none> Annotations: <none> Status: Running IP: 10.244.2.2 IPs: IP: 10.244.2.2 Containers: httpd-container: Container ID:
docker://111c5345a3140c069c9e8d17c7da90c22f7683c576cced2d96729a6d00d2c9cd Image: httpd:latest Image ID:
docker-pullable://httpd@sha256:48bae0ac5d0d75168f1c1282c0eb21b43302cb1b5c5dc9fa3b4a758ccfb36fe9 Port: <none> Host Port: <none> State: Running Started: Mon, 07 Jun 2021 14:49:34 +0000 Ready: True Restart Count: 0 Limits: cpu: 2 memory: 20Mi Requests: cpu: 1 memory:
15Mi Environment: <none> Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-xh465
(ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: default-token-xh465: Type: Secret (a volume populated by a
Secret) SecretName: default-token-xh465 Optional: false 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
51s default-scheduler Successfully assigned default/httpd-pod to
node01 Normal Pulling
49s kubelet Pulling image "httpd:latest" Normal Pulled
44s kubelet Successfully pulled image "httpd:latest"
in 5.025161084s Normal Created
44s kubelet Created container httpd-container Normal Started
44s kubelet Started container httpd-container thor@jump_host /$ |
Happy Learning!!!!
0 Comments