Skip to content

Commit

Permalink
chore: Use consistent code style across templates (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkilchhofer committed Apr 8, 2024
1 parent 1c182ef commit d8508cd
Show file tree
Hide file tree
Showing 19 changed files with 255 additions and 295 deletions.
2 changes: 1 addition & 1 deletion charts/unifi/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: v7.5.176
kubeVersion: ">=1.18-0"
description: Ubiquiti Network's Unifi Controller
name: unifi
version: 1.7.0
version: 1.7.1
keywords:
- ubiquiti
- unifi
Expand Down
26 changes: 13 additions & 13 deletions charts/unifi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Ubiquiti Network's Unifi Controller

**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)**
**This chart is not maintained by the [upstream project](https://github.com/jacobalberty/unifi-docker) and any issues with the chart should be raised [here](https://github.com/mkilchhofer/unifi-chart/issues/new)**

## Source Code

Expand Down Expand Up @@ -41,13 +41,13 @@ Specify each parameter using the `--set key=value[,key=value]` argument to `helm
```console
helm install unifi \
--set env.TZ="America/New York" \
k8s-at-home/unifi
oci://ghcr.io/mkilchhofer/unifi-chart/unifi
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.

```console
helm install unifi k8s-at-home/unifi -f values.yaml
helm install unifi oci://ghcr.io/mkilchhofer/unifi-chart/unifi -f values.yaml
```

## Custom configuration
Expand Down Expand Up @@ -98,7 +98,7 @@ ingress:
| UID | int | `999` | Set the UID (user id) the UniFi service runs as when `runAsRoot` is set to false |
| affinity | object | `{}` | Affinity for pod assignment |
| captivePortalService.annotations | object | `{}` | Provide any additional annotations which may be required. This can be used to set the LoadBalancer service type to internal only. ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| captivePortalService.enabled | bool | `false` | Enable service for the captive portal webpage |
| captivePortalService.enabled | bool | `true` | Enable service for the captive portal webpage |
| captivePortalService.externalTrafficPolicy | string | `nil` | Set the externalTrafficPolicy in the Service to either Cluster or Local |
| captivePortalService.http | int | `8880` | Kubernetes port where the http service is exposed |
| captivePortalService.https | int | `8843` | Kubernetes port where the https service is exposed |
Expand All @@ -112,7 +112,7 @@ ingress:
| captivePortalService.loadBalancerSourceRanges | list | `nil` | loadBalancerSourceRanges |
| captivePortalService.type | string | `"ClusterIP"` | Kubernetes service type |
| controllerService.annotations | object | `{}` | Provide any additional annotations which may be required. This can be used to set the LoadBalancer service type to internal only. ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| controllerService.enabled | bool | `false` | Enable service for the controller |
| controllerService.enabled | bool | `true` | Enable service for the controller |
| controllerService.externalTrafficPolicy | string | `nil` | Set the externalTrafficPolicy in the Service to either Cluster or Local |
| controllerService.ingress.annotations | object | `{}` | Annotations for Ingress resource |
| controllerService.ingress.enabled | bool | `false` | Enable Ingress resource |
Expand All @@ -131,7 +131,7 @@ ingress:
| customCert.keyName | string | `"tls.key"` | File name of the private key for the certificate |
| deploymentAnnotations | object | `{}` | Annotations for UniFi deployment |
| discoveryService.annotations | object | `{}` | Provide any additional annotations which may be required. This can be used to set the LoadBalancer service type to internal only. ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| discoveryService.enabled | bool | `false` | Enable service for the discovery feature |
| discoveryService.enabled | bool | `true` | Enable service for the discovery feature |
| discoveryService.externalTrafficPolicy | string | `nil` | Set the externalTrafficPolicy in the Service to either Cluster or Local |
| discoveryService.ingress.annotations | object | `{}` | Annotations for Ingress resource |
| discoveryService.ingress.enabled | bool | `false` | Enable Ingress resource |
Expand All @@ -148,7 +148,7 @@ ingress:
| extraVolumeMounts | list | `[]` | specify additional VolumeMount to be mounted inside unifi container |
| extraVolumes | list | `[]` | specify additional volume to be used by extraVolumeMounts inside unifi container |
| guiService.annotations | object | `{}` | Provide any additional annotations which may be required. This can be used to set the LoadBalancer service type to internal only. ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| guiService.enabled | bool | `false` | Enable service for the main web UI |
| guiService.enabled | bool | `true` | Enable service for the main web UI |
| guiService.externalTrafficPolicy | string | `nil` | Set the externalTrafficPolicy in the Service to either Cluster or Local |
| guiService.labels | object | `{}` | Labels to add to the GUI service |
| guiService.loadBalancerIP | string | `nil` | Use loadBalancerIP to request a specific static IP, otherwise leave blank |
Expand All @@ -160,7 +160,7 @@ ingress:
| image.repository | string | `"jacobalberty/unifi"` | Container image name |
| image.tag | string | `""` (use appVersion in `Chart.yaml`) | Container image tag |
| ingress.annotations | object | `{}` | Annotations for Ingress resource |
| ingress.enabled | bool | `false` | Enable Ingress resource |
| ingress.enabled | bool | `true` | Enable Ingress resource |
| ingress.hosts | list | `["chart-example.local"]` | Hostname(s) for the Ingress resource |
| ingress.path | string | `"/"` | Ingress path |
| ingress.tls | list | `[]` | Ingress TLS configuration |
Expand All @@ -184,10 +184,10 @@ ingress:
| nodeSelector | object | `{}` | Node labels for pod assignment |
| persistence.accessMode | string | `"ReadWriteOnce"` | Persistence access modes |
| persistence.enabled | bool | `false` | Use persistent volume to store data |
| persistence.existingClaim | string | `nil` | Use an existing PVC to persist data |
| persistence.existingClaim | string | `""` | Use an existing PVC to persist data |
| persistence.size | string | `"5Gi"` | Size of persistent volume claim |
| persistence.skipuninstall | bool | `false` | Do not delete the pvc upon helm uninstall |
| persistence.storageClass | string | `nil` | Type of persistent volume claim |
| persistence.storageClass | string | `""` | Storage Class to use for the PVC |
| podAnnotations | object | `{}` | Annotations for UniFi pod |
| readinessProbe.enabled | bool | `true` | Enable readiness probe |
| readinessProbe.failureThreshold | int | `3` | Minimum consecutive failures for the probe to be considered failed after having succeeded. |
Expand All @@ -198,7 +198,7 @@ ingress:
| resources | object | `{}` | Set container requests and limits for different resources like CPU or memory |
| runAsRoot | bool | `false` | This is used to determine whether or not the UniFi service runs as a privileged (root) user. The default value is `true` but it is recommended to use `false` instead. |
| speedtestService.annotations | object | `{}` | Provide any additional annotations which may be required. This can be used to set the LoadBalancer service type to internal only. ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| speedtestService.enabled | bool | `false` | Enable service for mobile speedtest inside the UniFi Mobile app |
| speedtestService.enabled | bool | `true` | Enable service for mobile speedtest inside the UniFi Mobile app |
| speedtestService.externalTrafficPolicy | string | `nil` | Set the externalTrafficPolicy in the Service to either Cluster or Local |
| speedtestService.labels | object | `{}` | Labels to add to the speedtest service |
| speedtestService.loadBalancerIP | string | `nil` | Use loadBalancerIP to request a specific static IP, otherwise leave blank |
Expand All @@ -207,15 +207,15 @@ ingress:
| speedtestService.type | string | `"ClusterIP"` | Kubernetes service type |
| strategyType | string | `"Recreate"` | upgrade strategy type (e.g. Recreate or RollingUpdate) |
| stunService.annotations | object | `{}` | Provide any additional annotations which may be required. This can be used to set the LoadBalancer service type to internal only. ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| stunService.enabled | bool | `false` | Enable service the STUN feature |
| stunService.enabled | bool | `true` | Enable service the STUN feature |
| stunService.externalTrafficPolicy | string | `nil` | Set the externalTrafficPolicy in the Service to either Cluster or Local |
| stunService.labels | object | `{}` | Labels to add to the STUN service |
| stunService.loadBalancerIP | string | `nil` | Use loadBalancerIP to request a specific static IP, otherwise leave blank |
| stunService.loadBalancerSourceRanges | list | `nil` | loadBalancerSourceRanges |
| stunService.port | int | `3478` | Kubernetes port where the service is exposed |
| stunService.type | string | `"NodePort"` | Kubernetes service type |
| syslogService.annotations | object | `{}` | Provide any additional annotations which may be required. This can be used to set the LoadBalancer service type to internal only. ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| syslogService.enabled | bool | `false` | Enable service for the syslog server. Used to capture syslog from Unifi devices if the feature is enabled in the site configuration. |
| syslogService.enabled | bool | `true` | Enable service for the syslog server. Used to capture syslog from Unifi devices if the feature is enabled in the site configuration. |
| syslogService.externalTrafficPolicy | string | `nil` | Set the externalTrafficPolicy in the Service to either Cluster or Local |
| syslogService.labels | object | `{}` | Labels to add to the syslog service |
| syslogService.loadBalancerIP | string | `nil` | Use loadBalancerIP to request a specific static IP, otherwise leave blank |
Expand Down
6 changes: 3 additions & 3 deletions charts/unifi/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Ubiquiti Network's Unifi Controller

**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)**
**This chart is not maintained by the [upstream project](https://github.com/jacobalberty/unifi-docker) and any issues with the chart should be raised [here](https://github.com/mkilchhofer/unifi-chart/issues/new)**

{{ template "chart.sourcesSection" . }}

Expand Down Expand Up @@ -39,13 +39,13 @@ Specify each parameter using the `--set key=value[,key=value]` argument to `helm
```console
helm install unifi \
--set env.TZ="America/New York" \
k8s-at-home/unifi
oci://ghcr.io/mkilchhofer/unifi-chart/unifi
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.

```console
helm install unifi k8s-at-home/unifi -f values.yaml
helm install unifi oci://ghcr.io/mkilchhofer/unifi-chart/unifi -f values.yaml
```

## Custom configuration
Expand Down
40 changes: 17 additions & 23 deletions charts/unifi/templates/captive-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
{{- if (and .Values.captivePortalService.ingress.enabled (not .Values.unifiedService.enabled)) }}
{{- $fullName := include "unifi.fullname" . -}}
{{- $ingressPath := .Values.captivePortalService.ingress.path -}}
{{- $unifiedServiceEnabled := .Values.unifiedService.enabled -}}
{{- $captivePortalHttps := .Values.captivePortalService.https -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}-captive
labels:
app.kubernetes.io/name: {{ include "unifi.name" . }}
helm.sh/chart: {{ include "unifi.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.captivePortalService.ingress.annotations }}
{{- with .Values.captivePortalService.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.captivePortalService.ingress.tls }}
tls:
{{- range .Values.captivePortalService.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
{{- include "unifi.labels" . | nindent 4 }}
spec:
rules:
{{- range .Values.captivePortalService.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
- path: {{ $.Values.captivePortalService.ingress.path }}
pathType: Prefix
backend:
service:
name: {{ $fullName }}-captiveportalservice
port:
{{- if $captivePortalHttps }}
{{- if $.Values.captivePortalService.https }}
name: captive-https
{{- else }}
name: captive-http
{{- end }}
{{- end }}
{{- if .Values.captivePortalService.ingress.tls }}
tls:
{{- range .Values.captivePortalService.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
39 changes: 18 additions & 21 deletions charts/unifi/templates/captive-svc.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,39 @@
{{ if (and .Values.captivePortalService.enabled (not .Values.unifiedService.enabled)) }}
{{- if and .Values.captivePortalService.enabled (not .Values.unifiedService.enabled) }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "unifi.fullname" . }}-captiveportalservice
labels:
app.kubernetes.io/name: {{ include "unifi.name" . }}
helm.sh/chart: {{ include "unifi.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.captivePortalService.labels }}
{{ toYaml .Values.captivePortalService.labels | indent 4 }}
{{- end }}
{{- with .Values.captivePortalService.annotations }}
{{- include "unifi.labels" . | nindent 4 }}
{{- if .Values.captivePortalService.labels }}
{{- toYaml .Values.captivePortalService.labels | nindent 4 }}
{{- end }}
{{- with .Values.captivePortalService.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if (or (eq .Values.captivePortalService.type "ClusterIP") (empty .Values.captivePortalService.type)) }}
type: ClusterIP
{{- if .Values.captivePortalService.clusterIP }}
clusterIP: {{ .Values.captivePortalService.clusterIP }}
{{end}}
{{- end }}
{{- else if eq .Values.captivePortalService.type "LoadBalancer" }}
type: {{ .Values.captivePortalService.type }}
{{- if .Values.captivePortalService.loadBalancerIP }}
loadBalancerIP: {{ .Values.captivePortalService.loadBalancerIP }}
{{- end }}
{{- if .Values.captivePortalService.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.captivePortalService.loadBalancerSourceRanges | indent 4 }}
{{- toYaml .Values.captivePortalService.loadBalancerSourceRanges | nindent 4 }}
{{- end -}}
{{- else }}
type: {{ .Values.captivePortalService.type }}
{{- end }}
{{- if .Values.captivePortalService.externalIPs }}
{{- if .Values.captivePortalService.externalIPs }}
externalIPs:
{{ toYaml .Values.captivePortalService.externalIPs | indent 4 }}
{{- end }}
{{- toYaml .Values.captivePortalService.externalIPs | nindent 4 }}
{{- end }}
{{- if .Values.captivePortalService.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.captivePortalService.externalTrafficPolicy }}
{{- end }}
Expand All @@ -45,16 +42,16 @@ spec:
targetPort: captive-http
protocol: TCP
name: captive-http
{{ if (and (eq .Values.captivePortalService.type "NodePort") (not (empty .Values.captivePortalService.http))) }}
{{- if (and (eq .Values.captivePortalService.type "NodePort") (not (empty .Values.captivePortalService.http))) }}
nodePort: {{.Values.captivePortalService.http}}
{{ end }}
{{- end }}
- port: {{ .Values.captivePortalService.https }}
targetPort: captive-https
protocol: TCP
name: captive-https
{{ if (and (eq .Values.captivePortalService.type "NodePort") (not (empty .Values.captivePortalService.https))) }}
{{- if (and (eq .Values.captivePortalService.type "NodePort") (not (empty .Values.captivePortalService.https))) }}
nodePort: {{.Values.captivePortalService.https}}
{{ end }}
{{- end }}
selector:
{{- include "unifi.selectorLabels" . | nindent 6 }}
{{ end }}
{{- end }}
7 changes: 2 additions & 5 deletions charts/unifi/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ apiVersion: v1
metadata:
name: {{ template "unifi.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "unifi.name" . }}
helm.sh/chart: {{ include "unifi.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "unifi.labels" . | nindent 4 }}
data:
{{ toYaml .Values.extraConfigFiles | indent 2 }}
{{- toYaml .Values.extraConfigFiles | nindent 2 }}
{{- end }}
39 changes: 17 additions & 22 deletions charts/unifi/templates/controller-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
{{- if (and .Values.controllerService.ingress.enabled (not .Values.unifiedService.enabled)) }}
{{- $fullName := include "unifi.fullname" . -}}
{{- $ingressPath := .Values.controllerService.ingress.path -}}
{{- $unifiedServiceEnabled := .Values.unifiedService.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}-controller
labels:
app.kubernetes.io/name: {{ include "unifi.name" . }}
helm.sh/chart: {{ include "unifi.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.controllerService.ingress.annotations }}
{{- with .Values.controllerService.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.controllerService.ingress.tls }}
tls:
{{- range .Values.controllerService.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
labels:
{{- include "unifi.labels" . | nindent 4 }}
spec:
rules:
{{- range .Values.controllerService.ingress.hosts }}
{{- range .Values.controllerService.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
- path: {{ $.Values.controllerService.ingress.path }}
pathType: Prefix
backend:
service:
name: {{ $fullName }}-controller
port:
name: controller
{{- end }}
{{- if .Values.controllerService.ingress.tls }}
tls:
{{- range .Values.controllerService.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit d8508cd

Please sign in to comment.