Skip to content

Commit

Permalink
feat: add missing Service spec fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mloiseleur authored Feb 9, 2024
1 parent 41373dd commit 8fba4e1
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 5 deletions.
22 changes: 22 additions & 0 deletions traefikee/templates/proxy/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,31 @@ metadata:
spec:
type: {{ $proxy.serviceType | default "LoadBalancer" }}
ports: {{ toYaml $proxy.servicePorts | nindent 4 }}
{{- with $proxy.clusterIP }}
clusterIP: {{ . }}
{{- end }}
{{- with $proxy.externalIPs }}
externalIPs: {{- toYaml . | nindent 2 }}
{{- end }}
{{- with $proxy.externalTrafficPolicy }}
externalTrafficPolicy: {{ . }}
{{- end }}
{{- with $proxy.ipFamilyPolicy }}
ipFamilyPolicy: {{ . }}
{{- end }}
{{- with $proxy.ipFamilies }}
ipFamilies: {{- toYaml . | nindent 2 }}
{{- end }}
{{- with $proxy.loadBalancerClass }}
loadBalancerClass: {{ . }}
{{- end }}
{{- with $proxy.loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- with $proxy.loadBalancerSourceRanges }}
loadBalancerSourceRanges: {{- toYaml . | nindent 2 }}
{{- end }}

selector:
app: traefikee
release: {{ $.Values.cluster }}
Expand Down
37 changes: 34 additions & 3 deletions traefikee/tests/proxy_service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ tests:
- equal:
path: spec.loadBalancerIP
value: "1.2.3.4"
- it: should set loadbalancerIP
- it: should set service spec options
set:
proxy:
loadBalancerIP: "1.2.3.4"
serviceType: LoadBalancer
clusterIP: "1.2.3.4"
externalIPs: [ "1.1.1.1", "2.2.2.2" ]
## One of Cluster or Local
externalTrafficPolicy: Cluster
## One of SingleStack, PreferDualStack, or RequireDualStack.
ipFamilyPolicy: SingleStack
## List of IP families (e.g. IPv4 and/or IPv6).
ipFamilies: [ "IPv4", "IPv6" ]
loadBalancerClass: "lb"
loadBalancerIP: "5.6.7.8"
loadBalancerSourceRanges: [ "3.3.3.3/28", "4.4.4.4/32" ]
asserts:
- isKind:
of: Service
Expand All @@ -64,8 +74,29 @@ tests:
path: spec.type
value: LoadBalancer
- equal:
path: spec.loadBalancerIP
path: spec.clusterIP
value: "1.2.3.4"
- lengthEqual:
path: spec.externalIPs
count: 2
- equal:
path: spec.externalTrafficPolicy
value: "Cluster"
- equal:
path: spec.ipFamilyPolicy
value: "SingleStack"
- lengthEqual:
path: spec.ipFamilies
count: 2
- equal:
path: spec.loadBalancerClass
value: "lb"
- equal:
path: spec.loadBalancerIP
value: "5.6.7.8"
- lengthEqual:
path: spec.loadBalancerSourceRanges
count: 2
- it: should have label selector
set:
cluster: mysupertraefikee
Expand Down
16 changes: 14 additions & 2 deletions traefikee/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,20 @@ proxy:
- name: https
port: 443
targetPort: https
# # Specify Static IP of cloud provider LB
# loadBalancerIP: "1.2.3.4"
## Service spec options
## /!\ Note: some Service fields are immutable.
## `helm upgrade --force [...]` can be used to replace resources with immutable fields.
clusterIP:
externalIPs:
## One of Cluster or Local
externalTrafficPolicy:
## One of SingleStack, PreferDualStack, or RequireDualStack.
ipFamilyPolicy:
## List of IP families (e.g. IPv4 and/or IPv6).
ipFamilies:
loadBalancerClass:
loadBalancerIP:
loadBalancerSourceRanges:

# To disable affinity at all set this value to null
affinity:
Expand Down

0 comments on commit 8fba4e1

Please sign in to comment.