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
feat: make multiple controllers handle different ApisixRoute CRDs #593
Conversation
Codecov Report
@@ Coverage Diff @@
## master #593 +/- ##
=======================================
Coverage 41.69% 41.69%
=======================================
Files 90 90
Lines 7702 7702
=======================================
Hits 3211 3211
Misses 4127 4127
Partials 364 364 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Here is an issue related |
cmd/ingress/ingress.go
Outdated
@@ -143,8 +143,7 @@ the apisix cluster and others are created`, | |||
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.Kubeconfig, "kubeconfig", "", "Kubernetes configuration file (by default in-cluster configuration will be used)") | |||
cmd.PersistentFlags().DurationVar(&cfg.Kubernetes.ResyncInterval.Duration, "resync-interval", time.Minute, "the controller resync (with Kubernetes) interval, the minimum resync interval is 30s") | |||
cmd.PersistentFlags().StringSliceVar(&cfg.Kubernetes.AppNamespaces, "app-namespace", []string{config.NamespaceAll}, "namespaces that controller will watch for resources") | |||
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.IngressClass, "ingress-class", config.IngressClass, "the class of an Ingress object is set using the field IngressClassName in Kubernetes clusters version v1.18.0 or higher or the annotation \"kubernetes.io/ingress.class\" (deprecated)") | |||
cmd.PersistentFlags().StringVar(&cfg.Kubernetes.ApisixRouteClass, "apisix-route-class", config.ApisixRouteClass, "the class of an ApisixRoute object is set using the field ApisixRouteClassName in Kubernetes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big broken change, we need some discussions in the mailing list.
dfff454
to
16edb2d
Compare
@@ -39,7 +39,8 @@ type ApisixRoute struct { | |||
|
|||
// ApisixRouteSpec is the spec definition for ApisixRouteSpec. | |||
type ApisixRouteSpec struct { | |||
Rules []Rule `json:"rules,omitempty" yaml:"rules,omitempty"` | |||
IngressClass string `json:"ingressClass,omitempty" yaml:"ingressClass,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use IngressClassName
instead of ingressClass
ref to: https://kubernetes.io/zh/docs/concepts/services-networking/ingress/#deprecated-annotation
pkg/ingress/apisix_route.go
Outdated
} else if ar.GroupVersion() == kube.ApisixRouteV2beta1 { | ||
class = ar.V2beta1().Spec.IngressClassName | ||
} else { | ||
class = c.controller.cfg.Kubernetes.IngressClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the else won't be entered, once the logic here was executed, then there are some programming faults occurred, we may just:
- Panic, or
- log the error and just return false.
Thanks for your contribution, |
…troller into feat-routeclass
Yesterday I had an online meeting with @Donghui0 and @Gallardot. I've just resolved the code merge conflict in this PR. For some basic technical solutions can refer to #1523 (comment) I will also submit a more complete description at #592 later Thank you all! |
@Donghui0 Please see #592 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And please add e2e test cases to cover this change. Thanks
IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"` | ||
HTTP []ApisixRouteHTTP `json:"http,omitempty" yaml:"http,omitempty"` | ||
Stream []ApisixRouteStream `json:"stream,omitempty" yaml:"stream,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to change the v2beta3 resource.
pkg/providers/apisix/apisix_route.go
Outdated
case config.ApisixV2beta3: | ||
icn = ar.V2beta3().Spec.IngressClassName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please resolve the conflicts, thanks
go.mod
Outdated
require ( | ||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect | ||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to change this one. right?
CI fails, I think @AlinsRan can help. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
e6cfb2e
to
1c418f2
Compare
go.mod
Outdated
@@ -67,6 +67,8 @@ require ( | |||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | |||
github.com/modern-go/reflect2 v1.0.2 // indirect | |||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | |||
github.com/onsi/ginkgo/v2 v2.9.0 // indirect | |||
github.com/onsi/gomega v1.27.1 // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two dependencies are redundant and will only be used in e2e. Let me remove them.
81381b4
to
08350e7
Compare
Please answer these questions before submitting a pull request
Why submit this pull request?
Bugfix
New feature provided
Improve performance
Backport patches
Related issues
feat: Can it support independent use of ApisixUpstream CRD in controller ? #578
proposal: Add IngressClass support for custom resources #592
New feature or improvement
make multiple controllers handle different ApisixRoute CRDs
Backport patches
Why need to backport?
Source branch
Related commits and pull requests
Target branch