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

Add gwctl to gateway-api repo #2428

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

gauravkghildiyal
Copy link
Member

What type of PR is this?
/kind feature

What this PR does / why we need it:
Import gwctl packages from https://github.com/gauravkghildiyal/gwctl

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

Add gwctl command-line tool which provides a better way to view and manage policies (https://gateway-api.sigs.k8s.io/geps/gep-713/#kubectl-plugin)

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 25, 2023
@gauravkghildiyal
Copy link
Member Author

/retest

@gauravkghildiyal gauravkghildiyal force-pushed the import-gwctl branch 2 times, most recently from 1c8008c to 01735a9 Compare September 25, 2023 18:18
@shaneutt shaneutt requested a review from robscott September 25, 2023 19:07
@gauravkghildiyal gauravkghildiyal force-pushed the import-gwctl branch 2 times, most recently from 65c5509 to 3ef4574 Compare September 25, 2023 21:03
@gauravkghildiyal gauravkghildiyal changed the title Add gwctl plugin to gateway-api repo Add gwctl to gateway-api repo Sep 25, 2023
Copy link
Member

@robscott robscott 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 very cool! Thanks for all the work on this @gauravkghildiyal! There's a lot here, but took a high level pass and had some nits + questions.

gwctl/README.md Outdated Show resolved Hide resolved
Comment on lines +15 to +35
```bash
# Clone the gwctl repository
git clone https://github.com/kubernetes-sigs/gateway-api.git

# Go to the gwctl directory
cd gateway-api

# Ensure vendor depedencies
go mod tidy
go mod vendor

# Build the gwctl binary
go build -o bin/gwctl gwctl/cmd/main.go

# Add binary to PATH
export PATH=./bin:${PATH}

# Start using!
gwctl help
```
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 fine for now, but we'll likely want to update this to point to a Gateway API release as soon as we have RC1 out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Acknowledged. Yes sure that that seems good. Will update as we make progress on that front in upcoming PRs.

gwctl/pkg/cmd/describe.go Outdated Show resolved Hide resolved
gwctl/pkg/common/consts.go Outdated Show resolved Hide resolved

type YamlString string

var YamlStringTransformer = cmp.Transformer("YamlLines", func(s YamlString) []string {
Copy link
Member

Choose a reason for hiding this comment

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

Probably missing something obvious, but why do we need 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.

No that's a good question. I should move the comment from within the function to outside the function. (Will update)

This is just a "good to have" thing which helps provide neat diffs during test. Idea being, split long blobs of yaml text by each line. When the diff is generated, it will clearly point out diffs per line (as oppposed to saying that: "somethings different in this large string, now go find what the difference is")

gwctl/pkg/resources/backends/backends.go Outdated Show resolved Hide resolved
gwctl/pkg/resources/policies/policies.go Outdated Show resolved Hide resolved
gwctl/pkg/resources/policies/policies.go Outdated Show resolved Hide resolved
gwctl/pkg/resources/policies/policies.go Outdated Show resolved Hide resolved
gwctl/pkg/types/params.go Outdated Show resolved Hide resolved
@howardjohn
Copy link
Contributor

howardjohn commented Sep 26, 2023 via email

@gauravkghildiyal gauravkghildiyal force-pushed the import-gwctl branch 5 times, most recently from 056eaab to ac17231 Compare October 2, 2023 07:43
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2023
@robscott
Copy link
Member

robscott commented Oct 6, 2023

You may consider naming the binary kubectl-<something> so its a "kubectl plugin"

Maybe kubectl-gw then?

@robscott
Copy link
Member

robscott commented Oct 7, 2023

Thanks for all the work on this @gauravkghildiyal! I took some time to test this out today and have some high level non-blocking feedback.

  1. I'd love to see this be a drop-in replacement for kubectl when reading (get/describe) Gateway API resources, so ideally this would be a superset of kubectl capabilities. With that said, if we end up having to recreate too many things, that's also not ideal. My main point of confusion here is that we're using get as a command, but it's not currently a drop-in replacement for kubectl get. If we wanted to get there, I think we'd need the following:
    • Support for all resources for both get and describe commands
    • Show at least the same set of columns, ideally more
    • Support for yaml and json output
    • Maybe support for more advanced features like label selection, etc
    • The longer this list gets, the less I'm sure about the overall goal 😄
  2. It would be great to more gracefully handle errors. For example, if one or more Gateway API CRDs are not found, we could just tell the user they need to install the CRD(s) that are missing.
  3. Similar to 1, but potentially more achievable in the short term, it would be great to include more information in our describe output. Right now the primary value seems to be policy connections, but it would be useful if it could include that + much of the other useful information included by kubectl describe.

I don't think any of these are blockers, but before we go too much further with this, it would probably be helpful to sketch out a user guide for the full set of functionality we want this to be able to accomplish, and then we can split up the work into smaller pieces so it can grow over time from this foundation.

I'm going to go ahead and approve what's here, because it works and looks like a good foundation, but would be very interested in a vision for how we want to build on top of this going forward.

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 7, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 7, 2023
@gauravkghildiyal
Copy link
Member Author

Thanks a lot for the review and great constructive feedback @robscott. Everything that you highlighted is definitely something that I can start addressing ASAP.

I agree that kubectl doesn't natively provide an extension mechanism in a way in which we can reuse it for certain things which ends up with us having to duplicate things. I will create a user guide on what I think we can/should support so others can start contributing as well.

I had been working on some improvements on the "usage as a library" aspects which I'll send separately.

(Rebasing to resolve merge conflict)

@gauravkghildiyal
Copy link
Member Author

/retest

Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for adding this!

I think adding it here in the repo is a good idea, as it will keep things in sync.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauravkghildiyal, robscott, shaneutt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gauravkghildiyal gauravkghildiyal force-pushed the import-gwctl branch 2 times, most recently from 87988af to 9066edf Compare October 12, 2023 22:23
@youngnick
Copy link
Contributor

yeah, I really like this to get us started, but I think we should spend a little time post-GA and talk about what we want this to go - tbh the more I think about it, the more I think we may be better off with two similar but distinct tools - gwctl which is a pretty straight kubectl replacement for get and describe, and a separate gw kubectl plugin that does the same things but with a slightly different interface. Typing kubectl gw get all or something seems slightly more readable than kubectl gwctl get all.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 12, 2023
@k8s-ci-robot k8s-ci-robot merged commit 20b5df1 into kubernetes-sigs:main Oct 12, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants