Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to a single config #3209

Merged
merged 1 commit into from
Nov 13, 2024
Merged

feat: update to a single config #3209

merged 1 commit into from
Nov 13, 2024

Conversation

joryirving
Copy link
Owner

No description provided.

@github-actions github-actions bot added area/kubernetes Changes made in the kubernetes directory cluster/main cluster/utility labels Nov 13, 2024
@smurf-bot
Copy link
Contributor

smurf-bot bot commented Nov 13, 2024

--- HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools

+++ HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools

@@ -1,26 +0,0 @@

----
-apiVersion: v1
-kind: Service
-metadata:
-  name: network-ups-tools
-  labels:
-    app.kubernetes.io/instance: network-ups-tools
-    app.kubernetes.io/managed-by: Helm
-    app.kubernetes.io/name: network-ups-tools
-    app.kubernetes.io/service: network-ups-tools
-  annotations:
-    external-dns.alpha.kubernetes.io/hostname: network-nut...PLACEHOLDER_SECRET_DOMAIN..
-    lbipam.cilium.io/ips: ..PLACEHOLDER_SVC_NUT_ADDR..
-spec:
-  type: LoadBalancer
-  externalTrafficPolicy: Cluster
-  ports:
-  - port: 3493
-    targetPort: 3493
-    protocol: TCP
-    name: http
-  selector:
-    app.kubernetes.io/component: network-ups-tools
-    app.kubernetes.io/instance: network-ups-tools
-    app.kubernetes.io/name: network-ups-tools
-
--- HelmRelease: observability/network-ups-tools Deployment: observability/network-ups-tools

+++ HelmRelease: observability/network-ups-tools Deployment: observability/network-ups-tools

@@ -18,12 +18,13 @@

       app.kubernetes.io/component: network-ups-tools
       app.kubernetes.io/name: network-ups-tools
       app.kubernetes.io/instance: network-ups-tools
   template:
     metadata:
       annotations:
+        checksum/configMaps: 2a4670cf8dd00dddc450a17513b76e33ebf7964350cee5153d4eb85c92f21eb7
         configmap.reloader.stakater.com/reload: network-ups-tools-config
       labels:
         app.kubernetes.io/component: network-ups-tools
         app.kubernetes.io/instance: network-ups-tools
         app.kubernetes.io/name: network-ups-tools
     spec:
@@ -58,12 +59,12 @@

           timeoutSeconds: 1
         securityContext:
           privileged: true
         volumeMounts:
         - mountPath: /etc/nut
           name: config
-          readOnly: true
       volumes:
       - configMap:
+          defaultMode: 256
           name: network-ups-tools-config
         name: config
 
--- HelmRelease: observability/network-ups-tools ConfigMap: observability/network-ups-tools-config

+++ HelmRelease: observability/network-ups-tools ConfigMap: observability/network-ups-tools-config

@@ -0,0 +1,36 @@

+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: network-ups-tools-config
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+data:
+  nut.conf: MODE=netserver
+  ups.conf: |-
+    [networkups]
+      driver = "usbhid-ups"
+      port = "auto"
+      desc = "Back-UPS ES 600M1"
+      vendorid = "051D"
+      productid = "0002"
+      serial = "4B2217P19326"
+  upsd.conf: |-
+    MAXAGE 20
+    LISTEN 0.0.0.0
+  upsd.users: |-
+    [monuser]
+      password = "bacon"
+      actions = SET
+      instcmds = ALL
+      upsmon primary
+  upsmon.conf: |-
+    MONITOR ups@localhost:3493 1 upsmon "bacon" primary
+    SHUTDOWNCMD "/sbin/shutdown -h +0"
+    POWERDOWNFLAG /etc/killpower
+    POLLFREQ 15
+    POLLFREQALERT 5
+    HOSTSYNC 15
+
--- HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-app

+++ HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-app

@@ -0,0 +1,26 @@

+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: network-ups-tools-app
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+    app.kubernetes.io/service: network-ups-tools-app
+  annotations:
+    external-dns.alpha.kubernetes.io/hostname: network-nut...PLACEHOLDER_SECRET_DOMAIN..
+    lbipam.cilium.io/ips: ..PLACEHOLDER_SVC_NUT_ADDR..
+spec:
+  type: LoadBalancer
+  externalTrafficPolicy: Cluster
+  ports:
+  - port: 3493
+    targetPort: 3493
+    protocol: TCP
+    name: http
+  selector:
+    app.kubernetes.io/component: network-ups-tools
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/name: network-ups-tools
+
--- HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-metrics

+++ HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-metrics

@@ -0,0 +1,22 @@

+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: network-ups-tools-metrics
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+    app.kubernetes.io/service: network-ups-tools-metrics
+spec:
+  type: ClusterIP
+  ports:
+  - port: 9199
+    targetPort: 9199
+    protocol: TCP
+    name: metrics
+  selector:
+    app.kubernetes.io/component: network-ups-tools
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/name: network-ups-tools
+
--- HelmRelease: observability/network-ups-tools ServiceMonitor: observability/network-ups-tools

+++ HelmRelease: observability/network-ups-tools ServiceMonitor: observability/network-ups-tools

@@ -0,0 +1,33 @@

+---
+apiVersion: monitoring.coreos.com/v1
+kind: ServiceMonitor
+metadata:
+  name: network-ups-tools
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+spec:
+  jobLabel: network-ups-tools
+  namespaceSelector:
+    matchNames:
+    - observability
+  selector:
+    matchLabels:
+      app.kubernetes.io/service: network-ups-tools-metrics
+      app.kubernetes.io/name: network-ups-tools
+      app.kubernetes.io/instance: network-ups-tools
+  endpoints:
+  - interval: 15s
+    params:
+      target:
+      - localhost:3493
+    path: /ups_metrics
+    port: metrics
+    relabelings:
+    - sourceLabels:
+      - __param_target
+      targetLabel: target
+    scheme: http
+    scrapeTimeout: 10s
+

@smurf-bot
Copy link
Contributor

smurf-bot bot commented Nov 13, 2024

--- kubernetes/utility/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools HelmRelease: observability/network-ups-tools

+++ kubernetes/utility/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools HelmRelease: observability/network-ups-tools

@@ -24,12 +24,41 @@

   upgrade:
     cleanupOnFail: true
     remediation:
       retries: 3
       strategy: rollback
   values:
+    configMaps:
+      config:
+        data:
+          nut.conf: MODE=netserver
+          ups.conf: |-
+            [networkups]
+              driver = "usbhid-ups"
+              port = "auto"
+              desc = "Back-UPS ES 600M1"
+              vendorid = "051D"
+              productid = "0002"
+              serial = "4B2217P19326"
+          upsd.conf: |-
+            MAXAGE 20
+            LISTEN 0.0.0.0
+          upsd.users: |-
+            [monuser]
+              password = "bacon"
+              actions = SET
+              instcmds = ALL
+              upsmon primary
+          upsmon.conf: |-
+            MONITOR ups@localhost:3493 1 upsmon "bacon" primary
+            SHUTDOWNCMD "/sbin/shutdown -h +0"
+            POWERDOWNFLAG /etc/killpower
+            POLLFREQ 15
+            POLLFREQALERT 5
+            HOSTSYNC 15
+        enabled: true
     controllers:
       network-ups-tools:
         containers:
           app:
             env:
               TZ: America/Edmonton
@@ -48,16 +77,15 @@

             configmap.reloader.stakater.com/reload: network-ups-tools-config
           nodeSelector:
             ups.feature.node.kubernetes.io/apc: 'true'
         strategy: RollingUpdate
     persistence:
       config:
-        enabled: true
+        defaultMode: 256
         globalMounts:
         - path: /etc/nut
-          readOnly: true
         name: network-ups-tools-config
         type: configMap
     service:
       app:
         annotations:
           external-dns.alpha.kubernetes.io/hostname: network-nut...PLACEHOLDER_SECRET_DOMAIN..
@@ -66,7 +94,31 @@

         externalTrafficPolicy: Cluster
         ports:
           http:
             port: 3493
             protocol: TCP
         type: LoadBalancer
+      metrics:
+        controller: network-ups-tools
+        enabled: true
+        ports:
+          metrics:
+            enabled: true
+            port: 9199
+            protocol: TCP
+    serviceMonitor:
+      app:
+        endpoints:
+        - interval: 15s
+          params:
+            target:
+            - localhost:3493
+          path: /ups_metrics
+          port: metrics
+          relabelings:
+          - sourceLabels:
+            - __param_target
+            targetLabel: target
+          scheme: http
+          scrapeTimeout: 10s
+        serviceName: network-ups-tools-metrics
 
--- kubernetes/utility/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools ConfigMap: observability/network-ups-tools-config

+++ kubernetes/utility/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools ConfigMap: observability/network-ups-tools-config

@@ -1,435 +0,0 @@

----
-apiVersion: v1
-data:
-  nut.conf: |
-    # Network UPS Tools: example nut.conf
-    #
-    ##############################################################################
-    # General section
-    ##############################################################################
-    # The MODE determines which part of the NUT is to be started, and which
-    # configuration files must be modified.
-    #
-    # This file try to standardize the various files being found in the field, like
-    # /etc/default/nut on Debian based systems, /etc/sysconfig/ups on RedHat based
-    # systems, ... Distribution's init script should source this file to see which
-    # component(s) has to be started.
-    #
-    # The values of MODE can be:
-    # - none: NUT is not configured, or use the Integrated Power Management, or use
-    #   some external system to startup NUT components. So nothing is to be started.
-    # - standalone: This mode address a local only configuration, with 1 UPS
-    #   protecting the local system. This implies to start the 3 NUT layers (driver,
-    #   upsd and upsmon) and the matching configuration files. This mode can also
-    #   address UPS redundancy.
-    # - netserver: same as for the standalone configuration, but also need
-    #   some more network access controls (firewall, tcp-wrappers) and possibly a
-    #   specific LISTEN directive in upsd.conf.
-    #   Since this MODE is opened to the network, a special care should be applied
-    #   to security concerns.
-    # - netclient: this mode only requires upsmon.
-    #
-    # IMPORTANT NOTE:
-    #  This file is intended to be sourced by standard POSIX shell scripts (so
-    #  there is no guaranteed `export VAR=VAL` syntax) and by systemd on Linux.
-    #  You MUST NOT use spaces around the equal sign!
-
-    MODE=netserver
-
-    # Uncomment this to allow starting the service even if ups.conf has no device
-    # sections at the moment. This environment variable overrides the built-in
-    # "false" and an optional same-named default flag that can be set in upsd.conf:
-    #ALLOW_NO_DEVICE=true
-    #export ALLOW_NO_DEVICE
-  ups.conf: |-
-    # Network UPS Tools: example ups.conf
-    #
-    # --- SECURITY NOTE ---
-    #
-    # If you use snmp-ups and set a community string in here, you
-    # will have to secure this file to keep other users from obtaining
-    # that string.  It needs to be readable by upsdrvctl and any drivers,
-    # and by upsd.
-    #
-    # ---
-    #
-    # This is where you configure all the UPSes that this system will be
-    # monitoring directly.  These are usually attached to serial ports, but
-    # USB devices and SNMP devices are also supported.
-    #
-    # This file is used by upsdrvctl to start and stop your driver(s), and
-    # is also used by upsd to determine which drivers to monitor.  The
-    # drivers themselves also read this file for configuration directives.
-    #
-    # The general form is:
-    #
-    # [upsname]
-    #       driver = <drivername>
-    #         port = <portname>
-    #       < any other directives here >
-    #
-    # The section header ([upsname]) can be just about anything as long as
-    # it is a single word inside brackets.  upsd uses this to uniquely
-    # identify a UPS on this system.
-    #
-    # If you have a UPS called snoopy, your section header would be "[snoopy]".
-    # On a system called "doghouse", the line in your upsmon.conf to monitor
-    # and manage it would look something like this:
-    #
-    #   MONITOR snoopy@doghouse 1 upsmonuser mypassword primary
-    #
-    # It might look like this if monitoring in "secondary" mode (without any
-    # ability to directly manage the UPS) from a different system:
-    #
-    #   MONITOR snoopy@doghouse 1 upsmonuser mypassword secondary
-    #
-    # Configuration directives
-    # ------------------------
-    #
-    # These directives are used by upsdrvctl only and should be specified outside
-    # of a driver definition:
-    #
-    #    maxretry: OPTIONAL.  Specify the number of attempts to start the driver(s),
-    #              in case of failure, before giving up. A delay of 'retrydelay' is
-    #              inserted between each attempt. Caution should be taken when using
-    #              this option, since it can impact the time taken by your system to
-    #              start.
-    #
-    #              The built-in default is 1 attempt.
-    #
-    #  retrydelay: OPTIONAL.  Specify the delay between each restart attempt of the
-    #              driver(s), as specified by 'maxretry'. Caution should be taken
-    #              when using this option, since it can impact the time taken by your
-    #              system to start.
-    #
-    #              The default is 5 seconds.
-    #
-    #      chroot: OPTIONAL. Used for securing. See man page for details.
-    #
-    #  driverpath: OPTIONAL. Used for custom setups. See man page for details.
-    #
-    #      nowait: OPTIONAL. Tell upsdrvctl to not wait at all for the driver(s)
-    #              to execute the requested command. Fire and forget.
-    #
-    # pollinterval: OPTIONAL. The status of the UPS will be refreshed after a
-    #              maximum delay which is controlled by this setting (default
-    #              2 seconds). This may be useful if the driver is creating too
-    #              much of a load on your system or network.
-    #              Note that some drivers also have an option called *pollfreq*
-    #              which controls how frequently some of the less critical
-    #              parameters are polled. See respective driver man pages.
-    #
-
-    # Set maxretry to 3 by default, this should mitigate race with slow devices:
-    maxretry = 3
-
-    # These directives can be set outside and inside a driver definition, with
-    # slightly different meanings per context:
-    #
-    # maxstartdelay: OPTIONAL.  This can be set as a global variable
-    #                above your first UPS definition and it can also be
-    #                set in a UPS section.  This value controls how long
-    #                upsdrvctl will wait for the driver to finish starting.
-    #                This keeps your system from getting stuck due to a
-    #                broken driver or UPS.
-    #                The default is 45 seconds.
-    #
-    #   debug_min: OPTIONAL.  Specify a minimum debug level for all driver daemons
-    #              (when specified at global level), or for this driver daemon
-    #              (when specified in a driver section), e.g. for troubleshooting
-    #              a deployment. This does not directly impact the foreground or
-    #              background running mode. If both the global and driver level
-    #              `debug_min` are set, the driver-level setting takes precedence.
-    #              Command-line option `-D` can only increase this verbosity level.
-    #
-    # user, group: OPTIONAL. Overrides the compiled-in (also global-section,
-    #                when used in driver section) default unprivileged user/group
-    #                name for NUT device driver. Impacts access rights used for
-    #                the socket file access (group) and communication ports (user).
-    #
-    # synchronous: OPTIONAL.  The driver work by default in asynchronous
-    #              mode (like *no*) with fallback to synchronous if sending
-    #              fails (i.e *synchronous=auto*).  This means that all data
-    #              are pushed by the driver on the communication socket to
-    #              upsd (Unix socket on Unix, Named pipe on Windows) without
-    #              waiting for these data to be actually consumed.  With
-    #              some HW, such as ePDUs, that can produce a lot of data,
-    #              asynchronous mode may cause some congestion, resulting in
-    #              the socket to be full, and the driver to appear as not
-    #              connected.  By enabling the 'synchronous' flag
-    #              (value = 'yes'), the driver will wait for data to be
-    #              consumed by upsd, prior to publishing more.  This can be
-    #              enabled either globally or per driver.
-    #
-    #              The default is 'no' (i.e. asynchronous mode) for backward
-    #              compatibility of the driver behavior.
-    #
-
-    # These directives are common to all drivers that support ups.conf:
-    #
-    #  driver: REQUIRED.  Specify the program to run to talk to this UPS.
-    #          apcsmart, bestups, and sec are some examples.
-    #
-    #    port: REQUIRED.  The serial port where your UPS is connected.
-    #          /dev/ttyS0 is usually the first port on Linux boxes, for example.
-    #
-    # sdorder: OPTIONAL.  When you have multiple UPSes on your system, you
-    #          usually need to turn them off in a certain order.  upsdrvctl
-    #          shuts down all the 0s, then the 1s, 2s, and so on.  To exclude
-    #          a UPS from the shutdown sequence, set this to -1.
-    #
-    #          The default value for this parameter is 0.
-    #
-    #    desc: optional, to keep a note of the UPS purpose, location, etc.
-    #
-    #  nolock: optional, and not recommended for use in this file.
-    #
-    #          If you put nolock in here, the driver will not lock the
-    #          serial port every time it starts.  This may allow other
-    #          processes to seize the port if you start more than one by
-    #          mistake.
-    #
-    #          This is only intended to be used on systems where locking
-    #          absolutely must be disabled for the software to work.
-    #
-    # ignorelb: OPTIONAL. Ignore low battery condition reported by device,
[Diff truncated by flux-local]
--- kubernetes/utility/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools PrometheusRule: observability/nut-exporter

+++ kubernetes/utility/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools PrometheusRule: observability/nut-exporter

@@ -0,0 +1,74 @@

+---
+apiVersion: monitoring.coreos.com/v1
+kind: PrometheusRule
+metadata:
+  labels:
+    app.kubernetes.io/name: network-ups-tools
+    kustomize.toolkit.fluxcd.io/name: network-ups-tools
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: nut-exporter
+  namespace: observability
+spec:
+  groups:
+  - name: nut-exporter
+    rules:
+    - alert: NutExporterAbsent
+      annotations:
+        description: NUT Exporter has disappeared from Prometheus target discovery.
+        summary: NUT Exporter is down.
+      expr: |
+        absent(up{job=~".*network-ups-tools.*"} == 1)
+      for: 5m
+      labels:
+        severity: critical
+    - alert: UpsOnBattery
+      annotations:
+        description: UPS {{ $labels.ups }} has lost power and is running on battery.
+        summary: UPS is running on battery.
+      expr: |
+        network_ups_tools_ups_status{flag="OB"} == 1
+      for: 10s
+      labels:
+        severity: critical
+    - alert: UpsLowRuntime
+      annotations:
+        description: UPS {{ $labels.instance }} battery is low and the system is getting
+          ready to shutdown.
+        summary: UPS battery is low.
+      expr: |
+        (
+          network_ups_tools_ups_status{flag="OB"} == 1
+        and
+          network_ups_tools_battery_runtime < 600
+        )
+      for: 1m
+      labels:
+        severity: critical
+    - alert: UpsShuttingDown
+      annotations:
+        description: UPS {{ $labels.ups }} battery is low and the system is getting
+          ready to shutdown.
+        summary: UPS battery is low.
+      expr: |
+        network_ups_tools_ups_status{flag="OB"} == 1
+      for: 5s
+      labels:
+        severity: critical
+    - alert: UpsLowBattery
+      annotations:
+        description: UPS {{ $labels.instance }} battery charge is {{ $value }} which
+          is below 50%.
+        summary: UPS battery low
+      expr: network_ups_tools_battery_charge < 50
+      labels:
+        severity: warning
+    - alert: UpsBatteryReplace
+      annotations:
+        description: UPS {{ $labels.ups }} battery needs to be replaced.
+        summary: Replace UPS battery.
+      expr: |
+        network_ups_tools_ups_status{flag="RB"} == 1
+      for: 10s
+      labels:
+        severity: critical
+

@smurf-bot
Copy link
Contributor

smurf-bot bot commented Nov 13, 2024

--- kubernetes/main/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools HelmRelease: observability/network-ups-tools

+++ kubernetes/main/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools HelmRelease: observability/network-ups-tools

@@ -24,12 +24,40 @@

   upgrade:
     cleanupOnFail: true
     remediation:
       retries: 3
       strategy: rollback
   values:
+    configMaps:
+      config:
+        data:
+          nut.conf: MODE=netserver
+          ups.conf: |-
+            [serverups]
+              driver = "usbhid-ups"
+              port = "auto"
+              desc = "TrippLite SMART1500LCD"
+              vendorid = "09AE"
+              productid = "2012"
+          upsd.conf: |-
+            MAXAGE 20
+            LISTEN 0.0.0.0
+          upsd.users: |-
+            [monuser]
+              password = "bacon"
+              actions = SET
+              instcmds = ALL
+              upsmon primary
+          upsmon.conf: |-
+            MONITOR ups@localhost:3493 1 upsmon "bacon" primary
+            SHUTDOWNCMD "/sbin/shutdown -h +0"
+            POWERDOWNFLAG /etc/killpower
+            POLLFREQ 15
+            POLLFREQALERT 5
+            HOSTSYNC 15
+        enabled: true
     controllers:
       network-ups-tools:
         containers:
           app:
             env:
               TZ: America/Edmonton
@@ -48,20 +76,43 @@

             configmap.reloader.stakater.com/reload: network-ups-tools-config
           nodeSelector:
             ups.feature.node.kubernetes.io/tripplite: 'true'
         strategy: RollingUpdate
     persistence:
       config:
-        enabled: true
+        defaultMode: 256
         globalMounts:
         - path: /etc/nut
-          readOnly: true
         name: network-ups-tools-config
         type: configMap
     service:
       app:
         controller: network-ups-tools
         ports:
           http:
             port: 3493
             protocol: TCP
+      metrics:
+        controller: network-ups-tools
+        enabled: true
+        ports:
+          metrics:
+            enabled: true
+            port: 9199
+            protocol: TCP
+    serviceMonitor:
+      app:
+        endpoints:
+        - interval: 15s
+          params:
+            target:
+            - localhost:3493
+          path: /ups_metrics
+          port: metrics
+          relabelings:
+          - sourceLabels:
+            - __param_target
+            targetLabel: target
+          scheme: http
+          scrapeTimeout: 10s
+        serviceName: nut-exporter-server
 
--- kubernetes/main/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools ConfigMap: observability/network-ups-tools-config

+++ kubernetes/main/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools ConfigMap: observability/network-ups-tools-config

@@ -1,434 +0,0 @@

----
-apiVersion: v1
-data:
-  nut.conf: |
-    # Network UPS Tools: example nut.conf
-    #
-    ##############################################################################
-    # General section
-    ##############################################################################
-    # The MODE determines which part of the NUT is to be started, and which
-    # configuration files must be modified.
-    #
-    # This file try to standardize the various files being found in the field, like
-    # /etc/default/nut on Debian based systems, /etc/sysconfig/ups on RedHat based
-    # systems, ... Distribution's init script should source this file to see which
-    # component(s) has to be started.
-    #
-    # The values of MODE can be:
-    # - none: NUT is not configured, or use the Integrated Power Management, or use
-    #   some external system to startup NUT components. So nothing is to be started.
-    # - standalone: This mode address a local only configuration, with 1 UPS
-    #   protecting the local system. This implies to start the 3 NUT layers (driver,
-    #   upsd and upsmon) and the matching configuration files. This mode can also
-    #   address UPS redundancy.
-    # - netserver: same as for the standalone configuration, but also need
-    #   some more network access controls (firewall, tcp-wrappers) and possibly a
-    #   specific LISTEN directive in upsd.conf.
-    #   Since this MODE is opened to the network, a special care should be applied
-    #   to security concerns.
-    # - netclient: this mode only requires upsmon.
-    #
-    # IMPORTANT NOTE:
-    #  This file is intended to be sourced by standard POSIX shell scripts (so
-    #  there is no guaranteed `export VAR=VAL` syntax) and by systemd on Linux.
-    #  You MUST NOT use spaces around the equal sign!
-
-    MODE=netserver
-
-    # Uncomment this to allow starting the service even if ups.conf has no device
-    # sections at the moment. This environment variable overrides the built-in
-    # "false" and an optional same-named default flag that can be set in upsd.conf:
-    #ALLOW_NO_DEVICE=true
-    #export ALLOW_NO_DEVICE
-  ups.conf: |
-    # Network UPS Tools: example ups.conf
-    #
-    # --- SECURITY NOTE ---
-    #
-    # If you use snmp-ups and set a community string in here, you
-    # will have to secure this file to keep other users from obtaining
-    # that string.  It needs to be readable by upsdrvctl and any drivers,
-    # and by upsd.
-    #
-    # ---
-    #
-    # This is where you configure all the UPSes that this system will be
-    # monitoring directly.  These are usually attached to serial ports, but
-    # USB devices and SNMP devices are also supported.
-    #
-    # This file is used by upsdrvctl to start and stop your driver(s), and
-    # is also used by upsd to determine which drivers to monitor.  The
-    # drivers themselves also read this file for configuration directives.
-    #
-    # The general form is:
-    #
-    # [upsname]
-    #       driver = <drivername>
-    #         port = <portname>
-    #       < any other directives here >
-    #
-    # The section header ([upsname]) can be just about anything as long as
-    # it is a single word inside brackets.  upsd uses this to uniquely
-    # identify a UPS on this system.
-    #
-    # If you have a UPS called snoopy, your section header would be "[snoopy]".
-    # On a system called "doghouse", the line in your upsmon.conf to monitor
-    # and manage it would look something like this:
-    #
-    #   MONITOR snoopy@doghouse 1 upsmonuser mypassword primary
-    #
-    # It might look like this if monitoring in "secondary" mode (without any
-    # ability to directly manage the UPS) from a different system:
-    #
-    #   MONITOR snoopy@doghouse 1 upsmonuser mypassword secondary
-    #
-    # Configuration directives
-    # ------------------------
-    #
-    # These directives are used by upsdrvctl only and should be specified outside
-    # of a driver definition:
-    #
-    #    maxretry: OPTIONAL.  Specify the number of attempts to start the driver(s),
-    #              in case of failure, before giving up. A delay of 'retrydelay' is
-    #              inserted between each attempt. Caution should be taken when using
-    #              this option, since it can impact the time taken by your system to
-    #              start.
-    #
-    #              The built-in default is 1 attempt.
-    #
-    #  retrydelay: OPTIONAL.  Specify the delay between each restart attempt of the
-    #              driver(s), as specified by 'maxretry'. Caution should be taken
-    #              when using this option, since it can impact the time taken by your
-    #              system to start.
-    #
-    #              The default is 5 seconds.
-    #
-    #      chroot: OPTIONAL. Used for securing. See man page for details.
-    #
-    #  driverpath: OPTIONAL. Used for custom setups. See man page for details.
-    #
-    #      nowait: OPTIONAL. Tell upsdrvctl to not wait at all for the driver(s)
-    #              to execute the requested command. Fire and forget.
-    #
-    # pollinterval: OPTIONAL. The status of the UPS will be refreshed after a
-    #              maximum delay which is controlled by this setting (default
-    #              2 seconds). This may be useful if the driver is creating too
-    #              much of a load on your system or network.
-    #              Note that some drivers also have an option called *pollfreq*
-    #              which controls how frequently some of the less critical
-    #              parameters are polled. See respective driver man pages.
-    #
-
-    # Set maxretry to 3 by default, this should mitigate race with slow devices:
-    maxretry = 3
-
-    # These directives can be set outside and inside a driver definition, with
-    # slightly different meanings per context:
-    #
-    # maxstartdelay: OPTIONAL.  This can be set as a global variable
-    #                above your first UPS definition and it can also be
-    #                set in a UPS section.  This value controls how long
-    #                upsdrvctl will wait for the driver to finish starting.
-    #                This keeps your system from getting stuck due to a
-    #                broken driver or UPS.
-    #                The default is 45 seconds.
-    #
-    #   debug_min: OPTIONAL.  Specify a minimum debug level for all driver daemons
-    #              (when specified at global level), or for this driver daemon
-    #              (when specified in a driver section), e.g. for troubleshooting
-    #              a deployment. This does not directly impact the foreground or
-    #              background running mode. If both the global and driver level
-    #              `debug_min` are set, the driver-level setting takes precedence.
-    #              Command-line option `-D` can only increase this verbosity level.
-    #
-    # user, group: OPTIONAL. Overrides the compiled-in (also global-section,
-    #                when used in driver section) default unprivileged user/group
-    #                name for NUT device driver. Impacts access rights used for
-    #                the socket file access (group) and communication ports (user).
-    #
-    # synchronous: OPTIONAL.  The driver work by default in asynchronous
-    #              mode (like *no*) with fallback to synchronous if sending
-    #              fails (i.e *synchronous=auto*).  This means that all data
-    #              are pushed by the driver on the communication socket to
-    #              upsd (Unix socket on Unix, Named pipe on Windows) without
-    #              waiting for these data to be actually consumed.  With
-    #              some HW, such as ePDUs, that can produce a lot of data,
-    #              asynchronous mode may cause some congestion, resulting in
-    #              the socket to be full, and the driver to appear as not
-    #              connected.  By enabling the 'synchronous' flag
-    #              (value = 'yes'), the driver will wait for data to be
-    #              consumed by upsd, prior to publishing more.  This can be
-    #              enabled either globally or per driver.
-    #
-    #              The default is 'no' (i.e. asynchronous mode) for backward
-    #              compatibility of the driver behavior.
-    #
-
-    # These directives are common to all drivers that support ups.conf:
-    #
-    #  driver: REQUIRED.  Specify the program to run to talk to this UPS.
-    #          apcsmart, bestups, and sec are some examples.
-    #
-    #    port: REQUIRED.  The serial port where your UPS is connected.
-    #          /dev/ttyS0 is usually the first port on Linux boxes, for example.
-    #
-    # sdorder: OPTIONAL.  When you have multiple UPSes on your system, you
-    #          usually need to turn them off in a certain order.  upsdrvctl
-    #          shuts down all the 0s, then the 1s, 2s, and so on.  To exclude
-    #          a UPS from the shutdown sequence, set this to -1.
-    #
-    #          The default value for this parameter is 0.
-    #
-    #    desc: optional, to keep a note of the UPS purpose, location, etc.
-    #
-    #  nolock: optional, and not recommended for use in this file.
-    #
-    #          If you put nolock in here, the driver will not lock the
-    #          serial port every time it starts.  This may allow other
-    #          processes to seize the port if you start more than one by
-    #          mistake.
-    #
-    #          This is only intended to be used on systems where locking
-    #          absolutely must be disabled for the software to work.
-    #
-    # ignorelb: OPTIONAL. Ignore low battery condition reported by device,
[Diff truncated by flux-local]
--- kubernetes/main/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools PrometheusRule: observability/nut-exporter

+++ kubernetes/main/apps/observability/network-ups-tools/app Kustomization: flux-system/network-ups-tools PrometheusRule: observability/nut-exporter

@@ -0,0 +1,74 @@

+---
+apiVersion: monitoring.coreos.com/v1
+kind: PrometheusRule
+metadata:
+  labels:
+    app.kubernetes.io/name: network-ups-tools
+    kustomize.toolkit.fluxcd.io/name: network-ups-tools
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: nut-exporter
+  namespace: observability
+spec:
+  groups:
+  - name: nut-exporter
+    rules:
+    - alert: NutExporterAbsent
+      annotations:
+        description: NUT Exporter has disappeared from Prometheus target discovery.
+        summary: NUT Exporter is down.
+      expr: |
+        absent(up{job=~".*network-ups-tools.*"} == 1)
+      for: 5m
+      labels:
+        severity: critical
+    - alert: UpsOnBattery
+      annotations:
+        description: UPS {{ $labels.ups }} has lost power and is running on battery.
+        summary: UPS is running on battery.
+      expr: |
+        network_ups_tools_ups_status{flag="OB"} == 1
+      for: 10s
+      labels:
+        severity: critical
+    - alert: UpsLowRuntime
+      annotations:
+        description: UPS {{ $labels.instance }} battery is low and the system is getting
+          ready to shutdown.
+        summary: UPS battery is low.
+      expr: |
+        (
+          network_ups_tools_ups_status{flag="OB"} == 1
+        and
+          network_ups_tools_battery_runtime < 600
+        )
+      for: 1m
+      labels:
+        severity: critical
+    - alert: UpsShuttingDown
+      annotations:
+        description: UPS {{ $labels.ups }} battery is low and the system is getting
+          ready to shutdown.
+        summary: UPS battery is low.
+      expr: |
+        network_ups_tools_ups_status{flag="OB"} == 1
+      for: 5s
+      labels:
+        severity: critical
+    - alert: UpsLowBattery
+      annotations:
+        description: UPS {{ $labels.instance }} battery charge is {{ $value }} which
+          is below 50%.
+        summary: UPS battery low
+      expr: network_ups_tools_battery_charge < 50
+      labels:
+        severity: warning
+    - alert: UpsBatteryReplace
+      annotations:
+        description: UPS {{ $labels.ups }} battery needs to be replaced.
+        summary: Replace UPS battery.
+      expr: |
+        network_ups_tools_ups_status{flag="RB"} == 1
+      for: 10s
+      labels:
+        severity: critical
+
--- kubernetes/main/apps/observability/exporters/nut-exporter/app Kustomization: flux-system/nut-exporter PrometheusRule: observability/nut-exporter

+++ kubernetes/main/apps/observability/exporters/nut-exporter/app Kustomization: flux-system/nut-exporter PrometheusRule: observability/nut-exporter

@@ -1,63 +0,0 @@

----
-apiVersion: monitoring.coreos.com/v1
-kind: PrometheusRule
-metadata:
-  labels:
-    app.kubernetes.io/name: nut-exporter
-    kustomize.toolkit.fluxcd.io/name: nut-exporter
-    kustomize.toolkit.fluxcd.io/namespace: flux-system
-  name: nut-exporter
-  namespace: observability
-spec:
-  groups:
-  - name: nut-exporter.rules
-    rules:
-    - alert: NutExporterAbsent
-      annotations:
-        description: NUT exporter has disappeared from Prometheus target discovery.
-        summary: NUT Exporter is down.
-      expr: |
-        absent(up{job=~".*nut-exporter.*"} == 1)
-      for: 5m
-      labels:
-        severity: critical
-    - alert: UpsOnBattery
-      annotations:
-        description: ZPM {{ $labels.instance }} has lost power and is running on battery.
-        summary: ZPM is running on battery.
-      expr: network_ups_tools_ups_status{flag="OB"} == 1
-      for: 10s
-      labels:
-        severity: warning
-    - alert: UpsLowRuntime
-      annotations:
-        description: ZPM {{ $labels.instance }} battery is low and the system is getting
-          ready to shutdown.
-        summary: ZPM battery is low.
-      expr: |
-        (
-          network_ups_tools_ups_status{flag="OB"} == 1
-        and
-          network_ups_tools_battery_runtime < 600
-        )
-      for: 1m
-      labels:
-        severity: critical
-    - alert: UpsLowBattery
-      annotations:
-        description: ZPM {{ $labels.instance }} battery charge is {{ $value }} which
-          is below 50%.
-        summary: ZPM battery low
-      expr: network_ups_tools_battery_charge < 50
-      labels:
-        severity: warning
-    - alert: UpsBatteryReplace
-      annotations:
-        description: UPS {{ $labels.ups }} battery needs to be replaced.
-        summary: Replace UPS battery.
-      expr: |
-        network_ups_tools_ups_status{flag="RB"} == 1
-      for: 10s
-      labels:
-        severity: warning
-
--- kubernetes/main/apps/observability/exporters/nut-exporter/app Kustomization: flux-system/nut-exporter ServiceMonitor: observability/nut-exporter-server

+++ kubernetes/main/apps/observability/exporters/nut-exporter/app Kustomization: flux-system/nut-exporter ServiceMonitor: observability/nut-exporter-server

@@ -1,45 +0,0 @@

----
-apiVersion: monitoring.coreos.com/v1
-kind: ServiceMonitor
-metadata:
-  labels:
-    app.kubernetes.io/component: metrics
-    app.kubernetes.io/instance: servers
-    app.kubernetes.io/name: nut-exporter
-    kustomize.toolkit.fluxcd.io/name: nut-exporter
-    kustomize.toolkit.fluxcd.io/namespace: flux-system
-    prometheus: kube-prometheus
-  name: nut-exporter-server
-  namespace: observability
-spec:
-  endpoints:
-  - interval: 30s
-    metricRelabelings:
-    - action: replace
-      replacement: server
-      sourceLabels:
-      - instance
-      targetLabel: instance
-    - action: replace
-      replacement: server
-      sourceLabels:
-      - server
-      targetLabel: server
-    - action: labeldrop
-      regex: (pod)
-    params:
-      server:
-      - network-ups-tools.observability
-    path: /ups_metrics
-    port: metrics
-    scheme: http
-    scrapeTimeout: 30s
-  jobLabel: nut-exporter
-  namespaceSelector:
-    matchNames:
-    - observability
-  selector:
-    matchLabels:
-      app.kubernetes.io/instance: nut-exporter
-      app.kubernetes.io/name: nut-exporter
-

@smurf-bot
Copy link
Contributor

smurf-bot bot commented Nov 13, 2024

--- HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools

+++ HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools

@@ -1,22 +0,0 @@

----
-apiVersion: v1
-kind: Service
-metadata:
-  name: network-ups-tools
-  labels:
-    app.kubernetes.io/instance: network-ups-tools
-    app.kubernetes.io/managed-by: Helm
-    app.kubernetes.io/name: network-ups-tools
-    app.kubernetes.io/service: network-ups-tools
-spec:
-  type: ClusterIP
-  ports:
-  - port: 3493
-    targetPort: 3493
-    protocol: TCP
-    name: http
-  selector:
-    app.kubernetes.io/component: network-ups-tools
-    app.kubernetes.io/instance: network-ups-tools
-    app.kubernetes.io/name: network-ups-tools
-
--- HelmRelease: observability/network-ups-tools Deployment: observability/network-ups-tools

+++ HelmRelease: observability/network-ups-tools Deployment: observability/network-ups-tools

@@ -18,12 +18,13 @@

       app.kubernetes.io/component: network-ups-tools
       app.kubernetes.io/name: network-ups-tools
       app.kubernetes.io/instance: network-ups-tools
   template:
     metadata:
       annotations:
+        checksum/configMaps: 366e1fed8945e879bbc479d4341cbe04668c4bbd52bf243c1189648e10dec890
         configmap.reloader.stakater.com/reload: network-ups-tools-config
       labels:
         app.kubernetes.io/component: network-ups-tools
         app.kubernetes.io/instance: network-ups-tools
         app.kubernetes.io/name: network-ups-tools
     spec:
@@ -51,19 +52,19 @@

         name: app
         readinessProbe:
           failureThreshold: 3
           initialDelaySeconds: 0
           periodSeconds: 10
           tcpSocket:
-            port: 3493
+            port: 9199
           timeoutSeconds: 1
         securityContext:
           privileged: true
         volumeMounts:
         - mountPath: /etc/nut
           name: config
-          readOnly: true
       volumes:
       - configMap:
+          defaultMode: 256
           name: network-ups-tools-config
         name: config
 
--- HelmRelease: observability/network-ups-tools ConfigMap: observability/network-ups-tools-config

+++ HelmRelease: observability/network-ups-tools ConfigMap: observability/network-ups-tools-config

@@ -0,0 +1,35 @@

+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: network-ups-tools-config
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+data:
+  nut.conf: MODE=netserver
+  ups.conf: |-
+    [serverups]
+      driver = "usbhid-ups"
+      port = "auto"
+      desc = "TrippLite SMART1500LCD"
+      vendorid = "09AE"
+      productid = "2012"
+  upsd.conf: |-
+    MAXAGE 20
+    LISTEN 0.0.0.0
+  upsd.users: |-
+    [monuser]
+      password = "bacon"
+      actions = SET
+      instcmds = ALL
+      upsmon primary
+  upsmon.conf: |-
+    MONITOR ups@localhost:3493 1 upsmon "bacon" primary
+    SHUTDOWNCMD "/sbin/shutdown -h +0"
+    POWERDOWNFLAG /etc/killpower
+    POLLFREQ 15
+    POLLFREQALERT 5
+    HOSTSYNC 15
+
--- HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-app

+++ HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-app

@@ -0,0 +1,22 @@

+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: network-ups-tools-app
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+    app.kubernetes.io/service: network-ups-tools-app
+spec:
+  type: ClusterIP
+  ports:
+  - port: 3493
+    targetPort: 3493
+    protocol: TCP
+    name: http
+  selector:
+    app.kubernetes.io/component: network-ups-tools
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/name: network-ups-tools
+
--- HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-metrics

+++ HelmRelease: observability/network-ups-tools Service: observability/network-ups-tools-metrics

@@ -0,0 +1,22 @@

+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: network-ups-tools-metrics
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+    app.kubernetes.io/service: network-ups-tools-metrics
+spec:
+  type: ClusterIP
+  ports:
+  - port: 9199
+    targetPort: 9199
+    protocol: TCP
+    name: metrics
+  selector:
+    app.kubernetes.io/component: network-ups-tools
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/name: network-ups-tools
+
--- HelmRelease: observability/network-ups-tools ServiceMonitor: observability/network-ups-tools

+++ HelmRelease: observability/network-ups-tools ServiceMonitor: observability/network-ups-tools

@@ -0,0 +1,33 @@

+---
+apiVersion: monitoring.coreos.com/v1
+kind: ServiceMonitor
+metadata:
+  name: network-ups-tools
+  labels:
+    app.kubernetes.io/instance: network-ups-tools
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: network-ups-tools
+spec:
+  jobLabel: network-ups-tools
+  namespaceSelector:
+    matchNames:
+    - observability
+  selector:
+    matchLabels:
+      app.kubernetes.io/service: nut-exporter-server
+      app.kubernetes.io/name: network-ups-tools
+      app.kubernetes.io/instance: network-ups-tools
+  endpoints:
+  - interval: 15s
+    params:
+      target:
+      - localhost:3493
+    path: /ups_metrics
+    port: metrics
+    relabelings:
+    - sourceLabels:
+      - __param_target
+      targetLabel: target
+    scheme: http
+    scrapeTimeout: 10s
+

@joryirving joryirving merged commit d2eeb98 into main Nov 13, 2024
13 checks passed
@joryirving joryirving deleted the feat/nut-update branch November 13, 2024 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes Changes made in the kubernetes directory cluster/main cluster/utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant