From c2a547db04ec185d5236ff8757e2276c64f608e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?n=CE=B9c=D0=BDola=D1=95=20w=CE=B9lde?= Date: Sun, 25 Apr 2021 08:00:43 -0700 Subject: [PATCH] [modem-stats] migrate to common (#823) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [modem-stats] migrate to common Signed-off-by: Nicholas Wilde * Added influxdb dependency Signed-off-by: Nicholas Wilde * Removed influxdb dependency Signed-off-by: Nicholas Wilde Co-authored-by: ᗪєνιη ᗷυнʟ --- charts/stable/modem-stats/Chart.yaml | 18 +++-- charts/stable/modem-stats/README.md | 44 ++++++---- .../modem-stats/README_CHANGELOG.md.gotmpl | 15 ++++ charts/stable/modem-stats/templates/NOTES.txt | 8 +- .../stable/modem-stats/templates/_helpers.tpl | 27 ------- .../stable/modem-stats/templates/common.yaml | 32 ++++++++ .../modem-stats/templates/configmap.yaml | 29 +------ .../modem-stats/templates/deployment.yaml | 49 ------------ charts/stable/modem-stats/values.yaml | 80 +++++++++---------- 9 files changed, 129 insertions(+), 173 deletions(-) delete mode 100644 charts/stable/modem-stats/templates/_helpers.tpl create mode 100644 charts/stable/modem-stats/templates/common.yaml delete mode 100644 charts/stable/modem-stats/templates/deployment.yaml diff --git a/charts/stable/modem-stats/Chart.yaml b/charts/stable/modem-stats/Chart.yaml index 44762b7f..022e1adb 100644 --- a/charts/stable/modem-stats/Chart.yaml +++ b/charts/stable/modem-stats/Chart.yaml @@ -1,16 +1,20 @@ apiVersion: v2 name: modem-stats -version: 3.0.3 +version: 4.0.0 appVersion: 1.0.0 description: periodic cable modem data collection and save the results to InfluxDB keywords: -- sb6183 -- influxdb + - sb6183 + - influxdb home: https://github.com/k8s-at-home/charts/tree/master/charts/stable/modem-stats icon: https://i.imgur.com/NprLyFf.png sources: -- https://github.com/k8s-at-home/SB6183-stats-for-influxdb -- https://github.com/k8s-at-home/charts + - https://github.com/k8s-at-home/SB6183-stats-for-influxdb + - https://github.com/k8s-at-home/charts maintainers: -- name: billimek - email: jeff@billimek.com + - name: billimek + email: jeff@billimek.com +dependencies: + - name: common + repository: https://library-charts.k8s-at-home.com + version: 2.3.1 diff --git a/charts/stable/modem-stats/README.md b/charts/stable/modem-stats/README.md index 986402e3..ff80be44 100644 --- a/charts/stable/modem-stats/README.md +++ b/charts/stable/modem-stats/README.md @@ -1,6 +1,6 @@ # modem-stats -![Version: 3.0.3](https://img.shields.io/badge/Version-3.0.3-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) +![Version: 4.0.0](https://img.shields.io/badge/Version-4.0.0-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) periodic cable modem data collection and save the results to InfluxDB @@ -17,6 +17,7 @@ periodic cable modem data collection and save the results to InfluxDB | Repository | Name | Version | |------------|------|---------| +| https://library-charts.k8s-at-home.com | common | 2.3.1 | ## TL;DR @@ -75,20 +76,16 @@ The configuration is set as a block of text through a configmap and mouted as a | Key | Type | Default | Description | |-----|------|---------|-------------| -| config.delay | int | `3600` | how many seconds to wait between checks | -| config.influxdb.database | string | `"cable_modem_stats"` | InfluxDB database | -| config.influxdb.host | string | `"influxdb-influxdb"` | InfluxDB hostname | -| config.influxdb.port | int | `8086` | InfluxDB port | -| config.influxdb.ssl | bool | `false` | InfluxDB connection using SSL | -| config.modem.url | string | `"http://192.168.100.1/RgConnect.asp"` | sb6183 stats URL page | -| debug | bool | `false` | Display debugging output | -| image.pullPolicy | string | `"IfNotPresent"` | modem-stats image pull policy | -| image.repository | string | `"billimek/sb6183-for-influxdb"` | modem-stats image | -| image.tag | string | `"latest"` | modem-stats image tag | -| nodeSelector | object | `{}` | | -| podAnnotations | object | `{}` | Key-value pairs to add as pod annotations | -| replicaCount | int | `1` | | -| resources | object | `{}` | | +| config | string | string | modem-stats' config.ini configuration | +| env | object | `{}` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"billimek/sb6183-for-influxdb"` | | +| image.tag | string | `"latest"` | | +| probes.liveness.enabled | bool | `false` | | +| probes.readiness.enabled | bool | `false` | | +| probes.startup.enabled | bool | `false` | | +| service.enabled | bool | `false` | | +| strategy.type | string | `"Recreate"` | | ## Changelog @@ -96,6 +93,20 @@ All notable changes to this application Helm chart will be documented in this fi The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### [4.0.0] + +#### Added + +- N/A + +#### Changed + +- **BREAKING** Migrate to the common library, a lot of configuration has changed. + +#### Removed + +- N/A + ### [3.0.1] #### Added @@ -110,6 +121,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - N/A +[4.0.0]: #4.0.0 [3.0.1]: #3.0.1 ## Support @@ -120,4 +132,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Join our [Discord](https://discord.gg/sTMX7Vh) community ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) \ No newline at end of file diff --git a/charts/stable/modem-stats/README_CHANGELOG.md.gotmpl b/charts/stable/modem-stats/README_CHANGELOG.md.gotmpl index f46f4447..cf8294e8 100644 --- a/charts/stable/modem-stats/README_CHANGELOG.md.gotmpl +++ b/charts/stable/modem-stats/README_CHANGELOG.md.gotmpl @@ -9,6 +9,20 @@ All notable changes to this application Helm chart will be documented in this fi The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### [4.0.0] + +#### Added + +- N/A + +#### Changed + +- **BREAKING** Migrate to the common library, a lot of configuration has changed. + +#### Removed + +- N/A + ### [3.0.1] #### Added @@ -23,5 +37,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - N/A +[4.0.0]: #4.0.0 [3.0.1]: #3.0.1 {{- end -}} diff --git a/charts/stable/modem-stats/templates/NOTES.txt b/charts/stable/modem-stats/templates/NOTES.txt index 1c97324f..90f7b653 100644 --- a/charts/stable/modem-stats/templates/NOTES.txt +++ b/charts/stable/modem-stats/templates/NOTES.txt @@ -1,7 +1 @@ -You can connect to the container running modem-stats. To open a shell session in the pod run the following: - -- kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "modem-stats.fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh - -To trail the logs for the modem-stats pod run the following: - -- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "modem-stats.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') \ No newline at end of file +{{- include "common.notes.defaultNotes" . -}} diff --git a/charts/stable/modem-stats/templates/_helpers.tpl b/charts/stable/modem-stats/templates/_helpers.tpl deleted file mode 100644 index 88ca0c51..00000000 --- a/charts/stable/modem-stats/templates/_helpers.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{{/* vim: set filetype=mustache: */}} - -{{/* -Expand the name of the chart. -*/}} -{{- define "modem-stats.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "modem-stats.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} \ No newline at end of file diff --git a/charts/stable/modem-stats/templates/common.yaml b/charts/stable/modem-stats/templates/common.yaml new file mode 100644 index 00000000..ebf7be03 --- /dev/null +++ b/charts/stable/modem-stats/templates/common.yaml @@ -0,0 +1,32 @@ +--- +{{/* Make sure all variables are set properly */}} +{{- include "common.values.setup" . }} + +{{/* Append the configMap to the additionalVolumes */}} +{{- define "modem-stats.configmap.volume" -}} +name: modem-stats-settings +configMap: + name: {{ template "common.names.fullname" . }}-config +{{- end -}} + +{{- $volume := include "modem-stats.configmap.volume" . | fromYaml -}} +{{- if $volume -}} + {{- $additionalVolumes := append .Values.additionalVolumes $volume }} + {{- $_ := set .Values "additionalVolumes" (deepCopy $additionalVolumes) -}} +{{- end -}} + +{{/* Append the configMap volume to the additionalVolumeMounts */}} +{{- define "modem-stats.configmap.volumeMount" -}} +name: modem-stats-settings +mountPath: /src/config.ini +subPath: config.ini +{{- end -}} + +{{- $volumeMount := include "modem-stats.configmap.volumeMount" . | fromYaml -}} +{{- if $volumeMount -}} + {{- $additionalVolumeMounts := append .Values.additionalVolumeMounts $volumeMount }} + {{- $_ := set .Values "additionalVolumeMounts" (deepCopy $additionalVolumeMounts) -}} +{{- end -}} + +{{/* Render the templates */}} +{{ include "common.all" . }} diff --git a/charts/stable/modem-stats/templates/configmap.yaml b/charts/stable/modem-stats/templates/configmap.yaml index 4f3ddedc..5ca597fe 100644 --- a/charts/stable/modem-stats/templates/configmap.yaml +++ b/charts/stable/modem-stats/templates/configmap.yaml @@ -1,31 +1,10 @@ +--- apiVersion: v1 kind: ConfigMap metadata: - name: {{ template "modem-stats.fullname" . }} + name: {{ template "common.names.fullname" . }}-config labels: - app: {{ template "modem-stats.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" + {{- include "common.labels" . | nindent 4 }} data: config.ini: | - [GENERAL] - Delay = {{ .Values.config.delay }} - {{- if .Values.debug }} - Output = True - {{- else }} - Output = False - {{- end }} - [INFLUXDB] - Address = {{ .Values.config.influxdb.host }} - Port = {{ .Values.config.influxdb.port }} - Database = {{ .Values.config.influxdb.database }} - Username = {{ .Values.config.influxdb.username }} - Password = {{ .Values.config.influxdb.password }} - {{- if .Values.config.influxdb.ssl }} - Verify_SSL = True - {{- else }} - Verify_SSL = False - {{- end }} - [MODEM] - URL = {{ .Values.config.modem.url }} \ No newline at end of file + {{- .Values.config | nindent 4 }} diff --git a/charts/stable/modem-stats/templates/deployment.yaml b/charts/stable/modem-stats/templates/deployment.yaml deleted file mode 100644 index f1d9b975..00000000 --- a/charts/stable/modem-stats/templates/deployment.yaml +++ /dev/null @@ -1,49 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "modem-stats.fullname" . }} - labels: - app: {{ template "modem-stats.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} -spec: - selector: - matchLabels: - app: {{ template "modem-stats.name" . }} - release: {{ .Release.Name }} - replicas: {{ default 1 .Values.replicas }} - revisionHistoryLimit: 3 - template: - metadata: - labels: - app: {{ template "modem-stats.name" . }} - release: {{ .Release.Name }} - {{- if .Values.podAnnotations }} - annotations: - {{- range $key, $value := .Values.podAnnotations }} - {{ $key }}: {{ $value | quote }} - {{- end }} - {{- end }} - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - resources: -{{ toYaml .Values.resources | indent 12 }} - volumeMounts: - - name: {{ template "modem-stats.name" . }} - mountPath: /src/config.ini - subPath: config.ini - {{- if .Values.nodeSelector }} - nodeSelector: -{{ toYaml .Values.nodeSelector | indent 8 }} - {{- end }} - volumes: - - name: {{ template "modem-stats.name" . }} - configMap: - name: {{ template "modem-stats.fullname" . }} - items: - - key: config.ini - path: config.ini \ No newline at end of file diff --git a/charts/stable/modem-stats/values.yaml b/charts/stable/modem-stats/values.yaml index 4512a5c8..552b73dc 100644 --- a/charts/stable/modem-stats/values.yaml +++ b/charts/stable/modem-stats/values.yaml @@ -1,48 +1,44 @@ -# Default values for modem-stats. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. -replicaCount: 1 +# +# IMPORTANT NOTE +# +# This chart inherits from our common library chart. You can check the default values/options here: +# https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml +# + image: - # -- modem-stats image repository: billimek/sb6183-for-influxdb - # -- modem-stats image tag tag: latest - # -- modem-stats image pull policy pullPolicy: IfNotPresent -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi -nodeSelector: {} -# -- Display debugging output -debug: false -config: - # -- how many seconds to wait between checks - delay: 3600 - influxdb: - # -- InfluxDB hostname - host: influxdb-influxdb - # -- InfluxDB port - port: 8086 - # -- InfluxDB database - database: cable_modem_stats - # -- InfluxDB username - # username: - # -- InfluxDB password - # password: - # -- InfluxDB connection using SSL - ssl: false - modem: - # -- sb6183 stats URL page - url: http://192.168.100.1/RgConnect.asp +strategy: + type: Recreate -# -- Key-value pairs to add as pod annotations -podAnnotations: {} +env: {} + +# -- modem-stats' config.ini configuration +# @default -- string +config: | + [GENERAL] + Delay = 3600 + Output = False + [INFLUXDB] + Address = influxdb-influxdb + Port = 8086 + Database = cable_modem_stats + Username = + Password = + Verify_SSL = False + [MODEM] + URL = http://192.168.100.1/RgConnect.asp + +service: + enabled: false + +## Probes configuration +probes: + liveness: + enabled: false + readiness: + enabled: false + startup: + enabled: false