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

egctl: add label selector for egctl config dump of Pod #1385

Merged
merged 7 commits into from
May 5, 2023

Conversation

chauhanshubham
Copy link
Member

While using egctl config envoy-proxy CLI, there is an additional step
to fetch the Pod name which can then be used in the egctl command.
This commit adds support to select a Pod based on label selectors, so that
it's easier to query for the envoy-proxy config of that Pod with something like

egctl config envoy-proxy cluster -l gateway.envoyproxy.io/owning-gateway-name=eg -l gateway.envoyproxy.io/owning-gateway-namespace=default

where we can use the envoy gateway owner labels to fetch the Pod. This
eliminates the need to get the Pod name specifically.

Right now this commit adds a limitation that the label selectors must select one and only one Pod.
If there are more than one pods selected, there is a requirement to change the output format,
something like

{
  "<pod-name>": {
    "config": {}
  }
}

which is still open for discussion, as part of issue #1069

@chauhanshubham chauhanshubham requested a review from a team as a code owner May 2, 2023 04:58
@codecov
Copy link

codecov bot commented May 2, 2023

Codecov Report

Merging #1385 (e439f70) into main (eee6d39) will decrease coverage by 0.03%.
The diff coverage is 32.30%.

@@            Coverage Diff             @@
##             main    #1385      +/-   ##
==========================================
- Coverage   62.34%   62.31%   -0.03%     
==========================================
  Files          78       78              
  Lines       10973    11024      +51     
==========================================
+ Hits         6841     6870      +29     
- Misses       3680     3697      +17     
- Partials      452      457       +5     
Impacted Files Coverage Δ
internal/cmd/egctl/config_bootstrap.go 0.00% <0.00%> (ø)
internal/cmd/egctl/config_cluster.go 0.00% <0.00%> (ø)
internal/cmd/egctl/config_cmd.go 0.00% <0.00%> (ø)
internal/cmd/egctl/config_endpoint.go 0.00% <0.00%> (ø)
internal/cmd/egctl/config_listener.go 0.00% <0.00%> (ø)
internal/cmd/egctl/config_route.go 0.00% <0.00%> (ø)
internal/cmd/egctl/config.go 40.44% <40.20%> (+14.85%) ⬆️
internal/cmd/egctl/utils.go 90.62% <100.00%> (+0.62%) ⬆️

... and 1 file with indirect coverage changes

if len(podList.Items) == 0 {
return nil, fmt.Errorf("no Pods found for label selectors %+v", labelSelectors)
}
if len(podList.Items) > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why the 1 pod limitation is added ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was not clear how do we output configs of multiple Pods. right now config of one pod is a singular json (lets say {....}), so for the output of multiple Pods could we output it as follows?

{
    pod-name-1: {....},
    pod-name-2: {....},
}

because the config output doesn't have a pod name reference, so how do we differentiate between multiple dumps.
So I just limited it to 1 for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah got it, yah a map works, thats what we recently did with translate


could be done here or lets raise a issue to this can be tracked
cc @zirain

Copy link
Member Author

Choose a reason for hiding this comment

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

wouldn't <namespace>-<name> be tricky to interpret given that both of them can have - in their names?

Copy link
Member Author

@chauhanshubham chauhanshubham May 2, 2023

Choose a reason for hiding this comment

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

I think we need some spec around these usecases, maybe something like this?

{
    ns-1: {
        pod-name-1: {....},
        pod-name-2: {....},
    },
}

Copy link
Contributor

@arkodg arkodg May 2, 2023

Choose a reason for hiding this comment

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

we are using ns-name across the project as a key for config e.g

func irStringKey(gateway *v1beta1.Gateway) string {

 ns-1: {
        pod-name-1: {....},

gets tricky because it makes the definition more Kubernetesy which we should ideally avoid, if we want to support other environments

Copy link
Contributor

Choose a reason for hiding this comment

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

thinking again, something like

 ns-1: {
        pod-name-1: {....},

is more readable for the end user, which might make sense

Copy link
Member

Choose a reason for hiding this comment

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

thinking again, something like

 ns-1: {
        pod-name-1: {....},

is more readable for the end user, which might make sense

+1 for this style for visibility

Copy link
Member

Choose a reason for hiding this comment

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

thinking again, something like

 ns-1: {
        pod-name-1: {....},

is more readable for the end user, which might make sense

+1 for this

Copy link
Member Author

Choose a reason for hiding this comment

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

nice. will output in this format then, and update the PR

Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Signed-off-by: Shubham Chauhan <shubham@tetrate.io>
Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks !

@arkodg arkodg requested review from Alice-Lilith and qicz May 3, 2023 18:37
Copy link
Member

@qicz qicz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@zirain zirain merged commit a66d864 into envoyproxy:main May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants