Skip to content

Commit

Permalink
feat: ✨ Add GitLab Operator alerting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
cmon33 committed Aug 28, 2024
1 parent af0c7e4 commit 37521a8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
11 changes: 10 additions & 1 deletion roles/gitlab-operator/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
needs_update: true

- name: Install GitLab Operator
when: (gl_api == 'absent') or (gl_vwhc.resources | length == 0) or (needs_update)
when: >
gl_api == 'absent' or
gl_vwhc.resources | length == 0 or
needs_update or
dsc.gitlabOperator.forcedInstall
block:
- name: Create GitLab Operator namespace
kubernetes.core.k8s:
Expand Down Expand Up @@ -77,3 +81,8 @@
until: endpoint.resources[0].subsets[0].addresses[0] is defined
retries: 15
delay: 5

- name: Set alerting rules
when: dsc.global.alerting.enabled
kubernetes.core.k8s:
template: prometheusrule.yml.j2
22 changes: 22 additions & 0 deletions roles/gitlab-operator/templates/prometheusrule.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
app.kubernetes.io/name: gitlab
name: gitlab-operator
namespace: {{ dsc.gitlabOperator.namespace }}
spec:
groups:
- name: GitLab Operator
rules:
- alert: GitLab Operator Pod not healthy
annotations:
message: GitLab Operator {{"{{"}} $labels.pod {{"}}"}} pod in namespace {{ dsc.gitlabOperator.namespace }} has been unavailable for the last 5 minutes.
summary: GitLab Operator {{"{{"}} $labels.pod {{"}}"}} pod not healthy (container {{"{{"}} $labels.container {{"}}"}} is not ready)
expr: |
kube_pod_container_status_ready{
pod=~"gitlab-controller-manager(-.*)*",
namespace="{{ dsc.gitlabOperator.namespace }}"} == 0
for: 5m
labels:
severity: critical
2 changes: 2 additions & 0 deletions roles/socle-config/files/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
cloudnativepg:
namespace: dso-cloudnativepg
helmRepoUrl: https://cloudnative-pg.github.io/charts
forcedInstall: false
console:
namespace: dso-console
subDomain: console
Expand All @@ -37,6 +38,7 @@ spec:
gitlabOperator:
namespace: dso-gitlab-operator
helmRepoUrl: https://gitlab.com/api/v4/projects/18899486/packages/helm/stable
forcedInstall: false
gitlabRunner:
helmRepoUrl: https://charts.gitlab.io
global:
Expand Down
7 changes: 7 additions & 0 deletions roles/socle-config/files/crd-conf-dso.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ spec:
namespace:
description: The namespace for GitLab Operator.
type: string
forcedInstall:
description: |
Should we force GitLab Operator installation in the desired namespace ?
Default is false, so it won't install (or reinstall) if it's already there.
Set to true for a forced installation.
default: false
type: boolean
type: object
gitlabCatalog:
description: Configuration for GitLab Catalog.
Expand Down

0 comments on commit 37521a8

Please sign in to comment.