mirror of
https://github.com/outbackdingo/cozystack.git
synced 2026-01-27 10:18:39 +00:00
[platform] Autodetect RobotLB (#1271)
If running in Hetzner and using Hetzner's cloud load balancers, node ports need to be allocated for the load balancer to function correctly. Therefore if RobotLB is enabled, we probably need to assign node ports. Release note: [platform] Autodetect if node ports should be assigned to load balancer services.
This commit is contained in:
@@ -8,7 +8,9 @@ spec:
|
||||
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
|
||||
{{- if .Values.external }}
|
||||
externalTrafficPolicy: Local
|
||||
{{- if (include "cozy-lib.network.disableLoadBalancerNodePorts" $ | fromYaml) }}
|
||||
allocateLoadBalancerNodePorts: false
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: ferretdb
|
||||
|
||||
@@ -10,7 +10,9 @@ spec:
|
||||
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
|
||||
{{- if .Values.external }}
|
||||
externalTrafficPolicy: Local
|
||||
{{- if (include "cozy-lib.network.disableLoadBalancerNodePorts" $ | fromYaml) }}
|
||||
allocateLoadBalancerNodePorts: false
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
app: {{ .Release.Name }}-haproxy
|
||||
|
||||
@@ -7,7 +7,9 @@ spec:
|
||||
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
|
||||
{{- if .Values.external }}
|
||||
externalTrafficPolicy: Local
|
||||
{{- if (include "cozy-lib.network.disableLoadBalancerNodePorts" $ | fromYaml) }}
|
||||
allocateLoadBalancerNodePorts: false
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: postgres
|
||||
|
||||
@@ -11,7 +11,9 @@ spec:
|
||||
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
|
||||
{{- if .Values.external }}
|
||||
externalTrafficPolicy: Local
|
||||
{{- if (include "cozy-lib.network.disableLoadBalancerNodePorts" $ | fromYaml) }}
|
||||
allocateLoadBalancerNodePorts: false
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
app.kubernetes.io/component: redis
|
||||
|
||||
@@ -10,7 +10,9 @@ spec:
|
||||
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
|
||||
{{- if .Values.external }}
|
||||
externalTrafficPolicy: Local
|
||||
{{- if (include "cozy-lib.network.disableLoadBalancerNodePorts" $ | fromYaml) }}
|
||||
allocateLoadBalancerNodePorts: false
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
selector:
|
||||
app: {{ .Release.Name }}-haproxy
|
||||
|
||||
@@ -13,7 +13,9 @@ metadata:
|
||||
spec:
|
||||
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
|
||||
externalTrafficPolicy: Local
|
||||
{{- if (include "cozy-lib.network.disableLoadBalancerNodePorts" $ | fromYaml) }}
|
||||
allocateLoadBalancerNodePorts: false
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "virtual-machine.selectorLabels" . | nindent 4 }}
|
||||
ports:
|
||||
|
||||
@@ -13,7 +13,9 @@ metadata:
|
||||
spec:
|
||||
type: {{ ternary "LoadBalancer" "ClusterIP" .Values.external }}
|
||||
externalTrafficPolicy: Local
|
||||
{{- if (include "cozy-lib.network.disableLoadBalancerNodePorts" $ | fromYaml) }}
|
||||
allocateLoadBalancerNodePorts: false
|
||||
{{- end }}
|
||||
selector:
|
||||
{{- include "virtual-machine.selectorLabels" . | nindent 4 }}
|
||||
ports:
|
||||
|
||||
23
packages/library/cozy-lib/templates/_network.tpl
Normal file
23
packages/library/cozy-lib/templates/_network.tpl
Normal file
@@ -0,0 +1,23 @@
|
||||
{{- define "cozy-lib.network.defaultDisableLoadBalancerNodePorts" }}
|
||||
{{/* Default behavior prior to introduction */}}
|
||||
{{- `true` }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Invoke as {{ include "cozy-lib.network.disableLoadBalancerNodePorts" $ }}.
|
||||
Detects whether the current load balancer class requires nodeports to function
|
||||
correctly. Currently just checks if Hetzner's RobotLB is enabled, which does
|
||||
require nodeports, and so, returns `false`. Otherwise assumes that metallb is
|
||||
in use and returns `true`.
|
||||
*/}}
|
||||
|
||||
{{- define "cozy-lib.network.disableLoadBalancerNodePorts" }}
|
||||
{{- include "cozy-lib.loadCozyConfig" (list "" .) }}
|
||||
{{- $cozyConfig := index . 1 "cozyConfig" }}
|
||||
{{- if not $cozyConfig }}
|
||||
{{- include "cozy-lib.network.defaultDisableLoadBalancerNodePorts" . }}
|
||||
{{- else }}
|
||||
{{- $enabledComponents := splitList "," ((index $cozyConfig.data "bundle-enable") | default "") }}
|
||||
{{- not (has "robotlb" $enabledComponents) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user