13/08/2021 - DOCKER, ELASTICSEARCH, KUBERNETES
In this example we are going to run Grafana in Kubernetes to visualise Elasticsearch logs. It is a very simple process and assumes your Elasticsearch is running in the same namespace monitoring
as Grafana.
apiVersion: v1
kind: Service
metadata:
name: grafana
namespace: monitoring
labels:
app: grafana
spec:
type: ClusterIP
selector:
app: grafana
ports:
- name: http
protocol: TCP
port: 3000
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: grafana-data
namespace: monitoring
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
namespace: monitoring
labels:
app: grafana
spec:
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
containers:
- image: grafana/grafana:8.1.1
name: grafana
ports:
- name: http
protocol: TCP
containerPort: 3000
volumeMounts:
- name: grafana-data
mountPath: /var/lib/grafana
volumes:
- name: grafana-data
persistentVolumeClaim:
claimName: grafana-data
$ kubectl apply -f kibana.yaml
$ kubectl --namespace=monitoring port-forward service/grafana 3000:3000
Visit http://127.0.0.1:3000/
and login with (admin:admin) credentials. Use Elasticsearch for the data source setup and use values below.
- URL: http://elasticsearch:9200
- Index: kubernetes-logs
The elasticsearch
is the name of the Kubernetes service.