<commit_before>---
- name: Deploy prometheus configMap
  community.kubernetes.k8s:
    state: present
    definition: "{{ lookup('template', '{{ item }}_configMap.yml.j2') | from_yaml }}"
    validate:
      fail_on_error: yes
  notify: Restart prometheus
  loop:
    - prometheus
    - prometheus_alert_rules

- name: Deploy prometheus pvc
  community.kubernetes.k8s:
    state: present
    definition:
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: prometheus
        namespace: default
        labels:
          app: prometheus-deployment
      spec:
        storageClassName: local-path
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi

- name: Deploy prometheus deployment
  community.kubernetes.k8s:
    state: present
    definition:
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: prometheus
        namespace: default
        labels:
          app: prometheus
      spec:
        replicas: 1
        strategy:
          rollingUpdate:
            maxSurge: 1
            maxUnavailable: 1
          type: RollingUpdate
        selector:
          matchLabels:
            app: prometheus
        template:
          metadata:
            labels:
              app: prometheus
            annotations:
              prometheus.io/scrape: "true"
              prometheus.io/port: "9090"
          spec:
            containers:
              - name: prometheus
                image: "prom/prometheus:{{ prometheus_version|default('latest') }}"
                imagePullPolicy: Always
                terminationMessagePath: /dev/termination-log
                terminationMessagePolicy: File
                args:
                  - '--storage.tsdb.retention=30d'
                  - '--storage.tsdb.path=/prometheus'
                  - '--config.file=/etc/prometheus/prometheus.yml'
                  - '--web.enable-lifecycle'
                ports:
                  - name: web
                    containerPort: 9090
                    protocol: TCP
                volumeMounts:
                  - name: prometheus-config-volume
                    mountPath: /etc/prometheus
                  - name: prometheus-alert-rules-config-volume
                    mountPath: /etc/prometheus/rules
                  - name: prometheus-storage-volume
                    mountPath: /prometheus
                resources:
                  limits:
                    cpu: "2"
                    memory: "512Mi"
                  requests:
                    cpu: "1"
                    memory: "128Mi"
            restartPolicy: Always
            volumes:
              - name: prometheus-config-volume
                configMap:
                  defaultMode: 420
                  name: prometheus-config<commit_msg>Add hosts aliases to prometheus if specified<commit_after>---
- name: Deploy prometheus configMap
  community.kubernetes.k8s:
    state: present
    definition: "{{ lookup('template', '{{ item }}_configMap.yml.j2') | from_yaml }}"
    validate:
      fail_on_error: yes
  notify: Restart prometheus
  loop:
    - prometheus
    - prometheus_alert_rules

- name: Deploy prometheus pvc
  community.kubernetes.k8s:
    state: present
    definition:
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: prometheus
        namespace: default
        labels:
          app: prometheus-deployment
      spec:
        storageClassName: local-path
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 10Gi

- name: Deploy prometheus deployment
  community.kubernetes.k8s:
    state: present
    definition:
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: prometheus
        namespace: default
        labels:
          app: prometheus
      spec:
        replicas: 1
        strategy:
          rollingUpdate:
            maxSurge: 1
            maxUnavailable: 1
          type: RollingUpdate
        selector:
          matchLabels:
            app: prometheus
        template:
          metadata:
            labels:
              app: prometheus
            annotations:
              prometheus.io/scrape: "true"
              prometheus.io/port: "9090"
          spec:
            containers:
              - name: prometheus
                image: "prom/prometheus:{{ prometheus_version|default('latest') }}"
                imagePullPolicy: Always
                terminationMessagePath: /dev/termination-log
                terminationMessagePolicy: File
                args:
                  - '--storage.tsdb.retention=30d'
                  - '--storage.tsdb.path=/prometheus'
                  - '--config.file=/etc/prometheus/prometheus.yml'
                  - '--web.enable-lifecycle'
                ports:
                  - name: web
                    containerPort: 9090
                    protocol: TCP
                volumeMounts:
                  - name: prometheus-config-volume
                    mountPath: /etc/prometheus
                  - name: prometheus-alert-rules-config-volume
                    mountPath: /etc/prometheus/rules
                  - name: prometheus-storage-volume
                    mountPath: /prometheus
                resources:
                  limits:
                    cpu: "2"
                    memory: "512Mi"
                  requests:
                    cpu: "1"
                    memory: "128Mi"
            restartPolicy: Always
            hostAliases: "{{ prometheus_host_aliases|default([]) }}"
            volumes:
              - name: prometheus-config-volume
                configMap:
                  defaultMode: 420
                  name: prometheus-config
{'fraction_non_alphanumeric': 0.07618393960192175, 'fraction_numerical': 0.01098146877144818, 'mean_word_length': 1.2849862798902392, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '410143', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1419, 'n_words': 317}