Move Pihole to ix-dev and fix DHCP/DNS (#1049)

* move pihole to ix-dev

* always use the web_port for webUI

* Apply fixes for DHCP/DNS + hostnetwork

* Don't attempt to generate service at all on hostnet

* clean url
This commit is contained in:
Stavros Kois
2023-03-24 23:24:51 +02:00
committed by GitHub
parent b840779832
commit 11d1506ccc
21 changed files with 137 additions and 61 deletions

View File

@@ -0,0 +1,2 @@
# Patterns to ignore when building packages.
*.png

View File

@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: file://../../../common/2207.0.0
version: 2207.0.0
digest: sha256:a301ba0f99ec1e08a60a7f0a0320aa02d225993572f2f056f09520f06df88b37
generated: "2023-03-22T14:34:22.657500007Z"

View File

@@ -0,0 +1,24 @@
name: pihole
description: DNS and Ad-filtering for your network.
annotations:
title: Pi-hole
type: application
version: 1.0.13
apiVersion: v2
appVersion: '2023.02.2'
kubeVersion: '>=1.16.0-0'
maintainers:
- name: truenas
url: https://www.truenas.com/
dependencies:
- name: common
repository: file://../../../common/2207.0.0
version: 2207.0.0
home: https://pi-hole.net/
icon: https://github.com/pi-hole/graphics/raw/master/Vortex/Vortex_Vertical_wordmark_lightmode.png?raw=true
sources:
- https://pi-hole.net/
- https://github.com/truenas/charts/tree/master/library/ix-dev/charts/pihole
keywords:
- networking
- dns

View File

@@ -0,0 +1,3 @@
# Pihole
DNS and Ad-filtering for your network.

View File

@@ -0,0 +1,3 @@
# Pihole
DNS and Ad-filtering for your network.

View File

@@ -0,0 +1,22 @@
appVolumeMounts:
config:
emptyDir: true
mountPath: /etc/pihole
dnsmasq:
emptyDir: true
mountPath: /etc/dnsmasq.d
dhcp: true
dhcp_start: 192.168.10.2
dhcp_end: 192.168.10.254
dhcp_gateway: 192.168.10.1
dnsConfig:
options: []
emptyDirVolumes: true
environmentVariables: []
extraAppVolumeMounts: []
hostNetwork: true
ownerGID: 568
ownerUID: 568
password: admin123
timezone: America/Los_Angeles
web_port: 32000

View File

@@ -0,0 +1,22 @@
appVolumeMounts:
config:
emptyDir: true
mountPath: /etc/pihole
dnsmasq:
emptyDir: true
mountPath: /etc/dnsmasq.d
dhcp: false
dhcp_port: 32003
dnsConfig:
options: []
dns_tcp_port: 32001
dns_udp_port: 32002
emptyDirVolumes: true
environmentVariables: []
extraAppVolumeMounts: []
hostNetwork: false
ownerGID: 568
ownerUID: 568
password: admin123
timezone: America/Los_Angeles
web_port: 32000

View File

@@ -0,0 +1,4 @@
icon_url: https://github.com/pi-hole/graphics/raw/master/Vortex/Vortex_Vertical_wordmark_lightmode.png?raw=true)
categories:
- networking
- dns

View File

@@ -0,0 +1,313 @@
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"
- name: "Resource Limits"
description: "Set CPU/memory limits for Kubernetes Pod"
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
show_if: [["hostNetwork", "=", false]]
required: true
- variable: dns_udp_port
label: "DNS UDP Port for pihole"
group: Networking
schema:
type: int
min: 8000
max: 65535
default: 20721
show_if: [["hostNetwork", "=", false]]
required: true
- variable: dhcp
label: "Enable DHCP"
group: "Networking"
schema:
type: boolean
default: false
show_subquestions_if: true
subquestions:
- variable: dhcp_port
label: "DHCP Port for pihole"
group: Networking
schema:
type: int
min: 8000
max: 65535
default: 20722
show_if: [["hostNetwork", "=", false]]
required: true
- variable: dhcp_start
label: "DHCP Start Address"
group: Networking
schema:
type: ipaddr
cidr: false
required: true
- variable: dhcp_end
label: "DHCP End Address"
group: Networking
schema:
type: ipaddr
cidr: false
required: true
- variable: dhcp_gateway
label: "Gateway"
group: Networking
schema:
type: ipaddr
cidr: false
required: 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
- variable: enableResourceLimits
label: "Enable Pod resource limits"
group: "Resource Limits"
schema:
type: boolean
default: false
- variable: cpuLimit
label: "CPU Limresource limitsit"
description: "CPU resource limit allow plain integer values with suffix m(milli) e.g 1000m, 100."
group: "Resource Limits"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^\\d+(?:\\.\\d+(?!.*m$)|m?$)"
default: "4000m"
- variable: memLimit
label: "Memory Limit"
group: "Resource Limits"
description: "Memory limits is specified by number of bytes. Followed by quantity suffix like E,P,T,G,M,k and Ei,Pi,Ti,Mi,Gi,Ki can also be used. e.g 129e6, 129M, 128974848000m, 123Mi"
schema:
type: string
show_if: [["enableResourceLimits", "=", true]]
valid_chars: "^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$"
default: "8Gi"

View File

@@ -0,0 +1,108 @@
{{ include "common.storage.hostPathValidate" .Values }}
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.resources.limitation" . | nindent 10 }}
{{ include "common.containers.imageConfig" .Values.image | nindent 10 }}
volumeMounts: {{ include "common.storage.configureAppVolumeMountsInContainer" .Values | nindent 12 }}
{{ range $index, $hostPathConfiguration := .Values.extraAppVolumeMounts }}
- name: extrappvolume-{{ $index }}
mountPath: {{ $hostPathConfiguration.mountPath }}
{{ end }}
securityContext:
capabilities:
{{ if .Values.hostNetwork }}
{{/* This is needed to be able to bind 53(DNS) and 67(DHCP) ports */}}
add: ["NET_ADMIN"]
{{ else }}
add: []
{{ end }}
ports:
- name: web
containerPort: {{ .Values.web_port }}
- name: dns-tcp
containerPort: 53
protocol: TCP
- name: dns-udp
containerPort: 53
protocol: UDP
{{ if .Values.dhcp }}
- name: dhcp
containerPort: 67
protocol: UDP
{{ end }}
readinessProbe:
httpGet:
path: /admin/login.php
port: {{ .Values.web_port }}
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 2
livenessProbe:
httpGet:
path: /admin/login.php
port: {{ .Values.web_port }}
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 5
successThreshold: 1
startupProbe:
httpGet:
path: /admin/login.php
port: {{ .Values.web_port }}
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 60
successThreshold: 1
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)) }}
{{ $envList = mustAppend $envList (dict "name" "WEB_PORT" "value" .Values.web_port) }}
{{ if .Values.dhcp }}
{{ $envList = mustAppend $envList (dict "name" "DHCP_ACTIVE" "value" "true") }}
{{ $envList = mustAppend $envList (dict "name" "DHCP_START" "value" .Values.dhcp_start) }}
{{ $envList = mustAppend $envList (dict "name" "DHCP_END" "value" .Values.dhcp_end) }}
{{ $envList = mustAppend $envList (dict "name" "DHCP_ROUTER" "value" .Values.dhcp_gateway) }}
{{ 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 }}

View File

@@ -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 }}

View File

@@ -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 }}

View File

@@ -0,0 +1,19 @@
{{/* Create services only if we are not using hostNetwork */}}
{{ if not .Values.hostNetwork }}
{{ $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" .Values.web_port) }}
{{ $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 }}
{{ end }}

View File

@@ -0,0 +1 @@
{"filename": "ix_values.yaml", "keys": ["image"], "test_filename": "test_values.yaml"}

View File

@@ -0,0 +1,27 @@
#!/usr/bin/python3
import json
import sys
from catalog_update.upgrade_strategy import datetime_versioning
def newer_mapping(image_tags):
key = list(image_tags.keys())[0]
tags = {t for t in image_tags[key]}
version = datetime_versioning(list(tags), '%Y-%m-%d')
if not version:
return {}
return {
'tags': {key: tags[version]},
'app_version': version,
}
if __name__ == '__main__':
try:
versions_json = json.loads(sys.stdin.read())
except ValueError:
raise ValueError('Invalid json specified')
print(json.dumps(newer_mapping(versions_json)))

View File

@@ -0,0 +1,4 @@
image:
pullPolicy: IfNotPresent
repository: pihole/pihole
tag: 2023.02.2