Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[unifi-controller] Support Service LoadBalancer #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/unifi-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ maintainers:
- name: David Girón
url: https://github.com/duhow

version: 0.0.4
version: 0.1.0
# renovate: datasource=docker depName=linuxserver/unifi-controller
appVersion: 7.3.83
80 changes: 80 additions & 0 deletions charts/unifi-controller/templates/service-lb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{{- if eq .Values.service.type "LoadBalancer" }}

{{- $proto := "tcp" }}
{{- $hasServicesEnabled := false }}
{{- range $svc, $data := get .Values.service.ports $proto }}
{{- if $data.enabled }}
{{- $hasServicesEnabled = true }}
{{- end }}
{{- end }}

{{- if $hasServicesEnabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "unifi.fullname" . }}-{{ $proto }}
labels:
{{- include "unifi.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- with .Values.service.loadBalancerIP }}
loadBalancerIP: {{ . | quote }}
{{- end }}
ports:
{{- range $svc, $data := get .Values.service.ports $proto }}
{{- if $data.enabled }}
- name: {{ $svc }}
port: {{ $data.port }}
protocol: {{ $proto | upper }}
targetPort: {{ $svc }}
{{- end }}
{{- end }}
selector:
{{- include "unifi.selectorLabels" . | nindent 4 }}
{{- end }}


{{- $proto := "udp" }}
{{- $hasServicesEnabled := false }}
{{- range $svc, $data := get .Values.service.ports $proto }}
{{- if $data.enabled }}
{{- $hasServicesEnabled = true }}
{{- end }}
{{- end }}

{{- if $hasServicesEnabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "unifi.fullname" . }}-{{ $proto }}
labels:
{{- include "unifi.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- with .Values.service.loadBalancerIP }}
loadBalancerIP: {{ . | quote }}
{{- end }}
ports:
{{- range $svc, $data := get .Values.service.ports $proto }}
{{- if $data.enabled }}
- name: {{ $svc }}
port: {{ $data.port }}
protocol: {{ $proto | upper }}
targetPort: {{ $svc }}
{{- end }}
{{- end }}
selector:
{{- include "unifi.selectorLabels" . | nindent 4 }}
{{- end }}

{{- end }}
7 changes: 7 additions & 0 deletions charts/unifi-controller/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{{- if ne .Values.service.type "LoadBalancer" }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "unifi.fullname" . }}
labels:
{{- include "unifi.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -13,3 +19,4 @@ spec:
name: http
selector:
{{- include "unifi.selectorLabels" . | nindent 4 }}
{{- end }}
33 changes: 33 additions & 0 deletions charts/unifi-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,40 @@ hostNetwork: true

service:
type: ClusterIP
annotations: {}
loadBalancerIP: null
port: 8443
# -- Used for LoadBalancer Service type
ports:
tcp:
https:
enabled: true
port: 8443
http:
enabled: false
port: 8080
guest-https:
enabled: false
port: 8843
guest-http:
enabled: false
port: 8880
throughput:
enabled: false
port: 6789
udp:
stun:
enabled: false
port: 3478
l2-discovery:
enabled: false
port: 1900
ap-discovery:
enabled: false
port: 10001
syslog:
enabled: false
port: 5514

ingress:
enabled: false
Expand Down