Saturday, 11 October 2025

Deploy Grafana on Kubernetes: Monitor Your Apps with Ease

Our course you can check :-   Udemy course 


Ques:-      

DevOps teams is planning to set up a Grafana tool to collect and analyze analytics from some applications. They are planning to deploy it on Kubernetes cluster. Below you can find more details.

1.) Create a deployment named grafana-deployment-devops using any grafana image for Grafana app. Set other parameters as per your choice.

2.) Create NodePort type service with nodePort 32000 to expose the app.

You need not to make any configuration changes inside the Grafana app once deployed, just make sure you are able to access the Grafana login page.

Ans:-

Here’s how you can deploy Grafana on a Kubernetes cluster using a Deployment and a NodePort Service, as per your requirements:

raj@jumphost ~$ cat pod.yaml 

---

apiVersion: apps/v1

kind: Deployment

metadata:

  name: grafana-deployment-devops

  labels:

    app: grafana

spec:

  replicas: 1

  selector:

    matchLabels:

      app: grafana

  template:

    metadata:

      labels:

        app: grafana

    spec:

      containers:

        - name: grafana

          image: grafana/grafana:latest

          ports:

            - containerPort: 3000


---

apiVersion: v1

kind: Service

metadata:

  name: grafana-service

spec:

  type: NodePort

  selector:

    app: grafana

  ports:

    - port: 3000

      targetPort: 3000

      nodePort: 32000


raj@jumphost ~$ kubectl apply -f pod.yaml 

deployment.apps/grafana-deployment-devops created

service/grafana-service created


raj@jumphost ~$ kubectl get all

NAME                                            READY   STATUS              RESTARTS   AGE

pod/grafana-deployment-devops-77648df4c-nmc8j   0/1     ContainerCreating   0          12s


NAME                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE

service/grafana-service   NodePort    10.96.249.159   <none>        3000:32000/TCP   13s

service/kubernetes        ClusterIP   10.96.0.1       <none>        443/TCP          20m


NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE

deployment.apps/grafana-deployment-devops   0/1     1            0           13s


NAME                                                  DESIRED   CURRENT   READY   AGE

replicaset.apps/grafana-deployment-devops-77648df4c   1         1         0       13s

raj@jumphost ~$ 


You should see grafana-service with NodePort 32000.

Open your browser and go to:

http://<NodeIP>:32000

Replace <NodeIP> with your Kubernetes node’s external IP.

No comments:

Post a Comment