Create Prometheus Environment
In this section we will show how you can create your prometheus environment as part of your kubernetes cluster, regardless of what cloud provider you have chosen.
Prometheus with AKS
For the monitoring and alerting aspect of your cluster, Fractal Cloud fully supports Prometheus.
Prometheus works hand in hand with an API Gateway component. Below, we will show an example of this using Ambassador. You can provide the host URL and Prometheus, Grafana and Alert Manager will be availble at that URL.
When you create your Kubernetes Cluster, you have the option to specify a Monitoring
component. In the example below, we will demonstrate how to create an Ambassador instance part of your AKS.
Prometheus with Ambassador in AKS
AzureKubernetesService.builder()
.withId("aks-1")
.withDescription("Test AKS cluster")
.withRegion(EUROPE_WEST)
.withNodePool(AzureNodePool.builder()
.withName("linuxdynamic")
.withMachineType(STANDARD_B2S)
.build())
.withAPIGateway(CaaSAmbassador.builder()
.withId("ambassador")
.withHost("api.yourdomain.com")
.withHostOwnerEmail("email@yourdomain.com")
.withAcmeProviderAuthority("https://acme-v02.api.letsencrypt.org/directory")
.withTlsSecretName("env-tls-cert")
.build())
.withMonitoring(CaaSPrometheus.builder()
.withId("prometheus")
.withNamespace("monitoring")
.withApiGatewayUrl("api.yourdomain.com")
.build())
.build();
For more details you can check the code on GitHub in our samples repository for Prometheus with Ambassador in AKS.
Prometheus with Ambassador in GKE
GoogleKubernetesEngine.builder()
.withId("gke-1")
.withDescription("Test GKE cluster")
.withRegion(EU_WEST1)
.withNodePool(GcpNodePool.builder()
.withName("nodepool")
.withMachineType(E2_STANDARD2)
.build())
.withAPIGateway(CaaSAmbassador.builder()
.withId("ambassador")
.withHost("api.yourdomain.com")
.withHostOwnerEmail("email@yourdomain.com")
.withAcmeProviderAuthority("https://acme-v02.api.letsencrypt.org/directory")
.withTlsSecretName("env-tls-cert")
.build())
.withMonitoring(CaaSPrometheus.builder()
.withId("prometheus")
.withNamespace("monitoring")
.withApiGatewayUrl("api.yourdomain.com")
.build())
.build();
For more details you can check the code on GitHub in our samples repository for Prometheus with Ambassador in GKE.
Prometheus Prerequisites
The Prometheus operator requires the following images:
- quay.io/prometheus-operator/prometheus-operator:v0.53.1
- quay.io/brancz/kube-rbac-proxy:v0.11.0
- quay.io/prometheus/blackbox-exporter:v0.19.0
- jimmidyson/configmap-reload:v0.5.0
- grafana/grafana:8.5.0
- k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.3.0
- quay.io/brancz/kube-rbac-proxy:v0.11.0
- willdockerhub/prometheus-adapter:v0.9.1
- quay.io/prometheus/prometheus:v2.35.0
- quay.io/prometheus-operator/prometheus-config-reloader:v0.53.1
- prom/node-exporter:v1.3.1
- prom/alertmanager:v0.24.0
If they are missing in the Fractal container registry, they must be pushed.
If you are instantiating Prometheus on Azure, you can simply push the images using a script like this:
az login
resourceGroupId="<your resource group id>"
subscription="<your subscription id>"
az acr login --name ${resourceGroupId}acr
docker pull "quay.io/prometheus-operator/prometheus-operator:v0.53.1"
docker tag "quay.io/prometheus-operator/prometheus-operator:v0.53.1" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus-operator:v0.53.1"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus-operator:v0.53.1"
docker pull "quay.io/brancz/kube-rbac-proxy:v0.11.0"
docker tag "quay.io/brancz/kube-rbac-proxy:v0.11.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/kube-rbac-proxy:v0.11.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/kube-rbac-proxy:v0.11.0"
docker pull "quay.io/prometheus/blackbox-exporter:v0.19.0"
docker tag "quay.io/prometheus/blackbox-exporter:v0.19.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/blackbox-exporter:v0.19.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/blackbox-exporter:v0.19.0"
docker pull "jimmidyson/configmap-reload:v0.5.0"
docker tag "jimmidyson/configmap-reload:v0.5.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/configmap-reload:v0.5.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/configmap-reload:v0.5.0"
docker pull "grafana/grafana:8.5.0"
docker tag "grafana/grafana:8.5.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/grafana:8.5.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/grafana:8.5.0"
docker pull "k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.3.0"
docker tag "k8s.gcr.io/kube-state-metrics/kube-state-metrics:v2.3.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/kube-state-metrics:v2.3.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/kube-state-metrics:v2.3.0"
docker pull "quay.io/brancz/kube-rbac-proxy:v0.11.0"
docker tag "quay.io/brancz/kube-rbac-proxy:v0.11.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/kube-rbac-proxy:v0.11.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/kube-rbac-proxy:v0.11.0"
docker pull "willdockerhub/prometheus-adapter:v0.9.1"
docker tag "willdockerhub/prometheus-adapter:v0.9.1" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus-adapter:v0.9.1"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus-adapter:v0.9.1"
docker pull "quay.io/prometheus/prometheus:v2.35.0"
docker tag "quay.io/prometheus/prometheus:v2.35.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus:v2.35.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus:v2.35.0"
docker pull "quay.io/prometheus-operator/prometheus-config-reloader:v0.53.1"
docker tag "quay.io/prometheus-operator/prometheus-config-reloader:v0.53.1" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus-config-reloader:v0.53.1"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/prometheus-config-reloader:v0.53.1"
docker pull "prom/node-exporter:v1.3.1"
docker tag "prom/node-exporter:v1.3.1" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/node-exporter:v1.3.1"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/node-exporter:v1.3.1"
docker pull "prom/alertmanager:v0.24.0"
docker tag "prom/alertmanager:v0.24.0" "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/alertmanager:v0.24.0"
docker push "${resourceGroupId}acr.azurecr.io/${subscription}/monitoring/alertmanager:v0.24.0"