Skip to content

Commit

Permalink
Backport of Catalog: Use EndpointSlice and propagate Kubernetes Topol…
Browse files Browse the repository at this point in the history
…ogy information to synced consul service into release/1.2.x (#3780)

* backport of commit b8e5ece

* backport of commit ee26768

* backport of commit 4a3c209

* backport of commit c11b034

* backport of commit 093826a

* backport of commit 75810ab

* backport of commit f0f1762

* backport of commit 395c4fe

* backport of commit 73ffbcb

* backport of commit cc5d60c

* backport of commit 0d8b7ae

* backport of commit 5dcb453

* backport of commit 09506ba

* Catalog: Use EndpointSlice and propagate Kubernetes Topology information to synced consul service (#3693)

* Use EndpointSlice and propagate zone metadata to consul service

* Fix tests

* Add test for zone metadata

* Cleanup and changelog entry

* Fix clusterrole permissions and type on Informer

* Include region info for NodePort services

* Include topology region for all service types

* Update release note

* Fix tests

* fix sync-catalog-clusterrole and tests

* fix stash conflict

* adding endpoints permission back to sync catalog since it still uses it.

* Fix endpointslice map

* Fix topology region

* Remove region lookups, remove endpoints permissions, use pointers for endpointslice map

* Drop region test

---------

Co-authored-by: John Murret <john.murret@hashicorp.com>

---------

Co-authored-by: jukie <10012479+Jukie@users.noreply.github.com>
Co-authored-by: John Murret <john.murret@hashicorp.com>
  • Loading branch information
3 people committed Mar 19, 2024
1 parent 4d51e9b commit 3f31a6c
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 214 deletions.
3 changes: 3 additions & 0 deletions .changelog/3693.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
catalog: Topology zone and region information is now read from the Kubernetes endpoints and associated node and added to registered consul services under Metadata.
```
16 changes: 14 additions & 2 deletions charts/consul/templates/sync-catalog-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ rules:
- apiGroups: [ "" ]
resources:
- services
- endpoints
verbs:
- get
- list
- watch
{{- if .Values.syncCatalog.toK8S }}
- update
- patch
- delete
- create
{{- end }}
- apiGroups: ["discovery.k8s.io"]
resources:
- endpointslices
verbs:
- get
- list
Expand Down Expand Up @@ -45,4 +57,4 @@ rules:
- get
- list
- watch
{{- end }}
{{- end }}
10 changes: 9 additions & 1 deletion charts/consul/test/unit/sync-catalog-clusterrole.bats
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ load _helpers
--set 'syncCatalog.enabled=true' \
--set 'global.enablePodSecurityPolicies=true' \
. | tee /dev/stderr |
yq -r '.rules[2].resources[0]' | tee /dev/stderr)
yq -r '.rules[3].resources[0]' | tee /dev/stderr)
[ "${actual}" = "podsecuritypolicies" ]
}

Expand All @@ -83,4 +83,12 @@ load _helpers
. | tee /dev/stderr |
yq -c '.rules[0].verbs' | tee /dev/stderr)
[ "${actual}" = '["get","list","watch","update","patch","delete","create"]' ]

actual=$(helm template \
-s templates/sync-catalog-clusterrole.yaml \
--set 'syncCatalog.enabled=true' \
--set 'syncCatalog.toK8S=true' \
. | tee /dev/stderr |
yq -c '.rules[0].verbs' | tee /dev/stderr)
[ "${actual}" = '["get","list","watch","update","patch","delete","create"]' ]
}

0 comments on commit 3f31a6c

Please sign in to comment.