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 init code for the istio provider #99

Merged

Conversation

dpasiukevich
Copy link
Member

@dpasiukevich dpasiukevich commented Nov 26, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:
Adds initial code for istio provider. This PR adds the interface implementation and helpers to read istio CRDs from the cluster. The actual conversion would be done in the following PRs.

In detailed, this PR:

  1. Reads istio Gateway & VirtualServices
  2. Removes customResources arg from the Provider interface. Currently is passed to the provider as a interface{} (nil value & nil type). Provider code currently cannot modify this struct (because cannot cast to any other type and cannot overwrite the value).
    The PR simplifies interface and removes the need to pass customResources as interface{} which is also shared across different providers.
    Now the provider if wants to handle custom resources, must itself parse them and store in any desired format locally until ToGatewayAPI is called on it.
  3. Updates go.mod to import latest IstioAPI.
  4. Bump linter version and fixes newly lint findings in the repo.

cc @howardjohn

Does this PR introduce a user-facing change?:

[Istio provider] set up code for reading istio custom resources

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 26, 2023
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 26, 2023
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 26, 2023
@dpasiukevich dpasiukevich force-pushed the framework_istio_provider branch from 8fa45df to 4e5c708 Compare November 26, 2023 23:33
@dpasiukevich
Copy link
Member Author

/test pull-ingress2gateway-verify

@dpasiukevich
Copy link
Member Author

/assign @LiorLieberman

@LiorLieberman
Copy link
Member

Thats great @dpasiukevich !
I will book some time today to review this.

In the meantime, can you edit the release-notes section to reflect the changes (that will then be included in our release notes)

This is a user facing change assuming now users will be able to invoke the tool with istio provider.

/cc @levikobi @mlavacca

@LiorLieberman LiorLieberman linked an issue Nov 27, 2023 that may be closed by this pull request
@dpasiukevich
Copy link
Member Author

The current PR is just a basic foundation to put the actual code later on.
I planned to add the release notes to notify customers when the converter would be ready at least on the basic level.

Copy link
Member

@LiorLieberman LiorLieberman left a comment

Choose a reason for hiding this comment

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

Overall looks good to me and thanks for improving the interface! I left a few small comments.

This PR actually looks like it is half implementing conversion (I can see you read storage.Gateways and fill in some metadata while the spec and virtual services are not being read). Ideally it should either set up the init code and have a followup PR for the conversion itslef OR doing everything in this PR.

pkg/i2gw/providers/istio/converter.go Outdated Show resolved Hide resolved
pkg/i2gw/providers/istio/resource_reader.go Outdated Show resolved Hide resolved
pkg/i2gw/providers/istio/istio.go Outdated Show resolved Hide resolved
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/evanphx/json-patch.v5 v5.7.0 // indirect
Copy link
Member

Choose a reason for hiding this comment

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

I wonder where this comes from as we already have above

	github.com/evanphx/json-patch v5.7.0+incompatible // indirect
	github.com/evanphx/json-patch/v5 v5.7.0 // indirect

Copy link
Member Author

Choose a reason for hiding this comment

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

It may be from istio.io/api v1.20.0. It's needed for the new provider.

Choose a reason for hiding this comment

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

Its from sigs.k8s.io/kustomize/api which was updated.

Istio API has no new deps:

        github.com/golang/protobuf v1.5.3
        google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13
        google.golang.org/genproto/googleapis/rpc v0.0.0-20231009173412-8bfb1ae86b6c
        google.golang.org/grpc v1.58.3
        google.golang.org/protobuf v1.31.0
        k8s.io/api v0.28.0
        k8s.io/apimachinery v0.28.0

just upgraded to 0.28

pkg/i2gw/providers/istio/converter.go Outdated Show resolved Hide resolved
Copy link
Member Author

@dpasiukevich dpasiukevich left a comment

Choose a reason for hiding this comment

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

@LiorLieberman updated in regards for the PR comments.

As for this PR -- I just want to have a proper basis and agreement for the conversion logic (imports, proper interface for the Provider).

If everything was done in one PR (this would've been a gargantuan PR). As I cannot reuse any existing conversion logic in the repo (it's for Ingress, while the provider is for Istio).

I'd prefer quicker&smaller iterations.

If needed I can remove the provider from registration for now.

pkg/i2gw/providers/istio/converter.go Outdated Show resolved Hide resolved
pkg/i2gw/providers/istio/istio.go Outdated Show resolved Hide resolved
pkg/i2gw/providers/istio/resource_reader.go Outdated Show resolved Hide resolved
VirtualServiceKind = "VirtualService"
)

type gateway struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

@howardjohn would this be an ok representation of the object to parse into from the unstructured.Unstructured? Or is there something similar in the istio API (adapted Istio resources for K8S)?

I didn't find any, asking just to double check.

Choose a reason for hiding this comment

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

istio/client-go repo already has these that can be used

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, exactly what's needed. Thanks!

Copy link
Member

@mlavacca mlavacca 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 it @dpasiukevich, lgtm!

Will defer to @levikobi for the final lgtm stamp.

@dpasiukevich
Copy link
Member Author

/test pull-ingress2gateway-test

@dpasiukevich
Copy link
Member Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Dec 1, 2023
pkg/i2gw/providers/ingressnginx/resource_fetcher.go Outdated Show resolved Hide resolved
pkg/i2gw/providers/istio/resource_fetcher.go Outdated Show resolved Hide resolved
package istio

const (
APIVersion = "networking.istio.io/v1beta1"
Copy link
Member

Choose a reason for hiding this comment

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

maybe APIVersionV1Beta1 as istio also have alpha3 IIRC

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'd keep as is to indicate the only currently supported API version is networking.istio.io/v1beta1 for istio converter

pkg/i2gw/providers/kong/resource_fetcher.go Outdated Show resolved Hide resolved
@LiorLieberman
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 1, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dpasiukevich, LiorLieberman, mlavacca

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

@k8s-ci-robot k8s-ci-robot merged commit 6ff1a24 into kubernetes-sigs:main Dec 1, 2023
1 check passed
xtineskim pushed a commit to xtineskim/ingress2gateway that referenced this pull request Dec 11, 2023
* Add init code for the istio provider

* rename resource_readers

* use istio api types

* return readers back

* refactor upd

* rename filenames to readers
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Istio provider support
6 participants