You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/12/04 07:45:11 UTC

[GitHub] [apisix-ingress-controller] An-DJ opened a new pull request, #1486: feat: support secret plugin config

An-DJ opened a new pull request, #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486

   <!-- Please answer these questions before submitting a pull request -->
   
   ### Type of change:
   
   <!-- Please delete options that are not relevant. -->
   
   - [ ] Bugfix
   - [X] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   
   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   Config in `ApisixRoute` and `ApisixPluginConfig` can be stored into and referred from the kubernetes secret.
   
   A echo plugin demo:
   
   ```yml
   apiVersion: v1
   kind: Secret
   metadata:
     name: echo
   data:
     before_body: IlRoaXMgaXMgdGhlIHByZWZhY2Ui
     after_body: IlRoaXMgaXMgdGhlIGVwaWxvZ3VlIg==
   ---
   apiVersion: apisix.apache.org/v2beta3
   kind: ApisixRoute
   metadata:
    name: httpbin-route
   spec:
    http:
    - name: rule1
      match:
        hosts:
        - httpbin.org
        paths:
          - /ip
      backends:
      - serviceName: %s
        servicePort: %d
        weight: 10
      plugins:
      - name: echo
        enable: true
        config:
          headers:
            X-Foo: v1
            X-Foo2: v2
        secretConfig: echo
   ```
   <!--- If it fixes an open issue, please link to the issue here. -->
   Close #1408
   
   ### 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
   -->
   
   * [X] Did you explain what problem does this PR solve? Or what new features have been added?
   * [X] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [X] 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 pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#issuecomment-1342463079

   OK


-- 
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] An-DJ commented on pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
An-DJ commented on PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#issuecomment-1336342527

   @tao12345666333 PTAL


-- 
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] lingsamuel commented on a diff in pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
lingsamuel commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1039088293


##########
test/e2e/suite-plugins/suite-plugins-general/echo.go:
##########
@@ -57,6 +57,62 @@ spec:
          X-Foo: v1
          X-Foo2: v2
        
+`, backendSvc, backendPorts[0])
+
+			assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixResource(ar))
+
+			err := s.EnsureNumApisixUpstreamsCreated(1)
+			assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams")
+			err = s.EnsureNumApisixRoutesCreated(1)
+			assert.Nil(ginkgo.GinkgoT(), err, "Checking number of routes")
+
+			resp := s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect()
+			resp.Status(http.StatusOK)
+			resp.Header("X-Foo").Equal("v1")
+			resp.Header("X-Foo2").Equal("v2")
+			resp.Body().Contains("This is the preface")

Review Comment:
   Any way to check if it actually appears before the later one?



##########
pkg/kube/apisix/apis/config/v2beta3/types.go:
##########
@@ -161,6 +161,8 @@ type ApisixRouteHTTPPlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.

Review Comment:
   We should have a document/field comment that explains how the priority work if this conflicts with the Config fields.



##########
pkg/kube/apisix/apis/config/v2beta3/types.go:
##########
@@ -161,6 +161,8 @@ type ApisixRouteHTTPPlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.
+	SecretConfig string `json:"secretConfig" yaml:"secretConfig"`

Review Comment:
   Are we still adding features for v2beta3? @tao12345666333 



##########
pkg/providers/apisix/translation/apisix_pluginconfig.go:
##########
@@ -42,6 +42,11 @@ func (t *translator) TranslatePluginConfigV2beta3(config *configv2beta3.ApisixPl
 						zap.Any("new", plugin.Config),
 					)
 				}
+				if sec, err := t.SecretLister.Secrets(config.Namespace).Get(plugin.SecretConfig); err == nil {

Review Comment:
   Why are errors being ignored here? There is no way for the user to know why their configuration (although wrong) is being ignored. At least we should print a log or add an error message to the sync status 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] An-DJ commented on a diff in pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
An-DJ commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1040669478


##########
pkg/providers/apisix/translation/apisix_pluginconfig.go:
##########
@@ -42,6 +42,11 @@ func (t *translator) TranslatePluginConfigV2beta3(config *configv2beta3.ApisixPl
 						zap.Any("new", plugin.Config),
 					)
 				}
+				if sec, err := t.SecretLister.Secrets(config.Namespace).Get(plugin.SecretConfig); err == nil {

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] codecov-commenter commented on pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#issuecomment-1339279946

   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1486?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 [#1486](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1486?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (dd9e470) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/ed92690f5aabb4ece4b92d860d72d85bdfa23db0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ed92690) will **decrease** coverage by `0.20%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1486      +/-   ##
   ==========================================
   - Coverage   41.26%   41.06%   -0.21%     
   ==========================================
     Files          83       83              
     Lines        7365     7401      +36     
   ==========================================
     Hits         3039     3039              
   - Misses       3972     4008      +36     
     Partials      354      354              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1486?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...roviders/apisix/translation/apisix\_pluginconfig.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1486/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3Byb3ZpZGVycy9hcGlzaXgvdHJhbnNsYXRpb24vYXBpc2l4X3BsdWdpbmNvbmZpZy5nbw==) | `30.55% <0.00%> (-6.12%)` | :arrow_down: |
   | [pkg/providers/apisix/translation/apisix\_route.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1486/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL3Byb3ZpZGVycy9hcGlzaXgvdHJhbnNsYXRpb24vYXBpc2l4X3JvdXRlLmdv) | `30.48% <0.00%> (-1.03%)` | :arrow_down: |
   | [pkg/config/config.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1486/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2NvbmZpZy9jb25maWcuZ28=) | `64.13% <0.00%> (ø)` | |
   | [pkg/apisix/cluster.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/1486/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGtnL2FwaXNpeC9jbHVzdGVyLmdv) | `36.12% <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] An-DJ commented on a diff in pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
An-DJ commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1040670193


##########
test/e2e/suite-plugins/suite-plugins-general/echo.go:
##########
@@ -57,6 +57,62 @@ spec:
          X-Foo: v1
          X-Foo2: v2
        
+`, backendSvc, backendPorts[0])
+
+			assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixResource(ar))
+
+			err := s.EnsureNumApisixUpstreamsCreated(1)
+			assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams")
+			err = s.EnsureNumApisixRoutesCreated(1)
+			assert.Nil(ginkgo.GinkgoT(), err, "Checking number of routes")
+
+			resp := s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect()
+			resp.Status(http.StatusOK)
+			resp.Header("X-Foo").Equal("v1")
+			resp.Header("X-Foo2").Equal("v2")
+			resp.Body().Contains("This is the preface")

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 #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1039082058


##########
pkg/kube/apisix/apis/config/v2beta3/types.go:
##########
@@ -161,6 +161,8 @@ type ApisixRouteHTTPPlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.
+	SecretConfig string `json:"secretConfig" yaml:"secretConfig"`

Review Comment:
   v2beta3 is deprecated, we don't need to modify it anymore.



##########
pkg/kube/apisix/apis/config/v2/types.go:
##########
@@ -170,6 +170,8 @@ type ApisixRoutePlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRoutePluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.
+	SecretConfig string `json:"secretConfig" yaml:"secretConfig"`

Review Comment:
   I prefer it called SecretRef. The semantics are clearer, this is a reference to the secret



##########
pkg/kube/apisix/apis/config/v2/types.go:
##########
@@ -170,6 +170,8 @@ type ApisixRoutePlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRoutePluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.
+	SecretConfig string `json:"secretConfig" yaml:"secretConfig"`

Review Comment:
   It can be left unset, right?



-- 
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 #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
AlinsRan commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1039079160


##########
pkg/providers/apisix/translation/apisix_pluginconfig.go:
##########
@@ -42,6 +42,11 @@ func (t *translator) TranslatePluginConfigV2beta3(config *configv2beta3.ApisixPl
 						zap.Any("new", plugin.Config),
 					)
 				}
+				if sec, err := t.SecretLister.Secrets(config.Namespace).Get(plugin.SecretConfig); err == nil {

Review Comment:
   I think there should be logs here.



-- 
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] An-DJ commented on pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
An-DJ commented on PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#issuecomment-1341017917

   Perhaps the unit-test-ci error was caused by network random delay. My local test has passed.
   
   Could the test workflow be retriggered by hand?


-- 
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 #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
AlinsRan commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1039086974


##########
pkg/kube/apisix/apis/config/v2/types.go:
##########
@@ -170,6 +170,8 @@ type ApisixRoutePlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRoutePluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.
+	SecretConfig string `json:"secretConfig" yaml:"secretConfig"`

Review Comment:
   +1



-- 
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 #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1039186888


##########
pkg/kube/apisix/apis/config/v2beta3/types.go:
##########
@@ -161,6 +161,8 @@ type ApisixRouteHTTPPlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.
+	SecretConfig string `json:"secretConfig" yaml:"secretConfig"`

Review Comment:
   no, we don't need. https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1039082058



-- 
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] An-DJ commented on a diff in pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
An-DJ commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1040673343


##########
pkg/kube/apisix/apis/config/v2beta3/types.go:
##########
@@ -161,6 +161,8 @@ type ApisixRouteHTTPPlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.

Review Comment:
   An additional section `Config with secretRef` in `apisix_route.md` is added to explain that.



-- 
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] An-DJ commented on a diff in pull request #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
An-DJ commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1040669793


##########
pkg/kube/apisix/apis/config/v2beta3/types.go:
##########
@@ -161,6 +161,8 @@ type ApisixRouteHTTPPlugin struct {
 	Enable bool `json:"enable" yaml:"enable"`
 	// Plugin configuration.
 	Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"`
+	// Plugin configuration secretRef.
+	SecretConfig string `json:"secretConfig" yaml:"secretConfig"`

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 #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
tao12345666333 commented on code in PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486#discussion_r1039084649


##########
pkg/providers/apisix/translation/apisix_pluginconfig.go:
##########
@@ -42,6 +42,11 @@ func (t *translator) TranslatePluginConfigV2beta3(config *configv2beta3.ApisixPl
 						zap.Any("new", plugin.Config),
 					)
 				}
+				if sec, err := t.SecretLister.Secrets(config.Namespace).Get(plugin.SecretConfig); err == nil {

Review Comment:
   +1



-- 
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 #1486: feat: support secret plugin config

Posted by GitBox <gi...@apache.org>.
tao12345666333 merged PR #1486:
URL: https://github.com/apache/apisix-ingress-controller/pull/1486


-- 
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