Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net 6289 improve consul api gateway annotations #3437

Merged
merged 15 commits into from
Jan 16, 2024

Conversation

sarahalsmiller
Copy link
Member

Changes proposed in this PR

  • Add annotations to the API Gateway that ensure

How I've tested this PR

  • Local unit tests
  • Local kind install

How I expect reviewers to test this PR

  • Local kind install
  • CI Passes

Checklist

@sarahalsmiller
Copy link
Member Author

References NET-6289-Improve-Consul-API-Gateway-annotations](#3171

@sarahalsmiller sarahalsmiller marked this pull request as ready for review January 8, 2024 17:01
Copy link
Member

@nathancoleman nathancoleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing this across the finish line!

.changelog/3437.txt Outdated Show resolved Hide resolved
cli/cmd/proxy/list/command.go Outdated Show resolved Hide resolved
cli/cmd/proxy/list/command.go Outdated Show resolved Hide resolved
cli/cmd/proxy/list/command.go Outdated Show resolved Hide resolved
cli/cmd/proxy/list/command_test.go Outdated Show resolved Hide resolved
cli/cmd/proxy/list/command_test.go Outdated Show resolved Hide resolved
cli/cmd/proxy/list/command_test.go Outdated Show resolved Hide resolved
@sarahalsmiller sarahalsmiller force-pushed the NET-6289-Improve-Consul-API-Gateway-annotations branch from a767518 to 15d073b Compare January 8, 2024 17:52

// Fallback to "Sidecar" as a default
if proxyType == "" {
default:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice clean up for this switch statement

@sarahalsmiller sarahalsmiller force-pushed the NET-6289-Improve-Consul-API-Gateway-annotations branch from cd77a71 to 4fc14d1 Compare January 11, 2024 19:09
Comment on lines +223 to +224
// TODO this block can be deleted if and when we decide we are ok with no longer listing pods of people using previous API Gateway
// versions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth signing this with your GitHub id so people know who wrote it (without using Git blame).

Comment on lines +229 to +231
namespacedName := func(pod v1.Pod) string {
return pod.Namespace + pod.Name
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine in this context, but this has the same name as a struct in Kubernetes that is structured somewhat differently. If you wanted to leverage this struct, it might be more "idiomatic". Because it has a string method itself, the behavior will be identical when used with formatting or with string().

https://github.com/kubernetes/apimachinery/blob/master/pkg/types/namespacedname.go

Again, not a blocker, just a little note.

Copy link
Contributor

@t-eckert t-eckert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a great quality of life improvement!

cli/cmd/proxy/list/command.go Outdated Show resolved Hide resolved
func isGateway(pod corev1.Pod) bool {
anno, ok := pod.Annotations[constants.AnnotationGatewayKind]
return ok && anno != ""
return ok && anno != "" && anno != apiGateway
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

nathancoleman and others added 14 commits January 16, 2024 15:30
…eway

This makes api-gateway behave the same as ingress, mesh and terminating gateways; however, it won't pick up pods created by the legacy consul-api-gateway controller.
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
@sarahalsmiller sarahalsmiller force-pushed the NET-6289-Improve-Consul-API-Gateway-annotations branch from 4fc14d1 to 67bef5a Compare January 16, 2024 21:30
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
@sarahalsmiller sarahalsmiller merged commit a5fe410 into main Jan 16, 2024
31 of 48 checks passed
@sarahalsmiller sarahalsmiller deleted the NET-6289-Improve-Consul-API-Gateway-annotations branch January 16, 2024 22:16
@missylbytes missylbytes added the backport/1.2.x This release branch is no longer active. label Feb 13, 2024
missylbytes pushed a commit that referenced this pull request Feb 14, 2024
* Add api-gateway to allow list for gateway-kind annotation

* Update godoc for AnnotationGatewayKind to list correct allowable values

* Exclude api-gateway kind when checking if endpoints controller should act on gateway

* Add gateway-kind and gateway-consul-service-name annotations to API gateway pods

* Add appropriate component label to api-gateway pods

* Update consul-k8s CLI to rely on standard component label for api-gateway

This makes api-gateway behave the same as ingress, mesh and terminating gateways; however, it won't pick up pods created by the legacy consul-api-gateway controller.

* add backwards compatabiilty, additional tests

* add changelog

* Update .changelog/3437.txt

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

* Update cli/cmd/proxy/list/command.go

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

* Update cli/cmd/proxy/list/command_test.go

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

* Update cli/cmd/proxy/list/command_test.go

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

* Update cli/cmd/proxy/list/command.go

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

* cleanup

* Update cli/cmd/proxy/list/command.go

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>

---------

Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
missylbytes pushed a commit that referenced this pull request Feb 14, 2024
…ase/1.2.x (#3627)

Net 6289 improve consul api gateway annotations (#3437)

* Add api-gateway to allow list for gateway-kind annotation

* Update godoc for AnnotationGatewayKind to list correct allowable values

* Exclude api-gateway kind when checking if endpoints controller should act on gateway

* Add gateway-kind and gateway-consul-service-name annotations to API gateway pods

* Add appropriate component label to api-gateway pods

* Update consul-k8s CLI to rely on standard component label for api-gateway

This makes api-gateway behave the same as ingress, mesh and terminating gateways; however, it won't pick up pods created by the legacy consul-api-gateway controller.

* add backwards compatabiilty, additional tests

* add changelog

* Update .changelog/3437.txt



* Update cli/cmd/proxy/list/command.go



* Update cli/cmd/proxy/list/command_test.go



* Update cli/cmd/proxy/list/command_test.go



* Update cli/cmd/proxy/list/command.go



* cleanup

* Update cli/cmd/proxy/list/command.go



---------

Co-authored-by: sarahalsmiller <100602640+sarahalsmiller@users.noreply.github.com>
Co-authored-by: Nathan Coleman <nathan.coleman@hashicorp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.2.x This release branch is no longer active. backport/1.3.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants