Skip to content
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

plugin init container tag configurable per flag #16

Merged
merged 2 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ The operator supports the following flags on startup:

* *--grafana-image*: overrides the Grafana image, defaults to `docker.io/grafana/grafana`.
* *--grafana-image-tag*: overrides the Grafana tag, defaults to `5.4.2`.
* *--grafana-plugins-init-container-image*: overrides the Grafana Plugins Init Container image, defaults to `quay.io/integreatly/grafana_plugins_init`.
* *--grafana-plugins-init-container-tag*: overrides the Grafana Plugins Init Container tag, defaults to `0.0.2`.
* *--scan-all*: watch for dashboards in all namespaces. This requires the the operator service account to have cluster wide permissions to `get`, `list`, `update` and `watch` dashboards. See `deploy/cluster_roles`.
* *--openshift*: force the operator to use a [route](https://docs.openshift.com/container-platform/3.11/architecture/networking/routes.html) instead of an [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/). Note that routes are only supported on OpenShift.

Expand Down
3 changes: 3 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var log = logf.Log.WithName("cmd")
var flagImage string
var flagImageTag string
var flagPluginsInitContainerImage string
var flagPluginsInitContainerTag string
var scanAll bool
var openshift bool

Expand All @@ -41,6 +42,7 @@ func init() {
flagset.StringVar(&flagImage, "grafana-image", "", "Overrides the default Grafana image")
flagset.StringVar(&flagImageTag, "grafana-image-tag", "", "Overrides the default Grafana image tag")
flagset.StringVar(&flagPluginsInitContainerImage, "grafana-plugins-init-container-image", "", "Overrides the default Grafana Plugins Init Container image")
flagset.StringVar(&flagPluginsInitContainerTag, "grafana-plugins-init-container-tag", "", "Overrides the default Grafana Plugins Init Container tag")
flagset.BoolVar(&scanAll, "scan-all", false, "Scans all namespaces for dashboards")
flagset.BoolVar(&openshift, "openshift", false, "Use Route instead of Ingress")
flagset.Parse(os.Args[1:])
Expand Down Expand Up @@ -92,6 +94,7 @@ func main() {
controllerConfig.AddConfigItem(common.ConfigGrafanaImage, flagImage)
controllerConfig.AddConfigItem(common.ConfigGrafanaImageTag, flagImageTag)
controllerConfig.AddConfigItem(common.ConfigPluginsInitContainerImage, flagPluginsInitContainerImage)
controllerConfig.AddConfigItem(common.ConfigPluginsInitContainerTag, flagPluginsInitContainerTag)
controllerConfig.AddConfigItem(common.ConfigOperatorNamespace, namespace)
controllerConfig.AddConfigItem(common.ConfigDashboardLabelSelector, "")
controllerConfig.AddConfigItem(common.ConfigOpenshift, openshift)
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/common/controller_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
ConfigGrafanaImage = "grafana.image.url"
ConfigGrafanaImageTag = "grafana.image.tag"
ConfigPluginsInitContainerImage = "grafana.plugins.init.container.image.url"
ConfigPluginsInitContainerTag = "grafana.plugins.init.container.image.tag"
ConfigOperatorNamespace = "grafana.operator.namespace"
ConfigDashboardLabelSelector = "grafana.dashboard.selector"
ConfigGrafanaPluginsUpdated = "grafana.plugins.updated"
Expand All @@ -28,7 +29,7 @@ const (
GrafanaIngressName = "grafana-ingress"
GrafanaServiceName = "grafana-service"
PluginsInitContainerImage = "quay.io/integreatly/grafana_plugins_init"
PluginsInitContainerImageTag = "0.0.2"
PluginsInitContainerTag = "0.0.2"
PluginsEnvVar = "GRAFANA_PLUGINS"
PluginsUrl = "https://grafana.com/api/plugins/%s/versions/%s"
PluginsMinAge = 5
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/grafana/templateHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type GrafanaParamaeters struct {
GrafanaRouteName string
GrafanaServiceName string
PluginsInitContainerImage string
PluginsInitContainerImageTag string
PluginsInitContainerTag string
GrafanaIngressName string
Hostname string
AdminUser string
Expand Down Expand Up @@ -93,7 +93,7 @@ func newTemplateHelper(cr *integreatly.Grafana) *TemplateHelper {
GrafanaRouteName: common.GrafanaRouteName,
GrafanaServiceName: common.GrafanaServiceName,
PluginsInitContainerImage: controllerConfig.GetConfigString(common.ConfigPluginsInitContainerImage, common.PluginsInitContainerImage),
PluginsInitContainerImageTag: common.PluginsInitContainerImageTag,
PluginsInitContainerTag: controllerConfig.GetConfigString(common.ConfigPluginsInitContainerTag, common.PluginsInitContainerTag),
GrafanaIngressName: common.GrafanaIngressName,
Hostname: cr.Spec.Hostname,
AdminUser: option(cr.Spec.AdminUser, "root"),
Expand Down
2 changes: 1 addition & 1 deletion templates/grafana-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
- env:
- name: GRAFANA_PLUGINS
value: ""
image: '{{ .PluginsInitContainerImage }}:{{ .PluginsInitContainerImageTag }}'
image: '{{ .PluginsInitContainerImage }}:{{ .PluginsInitContainerTag }}'
imagePullPolicy: IfNotPresent
name: grafana-plugins-init
resources: {}
Expand Down