generated from onedr0p/cluster-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
kubernetes/apps/observability/nut-exporter/app/externalsecret.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/external-secrets.io/externalsecret_v1beta1.json | ||
apiVersion: external-secrets.io/v1beta1 | ||
kind: ExternalSecret | ||
metadata: | ||
name: nut-exporter | ||
spec: | ||
secretStoreRef: | ||
kind: ClusterSecretStore | ||
name: onepassword | ||
target: | ||
name: nut-exporter-secret | ||
template: | ||
data: | ||
NUT_EXPORTER_USERNAME: "{{ .username }}" | ||
NUT_EXPORTER_PASSWORD: "{{ .password }}" | ||
dataFrom: | ||
- extract: | ||
key: nut-exporter |
62 changes: 62 additions & 0 deletions
62
kubernetes/apps/observability/nut-exporter/app/helmrelease.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/main/charts/other/app-template/schemas/helmrelease-helm-v2.schema.json | ||
apiVersion: helm.toolkit.fluxcd.io/v2 | ||
kind: HelmRelease | ||
metadata: | ||
name: nut-exporter | ||
spec: | ||
interval: 30m | ||
chart: | ||
spec: | ||
chart: app-template | ||
version: 3.4.0 | ||
sourceRef: | ||
kind: HelmRepository | ||
name: bjw-s | ||
namespace: flux-system | ||
driftDetection: | ||
mode: enabled | ||
install: | ||
remediation: | ||
retries: 3 | ||
upgrade: | ||
cleanupOnFail: true | ||
remediation: | ||
strategy: rollback | ||
retries: 3 | ||
values: | ||
controllers: | ||
nut-exporter: | ||
annotations: | ||
reloader.stakater.com/auto: "true" | ||
containers: | ||
nut-exporter: | ||
image: | ||
repository: ghcr.io/druggeri/nut_exporter | ||
tag: 3.1.1 | ||
args: | ||
# the first time I set this, the first and last entries were ignored, so I have doubled them. | ||
- --nut.vars_enable="battery.charge,battery.charge,battery.runtime,battery.voltage,battery.voltage.nominal,input.voltage,input.voltage.nominal,output.voltage,output.voltage.nominal,ups.realpower,ups.load,ups.status,ups.status" | ||
env: | ||
TZ: America/Los_Angeles | ||
envFrom: | ||
- secretRef: | ||
name: nut-exporter-secret | ||
resources: | ||
requests: | ||
cpu: 1m | ||
limits: | ||
memory: 100Mi | ||
service: | ||
app: | ||
controller: nut-exporter | ||
ports: | ||
metrics: | ||
protocol: TCP | ||
port: 9199 | ||
ipFamilyPolicy: PreferDualStack | ||
serviceMonitor: | ||
app: | ||
serviceName: nut-exporter | ||
endpoints: | ||
- name: metrics |
9 changes: 9 additions & 0 deletions
9
kubernetes/apps/observability/nut-exporter/app/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
# yaml-language-server: $schema=https://json.schemastore.org/kustomization | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ./externalsecret.yaml | ||
- ./helmrelease.yaml | ||
- ./prometheusrule.yaml | ||
- ./servicemonitor.yaml |
60 changes: 60 additions & 0 deletions
60
kubernetes/apps/observability/nut-exporter/app/prometheusrule.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/monitoring.coreos.com/prometheusrule_v1.json | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PrometheusRule | ||
metadata: | ||
labels: | ||
app.kubernetes.io/component: nut-exporter | ||
app.kubernetes.io/instance: nut-exporter | ||
app.kubernetes.io/name: nut-exporter | ||
name: nut-exporter | ||
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: "{{ $labels.instance }} has lost power and is running on battery." | ||
summary: is running on battery. | ||
expr: network_ups_tools_ups_status{flag="OB"} == 1 | ||
for: 10s | ||
labels: | ||
severity: warning | ||
- alert: UpsLowRuntime | ||
annotations: | ||
description: "{{ $labels.instance }} battery is low and the system is getting ready to shutdown." | ||
summary: 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 | ||
expr: network_ups_tools_battery_charge < 50 | ||
labels: | ||
severity: warning | ||
annotations: | ||
description: "{{ $labels.instance }} battery charge is {{ $value }} which is below 50%." | ||
summary: battery low | ||
- 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 |
82 changes: 82 additions & 0 deletions
82
kubernetes/apps/observability/nut-exporter/app/servicemonitor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/monitoring.coreos.com/servicemonitor_v1.json | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
labels: | ||
app.kubernetes.io/component: nut-exporter | ||
app.kubernetes.io/instance: homeassistant | ||
app.kubernetes.io/name: nut-exporter | ||
name: nut-exporter-homeassistant | ||
spec: | ||
endpoints: | ||
- interval: 30s | ||
metricRelabelings: | ||
- action: replace | ||
replacement: homeassistant | ||
sourceLabels: | ||
- instance | ||
targetLabel: instance | ||
- action: replace | ||
replacement: homeassistant.flat | ||
sourceLabels: | ||
- server | ||
targetLabel: server | ||
- action: labeldrop | ||
regex: (pod) | ||
params: | ||
server: | ||
- homeassistant.flat | ||
path: /ups_metrics | ||
port: metrics | ||
scheme: http | ||
scrapeTimeout: 30s | ||
jobLabel: app.kubernetes.io/instance | ||
namespaceSelector: | ||
matchNames: | ||
- observability | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/instance: nut-exporter | ||
app.kubernetes.io/name: nut-exporter | ||
--- | ||
# yaml-language-server: $schema=https://kubernetes-schemas.pages.dev/monitoring.coreos.com/servicemonitor_v1.json | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
labels: | ||
app.kubernetes.io/component: nut-exporter | ||
app.kubernetes.io/instance: pikvm | ||
app.kubernetes.io/name: nut-exporter | ||
name: nut-exporter-pikvm | ||
spec: | ||
endpoints: | ||
- interval: 30s | ||
metricRelabelings: | ||
- action: replace | ||
replacement: pikvm | ||
sourceLabels: | ||
- instance | ||
targetLabel: instance | ||
- action: replace | ||
replacement: pikvm.flat | ||
sourceLabels: | ||
- server | ||
targetLabel: server | ||
- action: labeldrop | ||
regex: (pod) | ||
params: | ||
server: | ||
- pikvm.flat | ||
path: /ups_metrics | ||
port: metrics | ||
scheme: http | ||
scrapeTimeout: 30s | ||
jobLabel: app.kubernetes.io/instance | ||
namespaceSelector: | ||
matchNames: | ||
- observability | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/instance: nut-exporter | ||
app.kubernetes.io/name: nut-exporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json | ||
apiVersion: kustomize.toolkit.fluxcd.io/v1 | ||
kind: Kustomization | ||
metadata: | ||
name: &app nut-exporter | ||
namespace: flux-system | ||
spec: | ||
targetNamespace: observability | ||
commonMetadata: | ||
labels: | ||
app.kubernetes.io/name: *app | ||
dependsOn: | ||
- name: external-secrets-stores | ||
path: ./kubernetes/apps/observability/nut-exporter/app | ||
prune: true | ||
sourceRef: | ||
kind: GitRepository | ||
name: home-kubernetes | ||
wait: false | ||
interval: 30m | ||
retryInterval: 1m | ||
timeout: 5m |