-
Notifications
You must be signed in to change notification settings - Fork 350
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: support secret plugin config #1486
Conversation
Config in ApisixRoute and ApisixPluginConfig can be stored into and referred from kubernetes secret Close apache#1408
@tao12345666333 PTAL |
@@ -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 { |
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.
I think there should be logs here.
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.
+1
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.
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.
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.
Done
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.
thanks for your contribution.
There are some things that need to be modified:
- SecretConfig semantics are less clear about naming
- v2beta3 is deprecated, we don't need to modify it anymore.
- The current code and test cases do not cover the case of duplicate configuration.
- You didn't add documentation about it. References need to be updated at least https://github.com/apache/apisix-ingress-controller/tree/master/docs/en/latest/references
@@ -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"` |
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.
I prefer it called SecretRef. The semantics are clearer, this is a reference to the secret
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.
It can be left unset, right?
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.
+1
@@ -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"` |
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.
v2beta3 is deprecated, we don't need to modify it anymore.
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.
Done
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.
Also need to update the documentation. And please fix the CI errors.
@@ -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 { |
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.
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.
resp.Status(http.StatusOK) | ||
resp.Header("X-Foo").Equal("v1") | ||
resp.Header("X-Foo2").Equal("v2") | ||
resp.Body().Contains("This is the preface") |
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.
Any way to check if it actually appears before the later one?
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.
Done
@@ -161,6 +161,8 @@ type ApisixRouteHTTPPlugin struct { | |||
Enable bool `json:"enable" yaml:"enable"` | |||
// Plugin configuration. | |||
Config ApisixRouteHTTPPluginConfig `json:"config" yaml:"config"` | |||
// Plugin configuration secretRef. |
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 should have a document/field comment that explains how the priority work if this conflicts with the Config fields.
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.
An additional section Config with secretRef
in apisix_route.md
is added to explain that.
* remove secretRef of plugins.config in v2beta3 * add key logs output * add test case to validate the plugins config priority * add the corresponding doc section Close apache#1408
Codecov Report
@@ 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
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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? |
OK |
Type of change:
What this PR does / why we need it:
Config in
ApisixRoute
andApisixPluginConfig
can be stored into and referred from the kubernetes secret.A echo plugin demo is like below, the
before_body
andafter_body
can be stored in their corresponding secret.Close #1408
Pre-submission checklist: