aboutsummaryrefslogtreecommitdiff
path: root/roles/monitoring/tasks/main.yaml
blob: cb954fd97c18db99081b4d8d3158c42e55cadd34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
- name: Add Prometheus remote chart
  kubernetes.core.helm_repository:
    name: prometheus
    repo_url: https://prometheus-community.github.io/helm-charts
  delegate_to: localhost
  run_once: true

- name: Add Prometheus PV
  kubernetes.core.k8s:
    state: "{%- if monitoring.enabled -%} present {%- else -%} absent {%- endif -%}"
    definition:
      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: "prometheus-pv"
        labels:
          app: "prometheus-pv"
      spec:
        storageClassName: nfs
        capacity:
          storage: 8Gi
        accessModes:
          - ReadWriteMany
        nfs:
          server: "{{ nfs.server }}"
          path: "{{ nfs.path }}"
          readOnly: false
  delegate_to: localhost
  run_once: true

- name: Add Prometheus PVC
  kubernetes.core.k8s:
    state: "{%- if monitoring.enabled -%} present {%- else -%} absent {%- endif -%}"
    definition:
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: prometheus-pvc
        namespace: default
      spec:
        storageClassName: nfs
        accessModes:
          - ReadWriteMany
        resources:
          requests:
            storage: 8Gi
        selector:
          matchLabels:
            app: "prometheus-pv"
  delegate_to: localhost
  run_once: true

- name: Deploy prometheus
  kubernetes.core.helm:
    name: prometheus
    chart_ref: prometheus/prometheus
    namespace: default
    state: "{%- if monitoring.enabled -%} present {%- else -%} absent {%- endif -%}"
    values:
      alertmanager:
        enabled: false
      prometheus-pushgateway:
        enabled: false
      server:
        ingress:
          annotations:
            cert-manager.io/cluster-issuer: ca-issuer
          enabled: true
          hosts:
            - prometheus.home
          tls:
            - secretName: prometheus-tls
              hosts:
                - prometheus.home
          securityContext:
            runAsUser: 1000
            runAsNonRoot: true
            runAsGroup: 1000
            fsGroup: 1000
          persistentVolume:
            existingClaim: "prometheus-pvc"
  delegate_to: localhost
  run_once: true