diff --git a/charts/pihole/.helmignore b/charts/pihole/.helmignore new file mode 100644 index 0000000000..c1347c2c27 --- /dev/null +++ b/charts/pihole/.helmignore @@ -0,0 +1,2 @@ +# Patterns to ignore when building packages. +*.png diff --git a/charts/pihole/1.0.0/Chart.yaml b/charts/pihole/1.0.0/Chart.yaml new file mode 100644 index 0000000000..5f919dbe71 --- /dev/null +++ b/charts/pihole/1.0.0/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +appVersion: 2022.04.3 +icon: https://truecharts.org/_static/img/appicons/pihole.png +description: DNS and Ad-filtering for your network. +name: pihole +version: 1.0.0 +dependencies: +- name: common + repository: file://../../../library/common/2112.0.0 + version: 2112.0.0 +home: https://pi-hole.net/ +keywords: +- networking +- dns diff --git a/charts/pihole/1.0.0/README.md b/charts/pihole/1.0.0/README.md new file mode 100644 index 0000000000..98d1bcdb3b --- /dev/null +++ b/charts/pihole/1.0.0/README.md @@ -0,0 +1,3 @@ +# Pihole + +DNS and Ad-filtering for your network. diff --git a/charts/pihole/1.0.0/app-readme.md b/charts/pihole/1.0.0/app-readme.md new file mode 100644 index 0000000000..98d1bcdb3b --- /dev/null +++ b/charts/pihole/1.0.0/app-readme.md @@ -0,0 +1,3 @@ +# Pihole + +DNS and Ad-filtering for your network. diff --git a/charts/pihole/1.0.0/charts/common-2112.0.0.tgz b/charts/pihole/1.0.0/charts/common-2112.0.0.tgz new file mode 100644 index 0000000000..62c214e1c8 Binary files /dev/null and b/charts/pihole/1.0.0/charts/common-2112.0.0.tgz differ diff --git a/charts/pihole/1.0.0/ix_values.yaml b/charts/pihole/1.0.0/ix_values.yaml new file mode 100644 index 0000000000..10cef7b5b3 --- /dev/null +++ b/charts/pihole/1.0.0/ix_values.yaml @@ -0,0 +1,4 @@ +image: + pullPolicy: IfNotPresent + repository: pihole/pihole + tag: 2022.04.3 diff --git a/charts/pihole/1.0.0/questions.yaml b/charts/pihole/1.0.0/questions.yaml new file mode 100644 index 0000000000..c5b125ff64 --- /dev/null +++ b/charts/pihole/1.0.0/questions.yaml @@ -0,0 +1,260 @@ +groups: + - name: "Configuration" + description: "Pihole application configuration" + - name: "Storage" + description: "Configure storage for pihole" + - name: "Networking" + description: "Networking Configuration for pihole" + - name: "Advanced DNS Settings" + description: "Configure DNS settings" + +portals: + web_portal: + protocols: + - "http" + host: + - "$node_ip" + ports: + - "$variable-web_port" + path: "/admin/" + +questions: + - variable: web_port + label: "Web Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20720 + required: true + - variable: dns_tcp_port + label: "DNS TCP Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20721 + required: true + - variable: dns_udp_port + label: "DNS UDP Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20721 + required: true + - variable: dhcp + label: "Enable DHCP" + group: "Networking" + schema: + type: boolean + default: false + - variable: dhcp_port + label: "DHCP Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20722 + required: true + show_if: [["dhcp", "=", true]] + + - variable: dnsConfig + label: "DNS Configuration" + group: "Advanced DNS Settings" + schema: + type: dict + attrs: + - variable: options + label: "DNS Options" + schema: + type: list + items: + - variable: optionsEntry + label: "Option Entry Configuration" + schema: + type: dict + attrs: + - variable: name + label: "Option Name" + schema: + type: string + required: true + - variable: value + label: "Option Value" + schema: + type: string + required: true + + - variable: ownerUID + label: "Storage User ID" + description: "User ID of the dnsmasq volume being used (application will chown the volume path with specified UID)" + group: Configuration + schema: + type: int + default: 568 + min: 1 + max: 65535 + + - variable: ownerGID + label: "Storage Group ID" + description: "Group ID of the dnsmasq volume being used (application will chown the volume path with specified GID)" + group: Configuration + schema: + type: int + default: 568 + min: 1 + max: 65535 + + - variable: password + label: "Admin password" + group: "Configuration" + schema: + type: string + private: true + required: true + empty: false + immutable: true + + - variable: timezone + label: "Configure timezone" + group: "Configuration" + description: "Configure timezone for pihole" + schema: + type: string + $ref: + - "definitions/timezone" + + - variable: hostNetwork + label: "Enable Host Network" + group: "Networking" + schema: + type: boolean + default: false + + - variable: environmentVariables + label: "Pihole environment" + group: "Configuration" + schema: + type: list + default: [] + items: + - variable: environmentVariable + label: "Environment Variable" + schema: + type: dict + attrs: + - variable: name + label: "Name" + schema: + type: string + - variable: value + label: "Value" + schema: + type: string + + - variable: appVolumeMounts + label: "Pihole Storage" + group: "Storage" + schema: + type: dict + attrs: + - variable: config + label: "Configuration Volume" + schema: + type: dict + attrs: + - variable: datasetName + label: "Configuration Volume Dataset Name" + schema: + type: string + hidden: true + $ref: + - "normalize/ixVolume" + show_if: [["hostPathEnabled", "=", false]] + default: "ix-pihole_config" + editable: false + - variable: mountPath + label: "Configuration Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + hidden: true + editable: true + default: "/etc/pihole" + - variable: hostPathEnabled + label: "Enable Custom Host Path for Pihole Configuration Volume" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostPath + label: "Host Path for Pihole Configuration Volume" + schema: + type: hostpath + required: true + - variable: dnsmasq + label: "DNSMASQ Volume for pihole" + schema: + type: dict + attrs: + - variable: datasetName + label: "DNSMASQ Volume Dataset Name" + schema: + type: string + hidden: true + $ref: + - "normalize/ixVolume" + show_if: [["hostPathEnabled", "=", false]] + default: "ix-pihole_dnsmasq" + editable: false + - variable: mountPath + label: "DNSMASQ Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + hidden: true + editable: true + default: "/etc/dnsmasq.d" + - variable: hostPathEnabled + label: "Enable Custom Host Path for Pihole DNSMASQ Volume" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostPath + label: "Host Path for Pihole DNSMASQ Volume" + schema: + type: hostpath + required: true + + - variable: extraAppVolumeMounts + label: "Extra Host Path Volumes" + group: "Storage" + schema: + type: list + items: + - variable: extraAppVolume + label: "Host Path Volume" + description: "Add an extra host path volume for Pihole application" + schema: + type: dict + attrs: + - variable: mountPath + label: "Mount Path in Pod" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + required: true + - variable: hostPath + label: "Host Path" + description: "Host path" + schema: + type: hostpath + required: true \ No newline at end of file diff --git a/charts/pihole/1.0.0/templates/deployment.yaml b/charts/pihole/1.0.0/templates/deployment.yaml new file mode 100644 index 0000000000..3ffe94fdf6 --- /dev/null +++ b/charts/pihole/1.0.0/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }} +kind: Deployment +metadata: + name: {{ template "common.names.fullname" . }} + labels: + app: {{ template "common.names.name" . }} + chart: {{ template "common.names.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + rollme: {{ randAlphaNum 5 | quote }} +spec: + replicas: {{ (default 1 .Values.replicas) }} + strategy: + type: "Recreate" + selector: + matchLabels: + app: {{ template "common.names.name" . }} + release: {{ .Release.Name }} + template: + metadata: + name: {{ template "common.names.fullname" . }} + labels: + app: {{ template "common.names.name" . }} + release: {{ .Release.Name }} + {{- include "common.labels.selectorLabels" . | nindent 8 }} + annotations: {{ include "common.annotations" . | nindent 8 }} + spec: + hostNetwork: {{ .Values.hostNetwork }} + containers: + - name: {{ .Chart.Name }} + {{ include "common.containers.imageConfig" .Values.image | nindent 10 }} + volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }} + ports: + - name: web + containerPort: 80 + - name: dns-tcp + containerPort: 53 + protocol: TCP + - name: dns-udp + containerPort: 53 + protocol: UDP + {{ if .Values.dhcp }} + - name: dhcp + containerPort: 67 + protocol: UDP + {{ end }} + env: + {{ $secretName := (include "common.names.fullname" .) }} + {{ $envList := (default list .Values.environmentVariables) }} + {{ $envList = mustAppend $envList (dict "name" "WEBPASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "password") }} + {{ $envList = mustAppend $envList (dict "name" "TZ" "value" (printf "%s" .Values.timezone)) }} + {{ if .Values.dhcp }} + {{ $envList = mustAppend $envList (dict "name" "DHCP_ACTIVE" "value" "true") }} + {{ end }} + {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }} +{{ include "common.networking.dnsConfiguration" .Values | nindent 6 }} + volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }} + {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }} + - name: extrappvolume-{{ $index }} + hostPath: + path: {{ $hostPathConfiguration.hostPath }} + {{ end }} diff --git a/charts/pihole/1.0.0/templates/pre-install-job.yaml b/charts/pihole/1.0.0/templates/pre-install-job.yaml new file mode 100644 index 0000000000..8ef9ea0f26 --- /dev/null +++ b/charts/pihole/1.0.0/templates/pre-install-job.yaml @@ -0,0 +1,32 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ template "common.names.fullname" . }}-preinstall-job" + labels: + app.kubernetes.io/managed-by: {{ .Release.Service | quote }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + helm.sh/chart: {{ template "common.names.chart" . }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "{{ template "common.names.fullname" . }}-preinstall-hook" + labels: + app.kubernetes.io/managed-by: {{ .Release.Service | quote }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} + helm.sh/chart: {{ template "common.names.chart" . }} + spec: + restartPolicy: Never + containers: + - name: pre-install-job + image: "alpine:latest" + command: + - "chown" + - "-R" + - "{{ .Values.ownerUID }}:{{ .Values.ownerGID }}" + - "{{ .Values.appVolumeMounts.dnsmasq.mountPath }}" + volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }} + volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }} diff --git a/charts/pihole/1.0.0/templates/secret.yaml b/charts/pihole/1.0.0/templates/secret.yaml new file mode 100644 index 0000000000..e531b6015e --- /dev/null +++ b/charts/pihole/1.0.0/templates/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "common.names.fullname" . }} + labels: {{ include "common.labels" . | nindent 4 }} +type: Opaque +data: + password: {{ .Values.password | b64enc | quote }} diff --git a/charts/pihole/1.0.0/templates/service.yaml b/charts/pihole/1.0.0/templates/service.yaml new file mode 100644 index 0000000000..566328dbc1 --- /dev/null +++ b/charts/pihole/1.0.0/templates/service.yaml @@ -0,0 +1,14 @@ +{{ $selectors := list }} +{{ $selectors = mustAppend $selectors (dict "key" "app" "value" (include "common.names.name" .) ) }} +{{ $selectors = mustAppend $selectors (dict "key" "release" "value" .Release.Name ) }} +{{ $ports := list }} +{{ $ports = mustAppend $ports (dict "name" "web" "port" .Values.web_port "nodePort" .Values.web_port "targetPort" 80) }} +{{ $ports = mustAppend $ports (dict "name" "dns-tcp" "port" .Values.dns_tcp_port "nodePort" .Values.dns_tcp_port "targetPort" 53) }} +{{ $ports = mustAppend $ports (dict "name" "dns-udp" "port" .Values.dns_udp_port "nodePort" .Values.dns_udp_port "targetPort" 53 "protocol" "UDP") }} +{{ if .Values.dhcp }} +{{ $ports = mustAppend $ports (dict "name" "dhcp" "port" .Values.dhcp_port "nodePort" .Values.dhcp_port "targetPort" 67 "protocol" "UDP") }} +{{ end }} +{{ $params := . }} +{{ $_ := set $params "commonService" (dict "type" "NodePort" "ports" $ports ) }} +{{ $_1 := set .Values "extraSelectorLabels" $selectors }} +{{ include "common.classes.service" $params }} diff --git a/charts/pihole/1.0.0/templates/tests/deployment-check.yaml b/charts/pihole/1.0.0/templates/tests/deployment-check.yaml new file mode 100644 index 0000000000..7e888eb0b9 --- /dev/null +++ b/charts/pihole/1.0.0/templates/tests/deployment-check.yaml @@ -0,0 +1,21 @@ +{{- $serviceName := (include "common.names.fullname" .) -}} +apiVersion: v1 +kind: Pod +metadata: + name: {{ .Release.Name }}-test-pod + labels: + app: {{ .Release.Name }} + release: {{ .Release.Name }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: test-curl + image: alpine/curl + imagePullPolicy: "IfNotPresent" + command: + - /bin/sh + - -ec + - | + curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 15 --retry-max-time 90 --retry-all-errors -ksf http://{{ $serviceName }}:{{.Values.web_port}}/ + restartPolicy: Never diff --git a/charts/pihole/1.0.0/test_values.yaml b/charts/pihole/1.0.0/test_values.yaml new file mode 100644 index 0000000000..0546195638 --- /dev/null +++ b/charts/pihole/1.0.0/test_values.yaml @@ -0,0 +1,26 @@ +image: + pullPolicy: IfNotPresent + repository: pihole/pihole + tag: 2022.04.3 +dhcp: false +timezone: "America/Los_Angeles" +password: "admin123" +environmentVariables: [] +extraAppVolumeMounts: [] +web_port: 32000 +dns_tcp_port: 32001 +dns_udp_port: 32002 +dhcp_port: 32003 +dnsConfig: + options: [] +emptyDirVolumes: true +appVolumeMounts: + config: + emptyDir: true + mountPath: /etc/pihole + dnsmasq: + emptyDir: true + mountPath: /etc/dnsmasq.d +ownerUID: 568 +ownerGID: 568 +hostNetwork: false diff --git a/charts/pihole/item.yaml b/charts/pihole/item.yaml new file mode 100644 index 0000000000..c1f475b14a --- /dev/null +++ b/charts/pihole/item.yaml @@ -0,0 +1,4 @@ +icon_url: https://truecharts.org/_static/img/appicons/pihole.png +categories: +- networking +- dns diff --git a/charts/pihole/upgrade_info.json b/charts/pihole/upgrade_info.json new file mode 100644 index 0000000000..5bf84fb901 --- /dev/null +++ b/charts/pihole/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "ix_values.yaml", "keys": ["image"]} diff --git a/charts/pihole/upgrade_strategy b/charts/pihole/upgrade_strategy new file mode 100755 index 0000000000..7b17b7c084 --- /dev/null +++ b/charts/pihole/upgrade_strategy @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +import json +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + + +def newer_mapping(image_tags): + key = list(image_tags.keys())[0] + tags = {t: t for t in image_tags[key]} + version = semantic_versioning(list(tags)) + if not version: + return {} + + return { + 'tags': {key: tags[version]}, + 'app_version': version, + } + + +if __name__ == '__main__': + if len(sys.argv) != 2: + exit(1) + + print(json.dumps(newer_mapping(json.loads(sys.argv[1])))) diff --git a/test/pihole/.helmignore b/test/pihole/.helmignore new file mode 100644 index 0000000000..c1347c2c27 --- /dev/null +++ b/test/pihole/.helmignore @@ -0,0 +1,2 @@ +# Patterns to ignore when building packages. +*.png diff --git a/test/pihole/1.0.0/Chart.yaml b/test/pihole/1.0.0/Chart.yaml new file mode 100644 index 0000000000..5f919dbe71 --- /dev/null +++ b/test/pihole/1.0.0/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +appVersion: 2022.04.3 +icon: https://truecharts.org/_static/img/appicons/pihole.png +description: DNS and Ad-filtering for your network. +name: pihole +version: 1.0.0 +dependencies: +- name: common + repository: file://../../../library/common/2112.0.0 + version: 2112.0.0 +home: https://pi-hole.net/ +keywords: +- networking +- dns diff --git a/test/pihole/1.0.0/README.md b/test/pihole/1.0.0/README.md new file mode 100644 index 0000000000..98d1bcdb3b --- /dev/null +++ b/test/pihole/1.0.0/README.md @@ -0,0 +1,3 @@ +# Pihole + +DNS and Ad-filtering for your network. diff --git a/test/pihole/1.0.0/app-readme.md b/test/pihole/1.0.0/app-readme.md new file mode 100644 index 0000000000..98d1bcdb3b --- /dev/null +++ b/test/pihole/1.0.0/app-readme.md @@ -0,0 +1,3 @@ +# Pihole + +DNS and Ad-filtering for your network. diff --git a/test/pihole/1.0.0/charts/common-2112.0.0.tgz b/test/pihole/1.0.0/charts/common-2112.0.0.tgz new file mode 100644 index 0000000000..62c214e1c8 Binary files /dev/null and b/test/pihole/1.0.0/charts/common-2112.0.0.tgz differ diff --git a/test/pihole/1.0.0/ix_values.yaml b/test/pihole/1.0.0/ix_values.yaml new file mode 100644 index 0000000000..10cef7b5b3 --- /dev/null +++ b/test/pihole/1.0.0/ix_values.yaml @@ -0,0 +1,4 @@ +image: + pullPolicy: IfNotPresent + repository: pihole/pihole + tag: 2022.04.3 diff --git a/test/pihole/1.0.0/questions.yaml b/test/pihole/1.0.0/questions.yaml new file mode 100644 index 0000000000..c5b125ff64 --- /dev/null +++ b/test/pihole/1.0.0/questions.yaml @@ -0,0 +1,260 @@ +groups: + - name: "Configuration" + description: "Pihole application configuration" + - name: "Storage" + description: "Configure storage for pihole" + - name: "Networking" + description: "Networking Configuration for pihole" + - name: "Advanced DNS Settings" + description: "Configure DNS settings" + +portals: + web_portal: + protocols: + - "http" + host: + - "$node_ip" + ports: + - "$variable-web_port" + path: "/admin/" + +questions: + - variable: web_port + label: "Web Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20720 + required: true + - variable: dns_tcp_port + label: "DNS TCP Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20721 + required: true + - variable: dns_udp_port + label: "DNS UDP Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20721 + required: true + - variable: dhcp + label: "Enable DHCP" + group: "Networking" + schema: + type: boolean + default: false + - variable: dhcp_port + label: "DHCP Port for pihole" + group: Networking + schema: + type: int + min: 8000 + max: 65535 + default: 20722 + required: true + show_if: [["dhcp", "=", true]] + + - variable: dnsConfig + label: "DNS Configuration" + group: "Advanced DNS Settings" + schema: + type: dict + attrs: + - variable: options + label: "DNS Options" + schema: + type: list + items: + - variable: optionsEntry + label: "Option Entry Configuration" + schema: + type: dict + attrs: + - variable: name + label: "Option Name" + schema: + type: string + required: true + - variable: value + label: "Option Value" + schema: + type: string + required: true + + - variable: ownerUID + label: "Storage User ID" + description: "User ID of the dnsmasq volume being used (application will chown the volume path with specified UID)" + group: Configuration + schema: + type: int + default: 568 + min: 1 + max: 65535 + + - variable: ownerGID + label: "Storage Group ID" + description: "Group ID of the dnsmasq volume being used (application will chown the volume path with specified GID)" + group: Configuration + schema: + type: int + default: 568 + min: 1 + max: 65535 + + - variable: password + label: "Admin password" + group: "Configuration" + schema: + type: string + private: true + required: true + empty: false + immutable: true + + - variable: timezone + label: "Configure timezone" + group: "Configuration" + description: "Configure timezone for pihole" + schema: + type: string + $ref: + - "definitions/timezone" + + - variable: hostNetwork + label: "Enable Host Network" + group: "Networking" + schema: + type: boolean + default: false + + - variable: environmentVariables + label: "Pihole environment" + group: "Configuration" + schema: + type: list + default: [] + items: + - variable: environmentVariable + label: "Environment Variable" + schema: + type: dict + attrs: + - variable: name + label: "Name" + schema: + type: string + - variable: value + label: "Value" + schema: + type: string + + - variable: appVolumeMounts + label: "Pihole Storage" + group: "Storage" + schema: + type: dict + attrs: + - variable: config + label: "Configuration Volume" + schema: + type: dict + attrs: + - variable: datasetName + label: "Configuration Volume Dataset Name" + schema: + type: string + hidden: true + $ref: + - "normalize/ixVolume" + show_if: [["hostPathEnabled", "=", false]] + default: "ix-pihole_config" + editable: false + - variable: mountPath + label: "Configuration Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + hidden: true + editable: true + default: "/etc/pihole" + - variable: hostPathEnabled + label: "Enable Custom Host Path for Pihole Configuration Volume" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostPath + label: "Host Path for Pihole Configuration Volume" + schema: + type: hostpath + required: true + - variable: dnsmasq + label: "DNSMASQ Volume for pihole" + schema: + type: dict + attrs: + - variable: datasetName + label: "DNSMASQ Volume Dataset Name" + schema: + type: string + hidden: true + $ref: + - "normalize/ixVolume" + show_if: [["hostPathEnabled", "=", false]] + default: "ix-pihole_dnsmasq" + editable: false + - variable: mountPath + label: "DNSMASQ Mount Path" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + hidden: true + editable: true + default: "/etc/dnsmasq.d" + - variable: hostPathEnabled + label: "Enable Custom Host Path for Pihole DNSMASQ Volume" + schema: + type: boolean + default: false + show_subquestions_if: true + subquestions: + - variable: hostPath + label: "Host Path for Pihole DNSMASQ Volume" + schema: + type: hostpath + required: true + + - variable: extraAppVolumeMounts + label: "Extra Host Path Volumes" + group: "Storage" + schema: + type: list + items: + - variable: extraAppVolume + label: "Host Path Volume" + description: "Add an extra host path volume for Pihole application" + schema: + type: dict + attrs: + - variable: mountPath + label: "Mount Path in Pod" + description: "Path where the volume will be mounted inside the pod" + schema: + type: path + required: true + - variable: hostPath + label: "Host Path" + description: "Host path" + schema: + type: hostpath + required: true \ No newline at end of file diff --git a/test/pihole/1.0.0/templates/deployment.yaml b/test/pihole/1.0.0/templates/deployment.yaml new file mode 100644 index 0000000000..3ffe94fdf6 --- /dev/null +++ b/test/pihole/1.0.0/templates/deployment.yaml @@ -0,0 +1,63 @@ +apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }} +kind: Deployment +metadata: + name: {{ template "common.names.fullname" . }} + labels: + app: {{ template "common.names.name" . }} + chart: {{ template "common.names.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + rollme: {{ randAlphaNum 5 | quote }} +spec: + replicas: {{ (default 1 .Values.replicas) }} + strategy: + type: "Recreate" + selector: + matchLabels: + app: {{ template "common.names.name" . }} + release: {{ .Release.Name }} + template: + metadata: + name: {{ template "common.names.fullname" . }} + labels: + app: {{ template "common.names.name" . }} + release: {{ .Release.Name }} + {{- include "common.labels.selectorLabels" . | nindent 8 }} + annotations: {{ include "common.annotations" . | nindent 8 }} + spec: + hostNetwork: {{ .Values.hostNetwork }} + containers: + - name: {{ .Chart.Name }} + {{ include "common.containers.imageConfig" .Values.image | nindent 10 }} + volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }} + ports: + - name: web + containerPort: 80 + - name: dns-tcp + containerPort: 53 + protocol: TCP + - name: dns-udp + containerPort: 53 + protocol: UDP + {{ if .Values.dhcp }} + - name: dhcp + containerPort: 67 + protocol: UDP + {{ end }} + env: + {{ $secretName := (include "common.names.fullname" .) }} + {{ $envList := (default list .Values.environmentVariables) }} + {{ $envList = mustAppend $envList (dict "name" "WEBPASSWORD" "valueFromSecret" true "secretName" $secretName "secretKey" "password") }} + {{ $envList = mustAppend $envList (dict "name" "TZ" "value" (printf "%s" .Values.timezone)) }} + {{ if .Values.dhcp }} + {{ $envList = mustAppend $envList (dict "name" "DHCP_ACTIVE" "value" "true") }} + {{ end }} + {{ include "common.containers.environmentVariables" (dict "environmentVariables" $envList) | nindent 12 }} +{{ include "common.networking.dnsConfiguration" .Values | nindent 6 }} + volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }} + {{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }} + - name: extrappvolume-{{ $index }} + hostPath: + path: {{ $hostPathConfiguration.hostPath }} + {{ end }} diff --git a/test/pihole/1.0.0/templates/pre-install-job.yaml b/test/pihole/1.0.0/templates/pre-install-job.yaml new file mode 100644 index 0000000000..8ef9ea0f26 --- /dev/null +++ b/test/pihole/1.0.0/templates/pre-install-job.yaml @@ -0,0 +1,32 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ template "common.names.fullname" . }}-preinstall-job" + labels: + app.kubernetes.io/managed-by: {{ .Release.Service | quote }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + helm.sh/chart: {{ template "common.names.chart" . }} + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "{{ template "common.names.fullname" . }}-preinstall-hook" + labels: + app.kubernetes.io/managed-by: {{ .Release.Service | quote }} + app.kubernetes.io/instance: {{ .Release.Name | quote }} + helm.sh/chart: {{ template "common.names.chart" . }} + spec: + restartPolicy: Never + containers: + - name: pre-install-job + image: "alpine:latest" + command: + - "chown" + - "-R" + - "{{ .Values.ownerUID }}:{{ .Values.ownerGID }}" + - "{{ .Values.appVolumeMounts.dnsmasq.mountPath }}" + volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }} + volumes: {{ include "common.storage.configureAppVolumes" .Values | nindent 8 }} diff --git a/test/pihole/1.0.0/templates/secret.yaml b/test/pihole/1.0.0/templates/secret.yaml new file mode 100644 index 0000000000..e531b6015e --- /dev/null +++ b/test/pihole/1.0.0/templates/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "common.names.fullname" . }} + labels: {{ include "common.labels" . | nindent 4 }} +type: Opaque +data: + password: {{ .Values.password | b64enc | quote }} diff --git a/test/pihole/1.0.0/templates/service.yaml b/test/pihole/1.0.0/templates/service.yaml new file mode 100644 index 0000000000..566328dbc1 --- /dev/null +++ b/test/pihole/1.0.0/templates/service.yaml @@ -0,0 +1,14 @@ +{{ $selectors := list }} +{{ $selectors = mustAppend $selectors (dict "key" "app" "value" (include "common.names.name" .) ) }} +{{ $selectors = mustAppend $selectors (dict "key" "release" "value" .Release.Name ) }} +{{ $ports := list }} +{{ $ports = mustAppend $ports (dict "name" "web" "port" .Values.web_port "nodePort" .Values.web_port "targetPort" 80) }} +{{ $ports = mustAppend $ports (dict "name" "dns-tcp" "port" .Values.dns_tcp_port "nodePort" .Values.dns_tcp_port "targetPort" 53) }} +{{ $ports = mustAppend $ports (dict "name" "dns-udp" "port" .Values.dns_udp_port "nodePort" .Values.dns_udp_port "targetPort" 53 "protocol" "UDP") }} +{{ if .Values.dhcp }} +{{ $ports = mustAppend $ports (dict "name" "dhcp" "port" .Values.dhcp_port "nodePort" .Values.dhcp_port "targetPort" 67 "protocol" "UDP") }} +{{ end }} +{{ $params := . }} +{{ $_ := set $params "commonService" (dict "type" "NodePort" "ports" $ports ) }} +{{ $_1 := set .Values "extraSelectorLabels" $selectors }} +{{ include "common.classes.service" $params }} diff --git a/test/pihole/1.0.0/templates/tests/deployment-check.yaml b/test/pihole/1.0.0/templates/tests/deployment-check.yaml new file mode 100644 index 0000000000..7e888eb0b9 --- /dev/null +++ b/test/pihole/1.0.0/templates/tests/deployment-check.yaml @@ -0,0 +1,21 @@ +{{- $serviceName := (include "common.names.fullname" .) -}} +apiVersion: v1 +kind: Pod +metadata: + name: {{ .Release.Name }}-test-pod + labels: + app: {{ .Release.Name }} + release: {{ .Release.Name }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: test-curl + image: alpine/curl + imagePullPolicy: "IfNotPresent" + command: + - /bin/sh + - -ec + - | + curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 15 --retry-max-time 90 --retry-all-errors -ksf http://{{ $serviceName }}:{{.Values.web_port}}/ + restartPolicy: Never diff --git a/test/pihole/1.0.0/test_values.yaml b/test/pihole/1.0.0/test_values.yaml new file mode 100644 index 0000000000..0546195638 --- /dev/null +++ b/test/pihole/1.0.0/test_values.yaml @@ -0,0 +1,26 @@ +image: + pullPolicy: IfNotPresent + repository: pihole/pihole + tag: 2022.04.3 +dhcp: false +timezone: "America/Los_Angeles" +password: "admin123" +environmentVariables: [] +extraAppVolumeMounts: [] +web_port: 32000 +dns_tcp_port: 32001 +dns_udp_port: 32002 +dhcp_port: 32003 +dnsConfig: + options: [] +emptyDirVolumes: true +appVolumeMounts: + config: + emptyDir: true + mountPath: /etc/pihole + dnsmasq: + emptyDir: true + mountPath: /etc/dnsmasq.d +ownerUID: 568 +ownerGID: 568 +hostNetwork: false diff --git a/test/pihole/item.yaml b/test/pihole/item.yaml new file mode 100644 index 0000000000..c1f475b14a --- /dev/null +++ b/test/pihole/item.yaml @@ -0,0 +1,4 @@ +icon_url: https://truecharts.org/_static/img/appicons/pihole.png +categories: +- networking +- dns diff --git a/test/pihole/upgrade_info.json b/test/pihole/upgrade_info.json new file mode 100644 index 0000000000..5bf84fb901 --- /dev/null +++ b/test/pihole/upgrade_info.json @@ -0,0 +1 @@ +{"filename": "ix_values.yaml", "keys": ["image"]} diff --git a/test/pihole/upgrade_strategy b/test/pihole/upgrade_strategy new file mode 100755 index 0000000000..7b17b7c084 --- /dev/null +++ b/test/pihole/upgrade_strategy @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +import json +import sys + +from catalog_update.upgrade_strategy import semantic_versioning + + +def newer_mapping(image_tags): + key = list(image_tags.keys())[0] + tags = {t: t for t in image_tags[key]} + version = semantic_versioning(list(tags)) + if not version: + return {} + + return { + 'tags': {key: tags[version]}, + 'app_version': version, + } + + +if __name__ == '__main__': + if len(sys.argv) != 2: + exit(1) + + print(json.dumps(newer_mapping(json.loads(sys.argv[1]))))