-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: get proxy API can query proxies from k8s-gateway (#9226)
* env: inject deployer image.tag * use plugin registry from extensions * fix import cycle in gloo translator * WIP - supoort proxy cache * supoort proxy source in request * use settings instead of whole opts * more api enhancements, cli todo * introduce port-forward utility * Cli uses new port forward utility * expand get proxies request * cleanup code * undo changes unrelated to proxy endpoit api * generated code * define rest.config once * check proxies ignores k8s gateway proxies without status * wrap error to improve debugability * fix glooctl check unit test * improve helm tests * add changelog * use 1.12.0: after the grpc api was first introduced * remove problematic helm tests * cleanup channel management * bad ref to readyCh * new gloo verion, update default validation max bytes * delete more helm tests that are out of date * order inputs, add comments * support getting all proxies * rework port-forwarding * fix compile issue, waitForStop * Adding changelog file to new location * Deleting changelog file from old location * goimports * go mod tidy * improve error handling * sync access to cmd * generated code * close requires write lock * lock all operations * always use CLI for port forwarding...for now * fix up port-forwarding * goimports * use CLI for now, comment why API portforward API is faulty * add comments around CLI API * cleanup cmd.Ctx * pass context. avoid cancelling prematurely * use default options * pass context ot function * Update projects/gloo/cli/pkg/cmd/options/options.go Co-authored-by: Jenny Shu <28537278+jenshu@users.noreply.github.com> * update changelog --------- Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com> Co-authored-by: changelog-bot <changelog-bot> Co-authored-by: Jenny Shu <28537278+jenshu@users.noreply.github.com>
- Loading branch information
1 parent
844b441
commit fc354df
Showing
35 changed files
with
1,350 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
changelog: | ||
- type: BREAKING_CHANGE | ||
issueLink: https://github.com/solo-io/solo-projects/issues/5874 | ||
resolvesIssue: false | ||
description: >- | ||
`glooctl get proxy` will not work if you have persisted Proxy CRs in etcD and you are querying | ||
and older server version (1.16 and below). In general, we recommend that you keep your client and | ||
server versions in sync. You can verify the client/server versions you are currently running by calling `glooctl version`. | ||
- type: NON_USER_FACING | ||
issueLink: https://github.com/solo-io/solo-projects/issues/5874 | ||
resolvesIssue: false | ||
description: >- | ||
Update the ProxyEndpointServer API to support returning proxies produced by the K8s Gateway translator. | ||
Update the CLI fix the `get proxy` API so that you can effectively query proxies. | ||
Introduce a PortForwarder. | ||
- type: NON_USER_FACING | ||
issueLink: https://github.com/solo-io/gloo/issues/6661 | ||
resolvesIssue: false | ||
description: >- | ||
Remove helm upgrade tests that upgrade from a version of Gloo (1.11) that is no longer in the support window. |
6 changes: 4 additions & 2 deletions
6
...github.com/solo-io/gloo/projects/gloo/api/grpc/debug/proxy_endpoint.proto.sk.md
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package kubeutils | ||
|
||
const ( | ||
GlooDeploymentName = "gloo" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package kubeutils | ||
|
||
import ( | ||
"context" | ||
|
||
"k8s.io/client-go/rest" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/fields" | ||
"k8s.io/apimachinery/pkg/labels" | ||
"k8s.io/client-go/kubernetes" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// Inspired by: https://github.com/solo-io/gloo-mesh-enterprise/blob/main/pkg/utils/kubeutils/pods.go | ||
|
||
// GetPodsForDeployment gets all pods backing a deployment | ||
func GetPodsForDeployment( | ||
ctx context.Context, | ||
restConfig *rest.Config, | ||
deploymentName string, | ||
deploymentNamespace string, | ||
) ([]string, error) { | ||
kubeClient, err := kubernetes.NewForConfig(restConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
deployment, err := kubeClient.AppsV1().Deployments(deploymentNamespace).Get(ctx, deploymentName, metav1.GetOptions{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
matchLabels := deployment.Spec.Selector.MatchLabels | ||
listOptions := (&client.ListOptions{ | ||
LabelSelector: labels.SelectorFromSet(matchLabels), | ||
FieldSelector: fields.Set{"status.phase": "Running"}.AsSelector(), | ||
}).AsListOptions() | ||
|
||
podList, err := kubeClient.CoreV1().Pods(deploymentNamespace).List(ctx, *listOptions) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pods := make([]string, len(podList.Items)) | ||
for i := range podList.Items { | ||
pods[i] = podList.Items[i].Name | ||
} | ||
|
||
return pods, nil | ||
} | ||
|
||
// GetPodsForService gets all pods backing a deployment | ||
func GetPodsForService( | ||
ctx context.Context, | ||
restConfig *rest.Config, | ||
serviceName string, | ||
serviceNamespace string, | ||
) ([]string, error) { | ||
kubeClient, err := kubernetes.NewForConfig(restConfig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
service, err := kubeClient.CoreV1().Services(serviceNamespace).Get(ctx, serviceName, metav1.GetOptions{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
matchLabels := service.Spec.Selector | ||
listOptions := (&client.ListOptions{LabelSelector: labels.SelectorFromSet(matchLabels)}).AsListOptions() | ||
|
||
podList, err := kubeClient.CoreV1().Pods(serviceNamespace).List(ctx, *listOptions) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pods := make([]string, len(podList.Items)) | ||
for i := range podList.Items { | ||
pods[i] = podList.Items[i].Name | ||
} | ||
|
||
return pods, nil | ||
} |
Oops, something went wrong.