Skip to content

Commit

Permalink
Helm: support sync-lb-services-endpoints for sync catalog (#3905)
Browse files Browse the repository at this point in the history
* Helm: support sync-lb-services-endpoints for sync catalog

* add test

* fix template tag order

---------

Co-authored-by: jukie <[email protected]>
  • Loading branch information
zalimeni and jukie authored Apr 12, 2024
1 parent e575eb2 commit 8ac97bf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/3905.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
helm: support sync-lb-services-endpoints flag for syncCatalog
```
3 changes: 3 additions & 0 deletions charts/consul/templates/sync-catalog-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ spec:
-loadBalancer-ips=true \
{{- end }}
{{- end }}
{{- if .Values.syncCatalog.syncLoadBalancerEndpoints }}
-sync-lb-services-endpoints=true \
{{- end }}
livenessProbe:
httpGet:
path: /health/ready
Expand Down
23 changes: 23 additions & 0 deletions charts/consul/test/unit/sync-catalog-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,29 @@ load _helpers
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# syncLoadBalancerEndpoints

@test "syncCatalog/Deployment: enable LB endpoints sync flag not passed when disabled" {
cd `chart_dir`
local actual=$(helm template \
-s templates/sync-catalog-deployment.yaml \
--set 'syncCatalog.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-sync-lb-services-endpoints=true"))' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "syncCatalog/Deployment: enable LB endpoints sync flag passed when enabled" {
cd `chart_dir`
local actual=$(helm template \
-s templates/sync-catalog-deployment.yaml \
--set 'syncCatalog.enabled=true' \
--set 'syncCatalog.syncLoadBalancerEndpoints=true' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-sync-lb-services-endpoints=true"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

#--------------------------------------------------------------------
# affinity

Expand Down
4 changes: 4 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,10 @@ syncCatalog:
# Set this to false to skip syncing ClusterIP services.
syncClusterIPServices: true

# If true, LoadBalancer service endpoints instead of ingress addresses will be synced to Consul.
# If false, LoadBalancer endpoints are not synced to Consul.
syncLoadBalancerEndpoints: false

ingress:
# Syncs the hostname from a Kubernetes Ingress resource to service registrations
# when a rule matched a service. Currently only supports host based routing and
Expand Down

0 comments on commit 8ac97bf

Please sign in to comment.