diff --git a/.changelog/3905.txt b/.changelog/3905.txt new file mode 100644 index 0000000000..f5aec57cb1 --- /dev/null +++ b/.changelog/3905.txt @@ -0,0 +1,3 @@ +```release-note:improvement +helm: support sync-lb-services-endpoints flag for syncCatalog +``` \ No newline at end of file diff --git a/charts/consul/templates/sync-catalog-deployment.yaml b/charts/consul/templates/sync-catalog-deployment.yaml index 8bd3e0af61..3851f0a8e2 100644 --- a/charts/consul/templates/sync-catalog-deployment.yaml +++ b/charts/consul/templates/sync-catalog-deployment.yaml @@ -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 diff --git a/charts/consul/test/unit/sync-catalog-deployment.bats b/charts/consul/test/unit/sync-catalog-deployment.bats index 0c9579df20..b60b030ac0 100755 --- a/charts/consul/test/unit/sync-catalog-deployment.bats +++ b/charts/consul/test/unit/sync-catalog-deployment.bats @@ -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 diff --git a/charts/consul/values.yaml b/charts/consul/values.yaml index 4939fba373..ec6263ad80 100644 --- a/charts/consul/values.yaml +++ b/charts/consul/values.yaml @@ -2182,6 +2182,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