-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support reading environment from secret/configmap #2295
Conversation
d8aebf1
to
5c02e7b
Compare
5c02e7b
to
c244afe
Compare
well... if tests are broken, somenthing is broken, please take a look @ramondeklein |
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.
So, If I am understanding the code right, sidecar will no longer watch the .spec.config.name
secret and will solely get the env variables from a configMap or a secret mentioned in spec.env
(on a side note: my suggestions is to use spec.envFrom
)
In that case shouldn't the field .spec.configuration
be completelly removed form TenantSpec?
// *Optional* +
//
// Specify a secret that contains additional environment variable configurations to be used for the MinIO pools.
// The secret is expected to have a key named config.env containing all exported environment variables for MinIO+
// +optional
Configuration *corev1.LocalObjectReference `json:"configuration,omitempty"`
type EnvVarSource struct { | ||
// Selects a key of a ConfigMap. | ||
// +optional | ||
ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty" protobuf:"bytes,3,opt,name=configMapKeyRef"` |
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 could be corev1.ConfigMapKeySelector
, I don't see why we would not honor the Optional
flag that is being removed
ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty" protobuf:"bytes,3,opt,name=configMapKeyRef"` | |
ConfigMapKeyRef *corev1.ConfigMapKeySelector `json:"configMapKeyRef,omitempty" protobuf:"bytes,3,opt,name=configMapKeyRef"` |
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 did that at first, but code is more complicated, because when the value is not optional we need to generate an error and abort the creation. It adds a lot of code. The current implementation just skips the environment variable (so optional is always enabled) if it cannot find the source.
There is no valid use-case to allow optional/non-optional support (AFAIK), so I prefered to use the simple code.
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.
How do we notify that a env variable could not be mounted to the user?, we just silently remove it?
optional
could solve this problem, even if means more code, if optional: false
then we should error out somewhere, if optional: true
we can silently drop the env variable, as the user stated that it is fine to run MinIO without it.
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.
Yes, I just skipped it. I'll rework to support Optional
and use corev1.ConfigMapKeySelector
(same for secret).
cli.StringFlag{ | ||
Name: "config-name", | ||
Value: "", | ||
Usage: "secret being watched", | ||
}, |
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 now read from the tenant specification.
type EnvVarSource struct { | ||
// Selects a key of a ConfigMap. | ||
// +optional | ||
ConfigMapKeyRef *ConfigMapKeySelector `json:"configMapKeyRef,omitempty" protobuf:"bytes,3,opt,name=configMapKeyRef"` |
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 did that at first, but code is more complicated, because when the value is not optional we need to generate an error and abort the creation. It adds a lot of code. The current implementation just skips the environment variable (so optional is always enabled) if it cannot find the source.
There is no valid use-case to allow optional/non-optional support (AFAIK), so I prefered to use the simple code.
@pjuarezd I've looked into this and all tests seem to run fine locally. Could it be that they time out when running in GitHub actions? I don't really get why this PR results in issues and some others seem to work fine... |
c244afe
to
9225dc8
Compare
Thank you for fixing the bug breaking the test @ramondeklein! |
Paused implementation, because it looks like #2253 is trying to restart pods anyway. This needs further discussion... |
Operator v7 will revert to old behaviour, so not needed anymore. |
This PR implements the following changes:
DEV_NAMESPACE
to the namespace where the tenant is located).Fixes #2279.