Let us deploy metrics-server to monitor the PODs and Nodes. Pull the git repository for the deployment files. https://github.com/kodekloudhub/kubernetes-metrics-server.git
-master $ git clone https://github.com/kodekloudhub/kubernetes-metrics-server.git
Cloning into 'kubernetes-metrics-server'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 15 (delta 0), reused 0 (delta 0), pack-reused 12
Unpacking objects: 100% (15/15), done.
master $
master $
master $ ls -ltr
total 8
drwxr-xr-x 4 root root 4096 Jul 8 08:30 go
drwxr-xr-x 3 root root 4096 Sep 25 02:36 kubernetes-metrics-server
Deploy the metrics-server by creating all the components downloaded. Run the 'kubectl create -f .' command from within the downloaded repository.
master $ cd kubernetes-metrics-server/
master $ ls -ltr
total 32
-rw-r--r-- 1 root root 612 Sep 25 02:36 resource-reader.yaml
-rw-r--r-- 1 root root 219 Sep 25 02:36 README.md
-rw-r--r-- 1 root root 249 Sep 25 02:36 metrics-server-service.yaml
-rw-r--r-- 1 root root 976 Sep 25 02:36 metrics-server-deployment.yaml
-rw-r--r-- 1 root root 298 Sep 25 02:36 metrics-apiservice.yaml
-rw-r--r-- 1 root root 329 Sep 25 02:36 auth-reader.yaml
-rw-r--r-- 1 root root 308 Sep 25 02:36 auth-delegator.yaml
-rw-r--r-- 1 root root 384 Sep 25 02:36 aggregated-metrics-reader.yaml
master $ kubectl create -f resource-reader.yaml
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
master $ kubectl create -f metrics-server-service.yaml
service/metrics-server created
master $ kubectl create -f metrics-server-deployment.yaml
serviceaccount/metrics-server created
deployment.apps/metrics-server created
master $ kubectl create -f metrics-apiservice.yaml
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created
master $ kubectl create -f auth-reader.yaml
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
master $ kubectl create -f auth-delegator.yaml
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
master $ kubectl create -f aggregated-metrics-reader.yaml
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
Instead of going over each individual and executing kubectl create -f <filename>, kubectl create -f . within the directory works as well !
It takes a few minutes for the metrics server to start gathering data.
Run the 'kubectl top node' command and wait for a valid output.
master $ kubectl top node
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
master 109m 5% 938Mi 49%
node01 2000m 100% 563Mi 14%
Identify the node that consumes the most CPU.
-- From the above command itself, the answer is node01.
Identify the node that consumes the most Memory.
-- From the above command, (kubectl top node), the answer is master.
Identify the POD that consumes the most Memory.
master $ kubectl top pod
NAME CPU(cores) MEMORY(bytes)
elephant 13m 50Mi
lion 956m 1Mi
rabbit 976m 1Mi
--- The answer is elephant
Identify the POD that consumes the most CPU.
--The answer is rabbit
No comments:
Post a Comment