tyriis / home-ops

IaC for my HomeLab kubernetes cluster resources with Flux
https://github.com/tyriis/home-ops/blob/main/README.md
39 stars 2 forks source link

feat(esphome): remove switch bedroom from prometheus #4001

Closed tyriis closed 6 days ago

sonarcloud[bot] commented 6 days ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

tyriis-automation[bot] commented 6 days ago

--- kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app Kustomization: flux-system/apps-kube-prometheus-stack HelmRelease: observability/kube-prometheus-stack

+++ kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app Kustomization: flux-system/apps-kube-prometheus-stack HelmRelease: observability/kube-prometheus-stack

@@ -149,8 +149,8 @@

   valuesFrom:
   - kind: ConfigMap
     name: alertmanager-values-gm8h59ctm7
   - kind: ConfigMap
     name: kube-state-metrics-values-h9m2ccfk54
   - kind: ConfigMap
-    name: prometheus-values-kkfg4c7kmf
+    name: prometheus-values-fmgc2cc9bc

--- kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app Kustomization: flux-system/apps-kube-prometheus-stack ConfigMap: observability/prometheus-values-kkfg4c7kmf

+++ kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app Kustomization: flux-system/apps-kube-prometheus-stack ConfigMap: observability/prometheus-values-kkfg4c7kmf

@@ -1,197 +0,0 @@

----
-apiVersion: v1
-data:
-  values.yaml: |
-    ---
-    prometheus:
-      thanosService:
-        enabled: true
-      thanosServiceMonitor:
-        enabled: true
-      ingress:
-        enabled: true
-        ingressClassName: traefik
-        annotations:
-          cert-manager.io/cluster-issuer: letsencrypt-production
-          kubernetes.io/tls-acme: "true"
-          traefik.ingress.kubernetes.io/router.middlewares: traefik-ingress-sso@kubernetescrd
-          traefik.ingress.kubernetes.io/router.entrypoints: websecure
-          traefik.ingress.kubernetes.io/affinity: "true"
-          traefik.ingress.kubernetes.io/router.tls: "true"
-          external-dns/opnsense: "true"
-          hajimari.io/appName: prometheus
-          hajimari.io/enable: "true"
-          hajimari.io/icon: simple-icons:prometheus
-          gethomepage.dev/enabled: "true"
-          gethomepage.dev/description: Monitoring and Alerting Toolkit
-          gethomepage.dev/group: Observability
-          gethomepage.dev/icon: prometheus
-          gethomepage.dev/name: Prometheus
-          gethomepage.dev/weight: "1" # optional
-          # gethomepage.dev/widget.type: prometheus
-          # gethomepage.dev/widget.url: http://prometheus-operated.observability.svc.cluster.local:9090
-          gethomepage.dev/pod-selector: app.kubernetes.io/name=prometheus
-        hosts:
-          - &host prometheus.techtales.io
-        tls:
-          - secretName: prometheus-tls
-            hosts:
-              - *host
-      prometheusSpec:
-        podMetadata:
-          annotations:
-            secret.reloader.stakater.com/reload: &secret thanos-objstore-secret
-        scrapeInterval: 1m # Must match interval in Grafana Helm chart
-        scrapeConfigSelectorNilUsesHelmValues: false
-        walCompression: true
-        enableFeatures:
-          - auto-gomemlimit
-          - memory-snapshot-on-shutdown
-          - new-service-discovery-manager
-        image:
-          registry: quay.io
-          repository: prometheus/prometheus
-          tag: v2.51.0-dedupelabels
-        externalLabels:
-          cluster: talos-flux
-
-        replicas: 3
-        replicaExternalLabelName: __replica__
-        ruleSelectorNilUsesHelmValues: false
-        serviceMonitorSelectorNilUsesHelmValues: false
-        podMonitorSelectorNilUsesHelmValues: false
-        probeSelectorNilUsesHelmValues: false
-        retentionSize: 8GB
-        retention: 14d
-        enableAdminAPI: true
-        # walCompression: true
-        storageSpec:
-          volumeClaimTemplate:
-            spec:
-              storageClassName: ceph-block
-              resources:
-                requests:
-                  storage: 10Gi
-        resources:
-          # limits:
-          #   memory: 4Gi
-          #   cpu: 4000m
-          requests:
-            memory: 4Gi
-            cpu: 1000m
-
-        thanos:
-          image: quay.io/thanos/thanos:v0.28.0
-          version: v0.28.0
-          objectStorageConfig:
-            name: *secret
-            key: objstore.yml
-
-        podAnnotations:
-          secret.reloader.stakater.com/reload: *secret
-
-        externalUrl: https://prometheus.techtales.io/
-        # ruleSelector: {}
-        # ruleNamespaceSelector: {}
-        # serviceMonitorSelector: {}
-        # serviceMonitorNamespaceSelector: {}
-        # podMonitorSelector: {}
-        # podMonitorNamespaceSelector: {}
-
-        additionalScrapeConfigs:
-          # ESPHome lights
-          - job_name: esphome-light-alexroom
-            static_configs:
-              - targets:
-                  - esphome-light-alexroom.home
-                labels:
-                  device: light-alexroom
-          - job_name: esphome-light-stairs
-            static_configs:
-              - targets:
-                  - esphome-light-stairs.home
-                labels:
-                  device: light-stairs
-          # ESPHome sensors
-          - job_name: esphome-sensor-bathroom
-            static_configs:
-              - targets:
-                  - esphome-sensor-bathroom.home
-                labels:
-                  device: sensor-bathroom
-          - job_name: esphome-sensor-domiroom
-            static_configs:
-              - targets:
-                  - esphome-sensor-domiroom.home
-                labels:
-                  device: sensor-domiroom
-          - job_name: esphome-sensor-heating
-            static_configs:
-              - targets:
-                  - esphome-sensor-heating.home
-                labels:
-                  device: sensor-heating
-          # ESPHome switches
-          - job_name: esphome-switch-alexroom
-            static_configs:
-              - targets:
-                  - esphome-switch-alexroom.home
-                labels:
-                  device: switch-alexroom
-          - job_name: esphome-switch-basement
-            static_configs:
-              - targets:
-                  - esphome-switch-basement.home
-                labels:
-                  device: switch-basement
-          - job_name: esphome-switch-domiroom
-            static_configs:
-              - targets:
-                  - esphome-switch-domiroom.home
-                labels:
-                  device: switch-domiroom
-          - job_name: esphome-switch-livingroom
-            static_configs:
-              - targets:
-                  - esphome-switch-livingroom.home
-                labels:
-                  device: switch-livingroom
-          - job_name: esphome-switch-bedroom
-            static_configs:
-              - targets:
-                  - esphome-switch-bedroom.home
-                labels:
-                  device: switch-bedroom
-          # homeassistant
-          - job_name: homeassistant
-            scrape_interval: 60s
-            metrics_path: /api/prometheus
-
-            # Long-Lived Access Token
-            authorization:
-              credentials: ..PLACEHOLDER_SECRET_HASS_API_TOKEN..
-
-            scheme: https
-            static_configs:
-              - targets:
-                  - hass.techtales.io
-
-          # - job_name: ohm-exporter
-          #   scrape_interval: 15s
-          #   static_configs:
-          #   - targets:
-          #     - red.home:4445
-          #     - carbon.home:4445
-          # - job_name: windows-exporter
-          #   scrape_interval: 15s
-          #   static_configs:
-          #   - targets:
-          #     - red.home:9182
-kind: ConfigMap
-metadata:
-  labels:
-    kustomize.toolkit.fluxcd.io/name: apps-kube-prometheus-stack
-    kustomize.toolkit.fluxcd.io/namespace: flux-system
-  name: prometheus-values-kkfg4c7kmf
-  namespace: observability
-
--- kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app Kustomization: flux-system/apps-kube-prometheus-stack ConfigMap: observability/prometheus-values-fmgc2cc9bc

+++ kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app Kustomization: flux-system/apps-kube-prometheus-stack ConfigMap: observability/prometheus-values-fmgc2cc9bc

@@ -0,0 +1,191 @@

+---
+apiVersion: v1
+data:
+  values.yaml: |
+    ---
+    prometheus:
+      thanosService:
+        enabled: true
+      thanosServiceMonitor:
+        enabled: true
+      ingress:
+        enabled: true
+        ingressClassName: traefik
+        annotations:
+          cert-manager.io/cluster-issuer: letsencrypt-production
+          kubernetes.io/tls-acme: "true"
+          traefik.ingress.kubernetes.io/router.middlewares: traefik-ingress-sso@kubernetescrd
+          traefik.ingress.kubernetes.io/router.entrypoints: websecure
+          traefik.ingress.kubernetes.io/affinity: "true"
+          traefik.ingress.kubernetes.io/router.tls: "true"
+          external-dns/opnsense: "true"
+          hajimari.io/appName: prometheus
+          hajimari.io/enable: "true"
+          hajimari.io/icon: simple-icons:prometheus
+          gethomepage.dev/enabled: "true"
+          gethomepage.dev/description: Monitoring and Alerting Toolkit
+          gethomepage.dev/group: Observability
+          gethomepage.dev/icon: prometheus
+          gethomepage.dev/name: Prometheus
+          gethomepage.dev/weight: "1" # optional
+          # gethomepage.dev/widget.type: prometheus
+          # gethomepage.dev/widget.url: http://prometheus-operated.observability.svc.cluster.local:9090
+          gethomepage.dev/pod-selector: app.kubernetes.io/name=prometheus
+        hosts:
+          - &host prometheus.techtales.io
+        tls:
+          - secretName: prometheus-tls
+            hosts:
+              - *host
+      prometheusSpec:
+        podMetadata:
+          annotations:
+            secret.reloader.stakater.com/reload: &secret thanos-objstore-secret
+        scrapeInterval: 1m # Must match interval in Grafana Helm chart
+        scrapeConfigSelectorNilUsesHelmValues: false
+        walCompression: true
+        enableFeatures:
+          - auto-gomemlimit
+          - memory-snapshot-on-shutdown
+          - new-service-discovery-manager
+        image:
+          registry: quay.io
+          repository: prometheus/prometheus
+          tag: v2.51.0-dedupelabels
+        externalLabels:
+          cluster: talos-flux
+
+        replicas: 3
+        replicaExternalLabelName: __replica__
+        ruleSelectorNilUsesHelmValues: false
+        serviceMonitorSelectorNilUsesHelmValues: false
+        podMonitorSelectorNilUsesHelmValues: false
+        probeSelectorNilUsesHelmValues: false
+        retentionSize: 8GB
+        retention: 14d
+        enableAdminAPI: true
+        # walCompression: true
+        storageSpec:
+          volumeClaimTemplate:
+            spec:
+              storageClassName: ceph-block
+              resources:
+                requests:
+                  storage: 10Gi
+        resources:
+          # limits:
+          #   memory: 4Gi
+          #   cpu: 4000m
+          requests:
+            memory: 4Gi
+            cpu: 1000m
+
+        thanos:
+          image: quay.io/thanos/thanos:v0.28.0
+          version: v0.28.0
+          objectStorageConfig:
+            name: *secret
+            key: objstore.yml
+
+        podAnnotations:
+          secret.reloader.stakater.com/reload: *secret
+
+        externalUrl: https://prometheus.techtales.io/
+        # ruleSelector: {}
+        # ruleNamespaceSelector: {}
+        # serviceMonitorSelector: {}
+        # serviceMonitorNamespaceSelector: {}
+        # podMonitorSelector: {}
+        # podMonitorNamespaceSelector: {}
+
+        additionalScrapeConfigs:
+          # ESPHome lights
+          - job_name: esphome-light-alexroom
+            static_configs:
+              - targets:
+                  - esphome-light-alexroom.home
+                labels:
+                  device: light-alexroom
+          - job_name: esphome-light-stairs
+            static_configs:
+              - targets:
+                  - esphome-light-stairs.home
+                labels:
+                  device: light-stairs
+          # ESPHome sensors
+          - job_name: esphome-sensor-bathroom
+            static_configs:
+              - targets:
+                  - esphome-sensor-bathroom.home
+                labels:
+                  device: sensor-bathroom
+          - job_name: esphome-sensor-domiroom
+            static_configs:
+              - targets:
+                  - esphome-sensor-domiroom.home
+                labels:
+                  device: sensor-domiroom
+          - job_name: esphome-sensor-heating
+            static_configs:
+              - targets:
+                  - esphome-sensor-heating.home
+                labels:
+                  device: sensor-heating
+          # ESPHome switches
+          - job_name: esphome-switch-alexroom
+            static_configs:
+              - targets:
+                  - esphome-switch-alexroom.home
+                labels:
+                  device: switch-alexroom
+          - job_name: esphome-switch-basement
+            static_configs:
+              - targets:
+                  - esphome-switch-basement.home
+                labels:
+                  device: switch-basement
+          - job_name: esphome-switch-domiroom
+            static_configs:
+              - targets:
+                  - esphome-switch-domiroom.home
+                labels:
+                  device: switch-domiroom
+          - job_name: esphome-switch-livingroom
+            static_configs:
+              - targets:
+                  - esphome-switch-livingroom.home
+                labels:
+                  device: switch-livingroom
+          # homeassistant
+          - job_name: homeassistant
+            scrape_interval: 60s
+            metrics_path: /api/prometheus
+
+            # Long-Lived Access Token
+            authorization:
+              credentials: ..PLACEHOLDER_SECRET_HASS_API_TOKEN..
+
+            scheme: https
+            static_configs:
+              - targets:
+                  - hass.techtales.io
+
+          # - job_name: ohm-exporter
+          #   scrape_interval: 15s
+          #   static_configs:
+          #   - targets:
+          #     - red.home:4445
+          #     - carbon.home:4445
+          # - job_name: windows-exporter
+          #   scrape_interval: 15s
+          #   static_configs:
+          #   - targets:
+          #     - red.home:9182
+kind: ConfigMap
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: apps-kube-prometheus-stack
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: prometheus-values-fmgc2cc9bc
+  namespace: observability
+
--- kubernetes/talos-flux/apps/home-automation/esphome/app Kustomization: flux-system/apps-esphome ConfigMap: home-automation/esphome-config

+++ kubernetes/talos-flux/apps/home-automation/esphome/app Kustomization: flux-system/apps-esphome ConfigMap: home-automation/esphome-config

@@ -1336,209 +1336,12 @@

     # status_led:
     #   # https://esphome.io/components/status_led
     #   pin:
     #     number: GPIO13
     #     inverted: True
-  switch-bedroom.yaml: |
-    substitutions:
-      host_name: switch-bedroom
-      device_name: switch_bedroom
-      friendly_name: Switch Bedroom
-
-    esphome:
-      name: ${host_name}
-      platform: ESP8266
-      board: esp01_1m
-
-    # Enable logging
-    logger:
-      level: INFO
-      logs:
-        mqtt.component: INFO
-        mqtt.client: INFO
-
-    # Enable Home Assistant API
-    api:
-      password: !secret api_password
-      encryption:
-        key: !secret api_encription_key
-
-    ota:
-      password: !secret ota_password
-
-    wifi:
-      ssid: !secret wifi_ssid
-      password: !secret wifi_password
-      use_address: 192.168.1.135
-      # domain: .home
-
-      # Enable fallback hotspot (captive portal) in case wifi connection fails
-      ap:
-        ssid: "ESPHome ${device_name} Hotspot"
-        password: !secret ap_password
-
-    captive_portal:
-
-    # MQTT
-    mqtt:
-      # disable mqtt logging
-      log_topic:
-      id: nqtt_client
-      broker: mqtt.home
-      client_id: esphome_${device_name}
-      discovery: false
-      discovery_retain: true
-      topic_prefix: ESPHome/${device_name}
-      birth_message:
-        topic: ESPHome/${device_name}/state
-        payload: 1
-        qos: 2
-        retain: true
-      shutdown_message:
-        topic: ESPHome/${device_name}/state
-        payload: 0
-        qos: 2
-        retain: true
-      will_message:
-        topic: ESPHome/${device_name}/state
-        payload: 0
-        qos: 2
-        retain: true
-
-      on_message:
-        - topic: ESPHome/${device_name}/switch/${device_name}_relay/set
-          payload: "ON"
-          then:
-            - switch.turn_on: relay_1
-        - topic: ESPHome/${device_name}/switch/${device_name}_relay/set
-          payload: "OFF"
-          then:
-            - switch.turn_off: relay_1
-
-    # web_server:
-    #   port: 80
-    #   auth:
-    #     username: !secret web_username
-    #     password: !secret web_password
-    #   ota: false
-
-    # expose prometheus data
-    prometheus:
-
-    text_sensor:
-      # wifi info
-      - platform: wifi_info
-        ip_address:
-          name: "${friendly_name} WiFi IP"
-      - platform: version
-        name: "${friendly_name} Firmware"
-
-      - platform: template
-        name: "${friendly_name} MAC Address"
-        lambda: 'return {WiFi.macAddress().c_str()};'
-        icon: mdi:fingerprint
-        update_interval: 60s
-        internal: true
-
-      - platform: template
-        name: "${friendly_name} Wifi Strength"
-        id: ${device_name}_wifi_strength
-        icon: "mdi:wifi"
-        lambda: |-
-          if (id(${device_name}_wifi_signal).state > -50 ) {
-            return {"Excellent"};
-          } else if (id(${device_name}_wifi_signal).state > -60) {
-            return {"Good"};
-          } else if (id(${device_name}_wifi_signal).state > -70) {
-            return {"Fair"};
-          } else if (id(${device_name}_wifi_signal).state < -70) {
-            return {"Weak"};
-          } else {
-            return {"None"};
-          }
-        update_interval: 900s
-
-    sensor:
-      - platform: uptime
-        name: "Device Uptime ${friendly_name}"
-        id: uptime_sensor
-        update_interval: 60s
-        disabled_by_default: true
-        # on_raw_value:
-        #   then:
-        #     - text_sensor.template.publish:
-        #         id: uptime_human
-        #         state: !lambda |-
-        #           int seconds = round(id(uptime_sensor).raw_state);
-        #           int days = seconds / (24 * 3600);
-        #           seconds = seconds % (24 * 3600);
-        #           int hours = seconds / 3600;
-        #           seconds = seconds % 3600;
-        #           int minutes = seconds /  60;
-        #           seconds = seconds % 60;
-        #           return (
-        #             (days ? to_string(days) + "d " : "") +
-        #             (hours ? to_string(hours) + "h " : "") +
-        #             (minutes ? to_string(minutes) + "m " : "") +
-        #             (to_string(seconds) + "s")
-        #           ).c_str();
-      - platform: wifi_signal
-        name: "${friendly_name} WiFi Signal"
-        id: ${device_name}_wifi_signal
-        update_interval: 900s
-        internal: true
-
-    time:
-      - platform: homeassistant
-        id: homeassistant_time
-
-    binary_sensor:
-      - platform: gpio
-        pin:
-          number: GPIO0
-          mode: INPUT_PULLUP
-          inverted: True
-        name: "${friendly_name} Touchpad"
-        on_press:
-          then:
-            - switch.toggle: relay_1
-      - platform: status
-        name: "${friendly_name} Status"
-
-    switch:
-      - platform: gpio
-        name: "${friendly_name} Relay"
-        id: relay_1
-        pin: GPIO12
-        # on_turn_on:
-        # - delay: 250ms
-        # - light.turn_off: light_1
-        # on_turn_off:
-        # - delay: 250ms
-        # - light.turn_on: light_1
-
-      - platform: restart
-        name: "${friendly_name} Restart"
-        disabled_by_default: true
-
-    output:
-      # Register the blue LED as a dimmable output ....
-      - platform: esp8266_pwm
-        id: blue_led
-        pin: GPIO13
-        inverted: True
-
-    light:
-      # ... and then make a light out of it.
-      - platform: monochromatic
-        id: light_1
-        name: "${friendly_name} WIFI LED"
-        output: blue_led
-        default_transition_length: 750ms
-        disabled_by_default: true
   switch-domiroom.yaml: |-
     # 2022-06-04

     substitutions:
       host_name: switch-domiroom
       device_name: switch_domiroom