Skip to content

Commit

Permalink
Merge pull request grafana#691 from edgeworks-as/feature/olm-support
Browse files Browse the repository at this point in the history
feat: added support for flag overrides using environment variables
  • Loading branch information
pb82 authored Feb 22, 2022
2 parents 1b94fe6 + a895d6a commit ad25aae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions documentation/deploy_grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ The operator accepts a number of flags that can be passed in the `args` section

See `deploy/operator.yaml` for an example.

The Grafana image URL and tag, and Grafana Plugins Init container image and tag can also be overridden using environment
variables - to support deployment through OLM:

* `GRAFANA_IMAGE_URL`: overrides the Grafana tag. See `controller_config.go` for default.
* `GRAFANA_IMAGE_TAG`: overrides the Grafana tag. See `controller_config.go` for default.
* `GRAFANA_PLUGINS_INIT_CONTAINER_IMAGE_URL`: overrides the Grafana Plugins Init Container image, defaults
to `quay.io/integreatly/grafana_plugins_init`.
* `GRAFANA_PLUGINS_INIT_CONTAINER_IMAGE_TAG`: overrides the Grafana Plugins Init Container tag, defaults to `0.0.3`.

## Deploying Grafana

Create a custom resource of type `Grafana`, or use the one in `deploy/examples/Grafana.yaml`.
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ func main() { // nolint
controllerConfig.AddConfigItem(grafanaconfig.ConfigDashboardLabelSelector, "")
controllerConfig.AddConfigItem(grafanaconfig.ConfigJsonnetBasePath, flagJsonnetLocation)

// Check config is given through env variables - to support OLM installations
if flagImage == "" {
controllerConfig.AddConfigItem(grafanaconfig.ConfigGrafanaImage, os.Getenv("GRAFANA_IMAGE_URL"))
}
if flagImageTag == "" {
controllerConfig.AddConfigItem(grafanaconfig.ConfigGrafanaImageTag, os.Getenv("GRAFANA_IMAGE_TAG"))
}
if flagPluginsInitContainerImage == "" {
controllerConfig.AddConfigItem(grafanaconfig.ConfigPluginsInitContainerImage, os.Getenv("GRAFANA_PLUGINS_INIT_CONTAINER_IMAGE_URL"))
}
if flagPluginsInitContainerTag == "" {
controllerConfig.AddConfigItem(grafanaconfig.ConfigPluginsInitContainerTag, os.Getenv("GRAFANA_PLUGINS_INIT_CONTAINER_IMAGE_TAG"))
}

// Get the namespaces to scan for dashboards
// It's either the same namespace as the controller's or it's all namespaces if the
// --scan-all flag has been passed
Expand Down

0 comments on commit ad25aae

Please sign in to comment.