You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "AlinsRan (via GitHub)" <gi...@apache.org> on 2023/02/17 04:14:09 UTC
[GitHub] [apisix-ingress-controller] AlinsRan opened a new pull request, #1674: feat: ApisixUpstream support IngressClass
AlinsRan opened a new pull request, #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674
<!-- Please answer these questions before submitting a pull request -->
### Type of change:
<!-- Please delete options that are not relevant. -->
<!-- Select all the options from below that matches the type your PR best -->
- [ ] Bugfix
- [ ] New feature provided
- [ ] Improve performance
- [ ] Backport patches
- [ ] Documentation
- [ ] Refactor
- [ ] Chore
- [ ] CI/CD or Tests
### What this PR does / why we need it:
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
### Pre-submission checklist:
<!--
Please follow the requirements:
1. Use Draft if the PR is not ready to be reviewed
2. Test is required for the feat/fix PR, unless you have a good reason
3. Doc is required for the feat PR
4. Use a new commit to resolve review instead of `push -f`
5. Use "request review" to notify the reviewer once you have resolved the review
-->
- [ ] Did you explain what problem does this PR solve? Or what new features have been added?
- [ ] Have you added corresponding test cases?
- [ ] Have you modified the corresponding document?
- [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix-ingress-controller#community) first**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on a diff in pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on code in PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#discussion_r1124385776
##########
test/e2e/suite-ingress/suite-ingress-features/ingress-class.go:
##########
@@ -0,0 +1,204 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package ingress
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+
+ ginkgo "github.com/onsi/ginkgo/v2"
+ "github.com/stretchr/testify/assert"
+
+ "github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+)
+
+var _ = ginkgo.Describe("suite-ingress-features: Testing CRDs with IngressClass", func() {
+ s := scaffold.NewScaffold(&scaffold.Options{
+ Name: "ingress-class",
+ IngressAPISIXReplicas: 1,
+ IngressClass: "apisix",
+ })
+ ginkgo.It("ApisiUpstream should be ignored", func() {
+ backendSvc, backendSvcPort := s.DefaultHTTPBackend()
+ au := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixUpstream
+metadata:
+ name: %s
+spec:
+ ingressClassName: ignore
+ retries: 3
+`, backendSvc)
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(au))
+ time.Sleep(6 * time.Second)
+
+ apisixRoute := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixRoute
+metadata:
+ name: httpbin-route
+spec:
+ http:
+ - name: rule1
+ match:
+ hosts:
+ - httpbin.org
+ paths:
+ - /ip
+ backends:
+ - serviceName: %s
+ servicePort: %d
+`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(apisixRoute))
+ time.Sleep(6 * time.Second)
+
+ ups, err := s.ListApisixUpstreams()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), ups, 1)
+ assert.Nil(ginkgo.GinkgoT(), ups[0].Retries)
+
+ err = s.EnsureNumApisixRoutesCreated(1)
+ assert.Nil(ginkgo.GinkgoT(), err, "Checking number of routes")
+ err = s.EnsureNumApisixUpstreamsCreated(1)
+ assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams")
+
+ s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusOK)
Review Comment:
oh i missed it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on a diff in pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on code in PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#discussion_r1111494595
##########
pkg/kube/apisix/apis/config/v2/types.go:
##########
@@ -477,6 +477,7 @@ type ApisixUpstream struct {
// ApisixUpstreamSpec describes the specification of ApisixUpstream.
type ApisixUpstreamSpec struct {
+ IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"`
Review Comment:
Please add comments for this field.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] AlinsRan commented on a diff in pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on code in PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#discussion_r1125869154
##########
pkg/providers/utils/ingress_class.go:
##########
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package utils
+
+import "github.com/apache/apisix-ingress-controller/pkg/config"
+
+func MatchCRDsIngressClass(resourceIngressClassName string, configIngressClass string) bool {
Review Comment:
If it is empty, it will return false. The old resource will be handed over to the caller for judgment. This method is only used to match the ingressClass
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#issuecomment-1453464349
This PR is good overall.
I hope that some test cases using `apisix-and-all` can be added to the test cases of IngressClass to ensure that there will be no break change.
Of course, it can also be implemented in subsequent PRs, without blocking the merging of this PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] codecov-commenter commented on pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#issuecomment-1434079465
# [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1674?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#1674](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1674?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e701ec2) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/4241b673b3fd385e82d5ca3a39fed8acafa5bd64?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4241b67) will **decrease** coverage by `0.06%`.
> The diff coverage is `0.00%`.
> :exclamation: Current head e701ec2 differs from pull request most recent head 595196a. Consider uploading reports for the commit 595196a to get more accurate results
```diff
@@ Coverage Diff @@
## master #1674 +/- ##
==========================================
- Coverage 41.42% 41.36% -0.06%
==========================================
Files 88 88
Lines 7642 7653 +11
==========================================
Hits 3166 3166
- Misses 4112 4123 +11
Partials 364 364
```
| [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1674?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [pkg/providers/apisix/translation/translator.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1674?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3Byb3ZpZGVycy9hcGlzaXgvdHJhbnNsYXRpb24vdHJhbnNsYXRvci5nbw==) | `0.00% <ø> (ø)` | |
| [pkg/providers/translation/service.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1674?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3Byb3ZpZGVycy90cmFuc2xhdGlvbi9zZXJ2aWNlLmdv) | `13.37% <0.00%> (-1.01%)` | :arrow_down: |
| [pkg/providers/translation/translator.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1674?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3Byb3ZpZGVycy90cmFuc2xhdGlvbi90cmFuc2xhdG9yLmdv) | `0.00% <ø> (ø)` | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] AlinsRan commented on a diff in pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on code in PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#discussion_r1124377866
##########
test/e2e/suite-ingress/suite-ingress-features/ingress-class.go:
##########
@@ -0,0 +1,204 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package ingress
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+
+ ginkgo "github.com/onsi/ginkgo/v2"
+ "github.com/stretchr/testify/assert"
+
+ "github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+)
+
+var _ = ginkgo.Describe("suite-ingress-features: Testing CRDs with IngressClass", func() {
+ s := scaffold.NewScaffold(&scaffold.Options{
+ Name: "ingress-class",
+ IngressAPISIXReplicas: 1,
+ IngressClass: "apisix",
+ })
+ ginkgo.It("ApisiUpstream should be ignored", func() {
+ backendSvc, backendSvcPort := s.DefaultHTTPBackend()
+ au := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixUpstream
+metadata:
+ name: %s
+spec:
+ ingressClassName: ignore
+ retries: 3
+`, backendSvc)
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(au))
+ time.Sleep(6 * time.Second)
+
+ apisixRoute := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixRoute
+metadata:
+ name: httpbin-route
+spec:
+ http:
+ - name: rule1
+ match:
+ hosts:
+ - httpbin.org
+ paths:
+ - /ip
+ backends:
+ - serviceName: %s
+ servicePort: %d
+`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(apisixRoute))
+ time.Sleep(6 * time.Second)
+
+ ups, err := s.ListApisixUpstreams()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), ups, 1)
+ assert.Nil(ginkgo.GinkgoT(), ups[0].Retries)
+
+ err = s.EnsureNumApisixRoutesCreated(1)
+ assert.Nil(ginkgo.GinkgoT(), err, "Checking number of routes")
+ err = s.EnsureNumApisixUpstreamsCreated(1)
+ assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams")
+
+ s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusOK)
Review Comment:
It is indeed ignored, see line 71.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 merged pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 merged PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] AlinsRan commented on a diff in pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on code in PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#discussion_r1125869733
##########
conf/config-default.yaml:
##########
@@ -64,7 +64,8 @@ kubernetes:
election_id: "ingress-apisix-leader" # the election id for the controller leader campaign,
# only the leader will watch and delivery resource changes,
# other instances (as candidates) stand by.
- ingress_class: "apisix" # the class of an Ingress object is set using the field
+ ingress_class: "apisix-and-all" # apisix-and-all is a special value, it handles Ingress resources with ingressClassName=apisix and all CRDs.
+ # the class of an Ingress object is set using the field
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-ingress-controller] tao12345666333 commented on a diff in pull request #1674: feat: ApisixUpstream support IngressClass
Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on code in PR #1674:
URL: https://github.com/apache/apisix-ingress-controller/pull/1674#discussion_r1124052774
##########
conf/config-default.yaml:
##########
@@ -64,7 +64,8 @@ kubernetes:
election_id: "ingress-apisix-leader" # the election id for the controller leader campaign,
# only the leader will watch and delivery resource changes,
# other instances (as candidates) stand by.
- ingress_class: "apisix" # the class of an Ingress object is set using the field
+ ingress_class: "apisix-and-all" # apisix-and-all is a special value, it handles Ingress resources with ingressClassName=apisix and all CRDs.
+ # the class of an Ingress object is set using the field
Review Comment:
this field can be used for both Ingress Object and custom resources.
##########
test/e2e/suite-ingress/suite-ingress-features/ingress-class.go:
##########
@@ -0,0 +1,204 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package ingress
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+
+ ginkgo "github.com/onsi/ginkgo/v2"
+ "github.com/stretchr/testify/assert"
+
+ "github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
+)
+
+var _ = ginkgo.Describe("suite-ingress-features: Testing CRDs with IngressClass", func() {
+ s := scaffold.NewScaffold(&scaffold.Options{
+ Name: "ingress-class",
+ IngressAPISIXReplicas: 1,
+ IngressClass: "apisix",
+ })
+ ginkgo.It("ApisiUpstream should be ignored", func() {
+ backendSvc, backendSvcPort := s.DefaultHTTPBackend()
+ au := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixUpstream
+metadata:
+ name: %s
+spec:
+ ingressClassName: ignore
+ retries: 3
+`, backendSvc)
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(au))
+ time.Sleep(6 * time.Second)
+
+ apisixRoute := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2
+kind: ApisixRoute
+metadata:
+ name: httpbin-route
+spec:
+ http:
+ - name: rule1
+ match:
+ hosts:
+ - httpbin.org
+ paths:
+ - /ip
+ backends:
+ - serviceName: %s
+ servicePort: %d
+`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(apisixRoute))
+ time.Sleep(6 * time.Second)
+
+ ups, err := s.ListApisixUpstreams()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), ups, 1)
+ assert.Nil(ginkgo.GinkgoT(), ups[0].Retries)
+
+ err = s.EnsureNumApisixRoutesCreated(1)
+ assert.Nil(ginkgo.GinkgoT(), err, "Checking number of routes")
+ err = s.EnsureNumApisixUpstreamsCreated(1)
+ assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams")
+
+ s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusOK)
Review Comment:
This is not as expected.
ApisixUpstream will be ignored.
##########
pkg/providers/utils/ingress_class.go:
##########
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package utils
+
+import "github.com/apache/apisix-ingress-controller/pkg/config"
+
+func MatchCRDsIngressClass(resourceIngressClassName string, configIngressClass string) bool {
Review Comment:
Will the resourceIngressClassName field be empty (nil)? This field does not exist for legacy resources.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org