Configure GitLab's Prometheus server to monitor Kubernetes
Description
While Prometheus is able to detect and monitor Kubernetes based environments, it would be helpful if GitLab configured these options for the administrator in a turn-key way.
Proposal
With GitLab including Prometheus, we need to offer an easy way to enable monitoring of not just GitLab, but also Kubernetes. In the short term, we should add a new gitlab.rb
flag to enable monitoring of Kubernetes if GitLab is deployed in-cluster. While we would like to eventually automatically deploy a Prometheus instance in each Kubernetes cluster, this will allow us to get started much more quickly with little end-user effort.
Since this attribute is about a configuration setting of Prometheus, and not an entire new process to run, I would suggest we simply add this as a sub-option like prometheus['monitor_kubernetes']
with a default value of false.
scrape_configs:
- job_name: 'kubernetes-nodes'
scheme: https
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
insecure_skip_verify: true
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)