Record Kubernetes container resource utilization data Record Kubernetes container resource utilization data kubernetes kubernetes

Record Kubernetes container resource utilization data


In line with @Jonas comment

This is the quickest way of installing Prometheus in you K8 cluster. Added Details in the answer as it was impossible to put the commands in a readable format in Comment.

  1. Add bitnami helm repo.
helm repo add bitnami https://charts.bitnami.com/bitnami
  1. Install helmchart for promethus
helm install my-release bitnami/kube-prometheus

Installation output would be:

C:\Users\ameena\Desktop\shine\Article\K8\promethus>helm install my-release bitnami/kube-prometheusNAME: my-releaseLAST DEPLOYED: Mon Apr 12 12:44:13 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1TEST SUITE: NoneNOTES:** Please be patient while the chart is being deployed **Watch the Prometheus Operator Deployment status using the command:    kubectl get deploy -w --namespace default -l app.kubernetes.io/name=kube-prometheus-operator,app.kubernetes.io/instance=my-releaseWatch the Prometheus StatefulSet status using the command:    kubectl get sts -w --namespace default -l app.kubernetes.io/name=kube-prometheus-prometheus,app.kubernetes.io/instance=my-releasePrometheus can be accessed via port "9090" on the following DNS name from within your cluster:    my-release-kube-prometheus-prometheus.default.svc.cluster.localTo access Prometheus from outside the cluster execute the following commands:    echo "Prometheus URL: http://127.0.0.1:9090/"    kubectl port-forward --namespace default svc/my-release-kube-prometheus-prometheus 9090:9090Watch the Alertmanager StatefulSet status using the command:    kubectl get sts -w --namespace default -l app.kubernetes.io/name=kube-prometheus-alertmanager,app.kubernetes.io/instance=my-releaseAlertmanager can be accessed via port "9093" on the following DNS name from within your cluster:    my-release-kube-prometheus-alertmanager.default.svc.cluster.localTo access Alertmanager from outside the cluster execute the following commands:    echo "Alertmanager URL: http://127.0.0.1:9093/"    kubectl port-forward --namespace default svc/my-release-kube-prometheus-alertmanager 9093:9093
  1. Follow the commands to forward the UI to localhost.
echo "Prometheus URL: http://127.0.0.1:9090/"    kubectl port-forward --namespace default svc/my-release-kube-prometheus-prometheus 9090:9090
  1. Open the UI in browser: http://127.0.0.1:9090/classic/graph

  2. Annotate the pods for sending the metrics.

apiVersion: apps/v1kind: Deploymentmetadata:  name: nginx-deploymentspec:  selector:    matchLabels:      app: nginx  replicas: 4 # Update the replicas from 2 to 4  template:    metadata:      labels:        app: nginx      annotations:        prometheus.io/scrape: 'true'        prometheus.io/port: '9102'    spec:      containers:      - name: nginx        image: nginx:1.14.2        ports:        - containerPort: 80
  1. In the ui put appropriate filters and start observing the crucial parameter such as memory CPU etc. UI supports autocomplete so it will not be that difficult to figure out things.

Regards