From 1d0cce4146d9aa8dd68809e00a1874372db866e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= <6213398+bjw-s@users.noreply.github.com> Date: Thu, 24 Dec 2020 12:51:18 +0100 Subject: [PATCH] [network-ups-tools] New chart (#431) --- charts/network-ups-tools/.helmignore | 24 +++++++ charts/network-ups-tools/Chart.yaml | 20 ++++++ charts/network-ups-tools/OWNERS | 8 +++ charts/network-ups-tools/README.md | 67 +++++++++++++++++++ charts/network-ups-tools/ci/ct-values.yaml | 4 ++ charts/network-ups-tools/templates/NOTES.txt | 1 + .../network-ups-tools/templates/common.yaml | 36 ++++++++++ .../templates/configmap.yaml | 19 ++++++ charts/network-ups-tools/values.yaml | 37 ++++++++++ 9 files changed, 216 insertions(+) create mode 100644 charts/network-ups-tools/.helmignore create mode 100644 charts/network-ups-tools/Chart.yaml create mode 100644 charts/network-ups-tools/OWNERS create mode 100644 charts/network-ups-tools/README.md create mode 100644 charts/network-ups-tools/ci/ct-values.yaml create mode 100644 charts/network-ups-tools/templates/NOTES.txt create mode 100644 charts/network-ups-tools/templates/common.yaml create mode 100644 charts/network-ups-tools/templates/configmap.yaml create mode 100644 charts/network-ups-tools/values.yaml diff --git a/charts/network-ups-tools/.helmignore b/charts/network-ups-tools/.helmignore new file mode 100644 index 00000000..fcf9212f --- /dev/null +++ b/charts/network-ups-tools/.helmignore @@ -0,0 +1,24 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode +# OWNERS file for Kubernetes +OWNERS diff --git a/charts/network-ups-tools/Chart.yaml b/charts/network-ups-tools/Chart.yaml new file mode 100644 index 00000000..ce705b75 --- /dev/null +++ b/charts/network-ups-tools/Chart.yaml @@ -0,0 +1,20 @@ +apiVersion: v2 +appVersion: v2.7.4-2061-g46c7da76 +description: Network UPS Tools is a collection of programs which provide a common interface for monitoring and administering UPS, PDU and SCD hardware. +name: network-ups-tools +version: 1.0.0 +keywords: + - nut + - network-ups-tools + - ups +home: https://github.com/k8s-at-home/charts/tree/master/charts/network-ups-tools +icon: https://avatars0.githubusercontent.com/u/3526263?s=400&v=4 +sources: + - https://github.com/networkupstools/nut +maintainers: + - name: billimek + email: jeff@billimek.com +dependencies: + - name: common + repository: https://k8s-at-home.com/charts/ + version: 2.1.1 diff --git a/charts/network-ups-tools/OWNERS b/charts/network-ups-tools/OWNERS new file mode 100644 index 00000000..1ce35762 --- /dev/null +++ b/charts/network-ups-tools/OWNERS @@ -0,0 +1,8 @@ +approvers: +- billimek +- onedr0p +- bjw-s +reviewers: +- billimek +- onedr0p +- bjw-s diff --git a/charts/network-ups-tools/README.md b/charts/network-ups-tools/README.md new file mode 100644 index 00000000..ae3ed427 --- /dev/null +++ b/charts/network-ups-tools/README.md @@ -0,0 +1,67 @@ +# network-ups-tools + +This is a helm chart for [network-ups-tools](https://github.com/networkupstools/nut). + +**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)** + +## TL;DR; + +```shell +$ helm repo add k8s-at-home https://k8s-at-home.com/charts/ +$ helm install k8s-at-home/network-ups-tools +``` + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +helm install --name my-release k8s-at-home/network-ups-tools +``` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +helm delete my-release --purge +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration +Read through the charts [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/network-ups-tools/values.yaml) +file. It has several commented out suggested values. +Additionally you can take a look at the common library [values.yaml](https://github.com/k8s-at-home/charts/blob/master/charts/common/values.yaml) for more (advanced) configuration options. + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, +```console +helm install network-ups-tools \ + --set env.TZ="America/New_York" \ + k8s-at-home/network-ups-tools +``` +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the +chart. For example, +```console +helm install network-ups-tools k8s-at-home/network-ups-tools --values values.yaml +``` + +```yaml +image: + tag: ... +``` + +--- +**NOTE** + +If you get +```console +Error: rendered manifests contain a resource that already exists. Unable to continue with install: existing resource conflict: ...` +``` +it may be because you uninstalled the chart with `skipuninstall` enabled, you need to manually delete the pvc or use `existingClaim`. + +--- + +## Upgrading an existing Release to a new major version + +A major chart version change (like 4.0.1 -> 5.0.0) indicates that there is an incompatible breaking change potentially needing manual actions. diff --git a/charts/network-ups-tools/ci/ct-values.yaml b/charts/network-ups-tools/ci/ct-values.yaml new file mode 100644 index 00000000..cc7f6185 --- /dev/null +++ b/charts/network-ups-tools/ci/ct-values.yaml @@ -0,0 +1,4 @@ +config: + files: + dummy-ups.dev: | + ups.status: OL diff --git a/charts/network-ups-tools/templates/NOTES.txt b/charts/network-ups-tools/templates/NOTES.txt new file mode 100644 index 00000000..90f7b653 --- /dev/null +++ b/charts/network-ups-tools/templates/NOTES.txt @@ -0,0 +1 @@ +{{- include "common.notes.defaultNotes" . -}} diff --git a/charts/network-ups-tools/templates/common.yaml b/charts/network-ups-tools/templates/common.yaml new file mode 100644 index 00000000..89a2009f --- /dev/null +++ b/charts/network-ups-tools/templates/common.yaml @@ -0,0 +1,36 @@ +{{/* Make sure all variables are set properly */}} +{{- include "common.values.setup" . }} + +{{/* Append the configMap to the additionalVolumes */}} +{{- define "network-ups-tools.configmap.volume" -}} +name: nut-config +configMap: + name: {{ template "common.names.fullname" . }}-config + defaultMode: 256 + optional: true +{{- end -}} + +{{- if eq .Values.config.mode "values" -}} + {{- $volume := include "network-ups-tools.configmap.volume" . | fromYaml -}} + {{- if $volume -}} + {{- $additionalVolumes := append .Values.additionalVolumes $volume }} + {{- $_ := set .Values "additionalVolumes" (deepCopy $additionalVolumes) -}} + {{- end -}} +{{- end -}} + +{{/* Append the configMap volume to the additionalVolumeMounts */}} +{{- define "network-ups-tools.configmap.volumeMount" -}} +name: nut-config +mountPath: /etc/nut +{{- end -}} + +{{- if eq .Values.config.mode "values" -}} + {{- $volumeMount := include "network-ups-tools.configmap.volumeMount" . | fromYaml -}} + {{- if $volumeMount -}} + {{- $additionalVolumeMounts := append .Values.additionalVolumeMounts $volumeMount }} + {{- $_ := set .Values "additionalVolumeMounts" (deepCopy $additionalVolumeMounts) -}} + {{- end -}} +{{- end -}} + +{{/* Render the templates */}} +{{ include "common.all" . }} diff --git a/charts/network-ups-tools/templates/configmap.yaml b/charts/network-ups-tools/templates/configmap.yaml new file mode 100644 index 00000000..e100dbc6 --- /dev/null +++ b/charts/network-ups-tools/templates/configmap.yaml @@ -0,0 +1,19 @@ +{{- if eq .Values.config.mode "values" -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "common.names.fullname" . }}-config + labels: + {{- include "common.labels" . | nindent 4 }} +data: + {{- range $file, $content := .Values.config.files }} + {{ $file }}: |- + {{- $content | nindent 4}} + {{- end }} + + {{- /* upsd.users is a required file, but can be empty */}} + {{- if not (hasKey .Values.config.files "upsd.users") }} + upsd.users: |- + # Required file, empty by default + {{- end }} +{{- end }} diff --git a/charts/network-ups-tools/values.yaml b/charts/network-ups-tools/values.yaml new file mode 100644 index 00000000..290b3c3f --- /dev/null +++ b/charts/network-ups-tools/values.yaml @@ -0,0 +1,37 @@ +# Default values for network-ups-tools. + +image: + repository: k8sathome/network-ups-tools + tag: v2.7.4-2061-g46c7da76 + pullPolicy: IfNotPresent + +strategy: + type: Recreate + +service: + port: + name: server + port: 3493 + +env: {} + # TZ: UTC + +# The main configuration files for network-ups-tools +config: + # If set to 'values', the configuration will be read from these values. + # Otherwise you have to mount a volume to /etc/nut containing the configuration files. + mode: values + + # See https://github.com/networkupstools/nut/tree/master/conf for config sample files + files: + nut.conf: | + MODE=netserver + + upsd.conf: | + LISTEN 0.0.0.0 + + ups.conf: | + [dummy] + driver = dummy-ups + port = dummy-ups.dev + desc = "dummy-ups in dummy mode"