Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Deploy GEM on Kubernetes
This guide will layout a step by step approach to deploying a Grafana Enterprise Metrics cluster on an existing Kubernetes namespace. This guide assumes you have a working Kubernetes cluster and the ability to deploy to that cluster using the kubectl
tool. At the end of this guide you should have a functional GEM cluster running on Kubernetes using Minio as a storage backend. If you do not currently have access to a Kubernetes cluster consider following Linux deployment guide instead.
Deploy Minio
For this guide we will be using Minio as our object storage backend. Minio is a open source S3 compatible object storage service that is freely available and easy to run on Kubernetes. If you want to follow this guide but use a different object storage backend, refer to Grafana Enterprise Metrics configuration.
Copy the above yaml into a file called minio.yaml
and run the following command:
kubectl create -f minio.yaml
You can confirm you have setup Minio correctly by port-forwarding it and navigating to it in your browser:
kubectl port-forward service/minio 9000:9000
Then you can navigate to the minio admin console using your browser. The login credentials are the same as those set above, minio
and minio123
.
Create a license Secret
Next you will need to take the license.jwt
file associated with you cluster and run the following command to load it as a Kubernetes Secret.
kubectl create secret generic ge-metrics-license --from-file license.jwt
Verify you have successfully created the secret by running the following command:
kubectl get secret ge-metrics-license -oyaml
The above command should print a kubernetes Secret object with a license.jwt
field with a long base64 encoded value string.
Create a GEM config ConfigMap
Next you will create a configuration file for you cluster and deploy it as a Kubernetes ConfigMap. Copy the text and save it as config.yaml
.
Next run the following command to create the ConfigMap.
kubectl create configmap ge-metrics-config --from-file=config.yaml
Create the services for Grafana Enterprise Metrics
Two Kubernetes Services are required to run Grafana Enterprise Metrics as a StatefulSet. First is a service to support GRPC requests between replicas. Second is a gossip service port to allow the replicas to join together and form a hash ring to coordinate work.
Copy the following content into services.yaml
:
---
apiVersion: v1
kind: Service
metadata:
labels:
name: ge-metrics-discovery
name: ge-metrics-discovery
spec:
clusterIP: None
ports:
- name: ge-metrics-grpc
port: 9095
targetPort: 9095
- name: ge-metrics-gossip
port: 7946
targetPort: 7946
publishNotReadyAddresses: true
selector:
name: ge-metrics
---
apiVersion: v1
kind: Service
metadata:
labels:
name: ge-metrics
name: ge-metrics
spec:
ports:
- name: ge-metrics-http-metrics
port: 80
targetPort: 80
selector:
name: ge-metrics
Create the services:
kubectl apply -f services.yaml
Deploy the Grafana Enterprise Metrics StatefulSet
Copy the following content into the statefulset.yaml
file, and make sure to add the <version_number>
of the GEM image that you would like to run:
Create the StatefulSet:
kubectl apply -f statefulset.yaml
Start the GEM compactor as a Kubernetes deployment
The single binary of GEM does not enable the compactor component by default. Therefore, you need to run the compactor separately as a Kubernetes StatefulSet. For more information about what the compactor does, refer to the Compactor section of the Cortex documentation.
- Copy the following content into the
compactor.yaml
file, and make sure to update the<version_number>
of the GEM image that you would like to run:
- Create the compactor StatefulSet:
kubectl apply -f compactor.yaml
Generate an admin token
To generate a token, use a Kubernetes Job.
Copy the following content it into the
tokengen-job.yaml
file, and make sure to update the<version_number>
of the GEM image that you would like to run:
apiVersion: batch/v1
kind: Job
metadata:
name: ge-metrics-tokengen
spec:
template:
spec:
containers:
- name: ge-metrics-tokengen
image: grafana/metrics-enterprise:<version_number>
args:
- --config.file=/etc/ge-metrics/config.yaml
- --target=tokengen
volumeMounts:
- mountPath: /etc/ge-metrics
name: ge-metrics-config
- mountPath: /etc/ge-metrics/license
name: ge-metrics-license
securityContext:
runAsUser: 10001
runAsGroup: 10001
runAsNonRoot: true
securityContext:
fsGroup: 10001
volumes:
- name: ge-metrics-config
configMap:
name: ge-metrics-config
- name: ge-metrics-license
secret:
secretName: ge-metrics-license
restartPolicy: Never
Create the tokengen kubernetes Job:
$ kubectl apply -f tokengen-job.yaml
- Check the status of the Pod, and after it displays ‘Completed’, check the logs for the new admin token:
kubectl logs job.batch/ge-metrics-tokengen
The output of the above command should contain a token in string in the logs:
Token created: Ym9vdHN0cmFwLXRva2VuOmA3PzkxOF0zfVx0MTlzMVteTTcjczNAPQ==
Be sure to note down this token since it will be required later when setting up your cluster.
Verify your cluster is working
To verify your cluster is working you can run the following command using the token you generated in the previous step.
First, port-forward the ge-metrics Service to port 9000 on your machine:
kubectl port-forward service/ge-metrics 9000:80
Then run the following command:
curl -u :<your_token> localhost:9000/ready
After running the above command you should see the following output:
ready
Next steps
After you have a GEM deployment working locally, refer to Set up the GEM plugin for Grafana to integrate your metrics cluster into Grafana. Doing so gives you a UI via which you can interact with the Admin API.