grafana-operator
grafana-operator copied to clipboard
Implement Environment variable configuration through `Env:` fields for grafana deployments
Is your feature request related to a problem? Please describe.
Currently, the operator has the option to pass environment variables to the grafana deployment through envFrom
which can parse configMaps and Secrets for Env Vars located in them, this works but it's a roundabout way of getting non-sensitive Env Vars to the deployment pod, such as GF_INSTALL_PLUGINS
which isn't a sensitive Env Var, but requires a bit of setup to get working. This can be streamlined by implementing Env Var configuration,
(If applicable)If your feature request solves a bug please provide a link to the community issue
Describe the solution you'd like We should be able to configure non-sensitive env vars using the Env field for grafana deployments, this is already parsed by the operator but isn't configurable https://github.com/integr8ly/grafana-operator/blob/master/pkg/controller/model/grafanaDeployment.go#L455-L463
The feature should implement a new Spec.Deployment.Env
field which will be parsed for content similar to
func getEnvFrom(cr *v1alpha1.Grafana) []v13.EnvFromSource {
var envFrom []v13.EnvFromSource
if cr.Spec.Deployment != nil && cr.Spec.Deployment.EnvFrom != nil {
for _, v := range cr.Spec.Deployment.EnvFrom {
envFrom = append(envFrom, *v.DeepCopy())
}
}
return envFrom
}
The new function should return all currently default Envs as defined here along with appended Envs provided by the user. Which will then be used by the operator to be passed into the grafana deployment pod
Describe alternatives you've considered We could keep using EnvFrom, but this is a slightly shorter and cleaner way of achieving the same goal
Additional context NA
Existing solutions NA
What makes this a bit more complicated is the fact that users could provide admin credentials (GF_ADMIN_USER & GF_ADMIN_PASSWORD) through env. The operator needs to be aware of this and currently checks the envFrom
source. We would now also have to check the vars from env
and check for admin credentials (and prioritize if both sources provide credentials).
I guess this can be closed? Ref: https://github.com/grafana-operator/grafana-operator/pull/500
I also created https://github.com/grafana-operator/grafana-operator/issues/890
Thanks for pointing this out @jasaltvik