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-11256] Add gateway read command to consul-k8s CLI #4432

Merged
merged 11 commits into from
Nov 29, 2024

Conversation

nathancoleman
Copy link
Member

@nathancoleman nathancoleman commented Nov 26, 2024

Note

This PR is blocked by the bug fix in #4434 which is preventing tests from passing

Changes proposed in this PR

This PR adds a new command, consul-k8s gateway read, which collects the various components of configuration for a given Consul API Gateway – Gateway, attached HTTPRoutes, attached TCPRoutes, etc. – into a single yaml file.

It can output an archive named after the read gateway into the current directory, or it can output JSON to the terminal.

# Output a zip archive for my-gateway in the current namespace on your kubecontext
$ consul-k8s gateway read my-gateway --output archive

# Output JSON to the terminal for my-gateway in the <my-namespace> namespace
$ consul-k8s gateway read my-gateway --namespace my-namespace --output json

How I've tested this PR

Create one or more Gateways in your Kube cluster. Example for this config is available here.

Run the commands above to inspect the various forms of output, making sure to use both the implicit namespace on your kubecontext and an explicit --namespace <my-namespace> arg.

How I expect reviewers to test this PR

See above

Checklist

@nathancoleman nathancoleman added area/cli CLI pr/no-backport signals that a PR will not contain a backport label labels Nov 26, 2024
@nathancoleman nathancoleman changed the title Add gateway read command to consul-k8s CLI [NET-11256] Add gateway read command to consul-k8s CLI Nov 26, 2024
@nathancoleman nathancoleman force-pushed the cli-gateway-read branch 2 times, most recently from 6eb79cf to ec7235f Compare November 26, 2024 20:52
f.StringVar(&flag.StringVar{
Name: "namespace",
Target: &c.flagGatewayNamespace,
Usage: "The namespace of the Gateway to read",
Copy link
Member

Choose a reason for hiding this comment

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

should we notify that the default value for this is the default namespace

Copy link
Member

Choose a reason for hiding this comment

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

and should we clarify that it's the k8s namespace and not the consul namespace (in case they do some mapping of namespaces?)

Copy link
Member Author

Choose a reason for hiding this comment

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

the default value is whatever namespace is set on the kubecontext, so it could be default or it could be something else


toolchain go1.22.5
toolchain go1.22.6
Copy link
Member

Choose a reason for hiding this comment

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

did we mean to bump the toolchain here? it's probably good that we do (and should probably be on the latest minor version tbh)

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 did not mean to -- I must be running a newer version of Go on my machine than what we use in the repo.

I'll bump it back down just to avoid sprawl in this PR


func (c *Command) fetchCRDs() error {
// Fetch Gateway
var gateway gwv1beta1.Gateway
Copy link
Member

Choose a reason for hiding this comment

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

is it possible that someone is running the v1alpha1 of the gateway if they're on an old consul-k8s version? should we worry about that/care about that?

Copy link
Member Author

Choose a reason for hiding this comment

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

v1.2 which introduced Gateway to consul-k8s itself consumes v1beta1.Gateway here, so customers would have to be using the old standalone consul-api-gateway project in order to be running the v1alpha1.Gateway.

Based on that, I don't think we need to support it here.

@nathancoleman nathancoleman marked this pull request as ready for review November 27, 2024 19:49
@nathancoleman nathancoleman requested a review from a team as a code owner November 27, 2024 19:49
@nathancoleman nathancoleman merged commit ef791dc into main Nov 29, 2024
50 of 51 checks passed
@nathancoleman nathancoleman deleted the cli-gateway-read branch November 29, 2024 03:52
@nathancoleman nathancoleman added backport/1.6.x Changes are backported to 1.6 and removed pr/no-backport signals that a PR will not contain a backport label labels Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli CLI backport/1.6.x Changes are backported to 1.6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants