Deploy Grafana on Kubernetes
The Nautilus DevOps team has successfully deployed the Grafana analytics tool onto the Kubernetes cluster, setting the stage for collecting and analyzing crucial application metrics. This deployment was achieved using standard Kubernetes manifests to create a Deployment and a NodePort Service, making the Grafana dashboard accessible for the team.
Implementation Details: YAML Configuration
The deployment process involved creating two primary configuration files: grafana-deployment-xfusion.yaml
and grafana-service-xfusion.yaml
.
1. Grafana Deployment (grafana-deployment-xfusion.yaml
)
A Deployment named grafana-deployment-xfusion
was created to manage the Grafana application pods, ensuring a persistent and scalable setup. It utilizes the official grafana/grafana:latest
image and exposes the application on its default port, 3000.
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana-deployment-xfusion
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
2. Service Exposure (grafana-service-xfusion.yaml
)
To make the Grafana application accessible from outside the Kubernetes cluster, a NodePort Service named grafana-service-xfusion
was created. It specifically exposes the service on NodePort 32000, which routes traffic to the target container port 3000.
apiVersion: v1
kind: Service
metadata:
name: grafana-service-xfusion
spec:
type: NodePort
selector:
app: grafana
ports:
- port: 3000
targetPort: 3000
nodePort: 32000
protocol: TCP
Execution and Verification
The configuration files were applied sequentially using kubectl
:
thor@jumphost ~$ kubectl apply -f grafana-deployment-xfusion.yaml
deployment.apps/grafana-deployment-xfusion created
thor@jumphost ~$ kubectl apply -f grafana-service-xfusion.yaml
service/grafana-service-xfusion created
Verification commands confirmed the successful creation of both resources:
Resource | Verification Command | Output Highlight |
---|---|---|
Deployment | kubectl get deployment grafana-deployment-xfusion |
grafana-deployment-xfusion 0/1 1 0 |
Service | kubectl get service grafana-service-xfusion |
3000:32000/TCP |
The successful creation of the NodePort Service confirmed that the Grafana application is now accessible via any cluster node's IP address on the specified port, http://<Node_IP_Address>:32000
. This completes the task, providing the team with a functional, cloud-native analytics solution.
Top comments (0)