diff --git a/api/integreatly/v1alpha1/grafana_types.go b/api/integreatly/v1alpha1/grafana_types.go index 040abb055..6947358a6 100644 --- a/api/integreatly/v1alpha1/grafana_types.go +++ b/api/integreatly/v1alpha1/grafana_types.go @@ -130,6 +130,7 @@ type GrafanaHttpProxy struct { Enabled bool `json:"enabled"` URL string `json:"url,omitempty"` SecureURL string `json:"secureUrl,omitempty"` + NoProxy string `json:"noProxy,omitempty"` } // GrafanaIngress provides a means to configure the ingress created diff --git a/api/integreatly/v1alpha1/zz_generated.deepcopy.go b/api/integreatly/v1alpha1/zz_generated.deepcopy.go index f0cbbfe67..fd4f26df8 100644 --- a/api/integreatly/v1alpha1/zz_generated.deepcopy.go +++ b/api/integreatly/v1alpha1/zz_generated.deepcopy.go @@ -1,4 +1,3 @@ -//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/config/crd/bases/integreatly.org_grafanas.yaml b/config/crd/bases/integreatly.org_grafanas.yaml index 082ebb398..ca9605278 100644 --- a/config/crd/bases/integreatly.org_grafanas.yaml +++ b/config/crd/bases/integreatly.org_grafanas.yaml @@ -4415,6 +4415,8 @@ spec: properties: enabled: type: boolean + noProxy: + type: string secureUrl: type: string url: diff --git a/controllers/grafanadashboard/dashboard_pipeline.go b/controllers/grafanadashboard/dashboard_pipeline.go index c5c46a532..ee77b8602 100644 --- a/controllers/grafanadashboard/dashboard_pipeline.go +++ b/controllers/grafanadashboard/dashboard_pipeline.go @@ -54,6 +54,9 @@ type DashboardPipelineImpl struct { } func NewDashboardPipeline(client client.Client, dashboard *v1alpha1.GrafanaDashboard, ctx context.Context) DashboardPipeline { + if dashboard.Spec.ContentCacheDuration == nil { + dashboard.Spec.ContentCacheDuration = &metav1.Duration{Duration: 24 * time.Hour} + } return &DashboardPipelineImpl{ Client: client, Dashboard: dashboard, diff --git a/controllers/model/grafanaDeployment.go b/controllers/model/grafanaDeployment.go index f54b79f39..0700c6c73 100644 --- a/controllers/model/grafanaDeployment.go +++ b/controllers/model/grafanaDeployment.go @@ -578,6 +578,12 @@ func getContainers(cr *v1alpha1.Grafana, configHash, dsHash string) []v13.Contai Value: cr.Spec.Deployment.HttpProxy.SecureURL, }) } + if cr.Spec.Deployment.HttpProxy.NoProxy != "" { + envVars = append(envVars, v13.EnvVar{ + Name: "NO_PROXY", + Value: cr.Spec.Deployment.HttpProxy.NoProxy, + }) + } } if cr.Spec.Deployment != nil && cr.Spec.Deployment.Env != nil { diff --git a/controllers/model/grafanaDeployment_test.go b/controllers/model/grafanaDeployment_test.go new file mode 100644 index 000000000..0b53b0156 --- /dev/null +++ b/controllers/model/grafanaDeployment_test.go @@ -0,0 +1,69 @@ +package model + +import ( + "testing" + + grafanav1alpha1 "github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1" + + "github.com/stretchr/testify/assert" +) + +func TestGrafanaDeployment_httpProxy(t *testing.T) { + t.Run("noProxy is setting", func(t *testing.T) { + cr := &grafanav1alpha1.Grafana{ + Spec: grafanav1alpha1.GrafanaSpec{ + Deployment: &grafanav1alpha1.GrafanaDeployment{ + HttpProxy: &grafanav1alpha1.GrafanaHttpProxy{ + Enabled: true, + URL: "http://1.2.3.4", + SecureURL: "http://1.2.3.4", + NoProxy: ".svc.cluster.local,.svc", + }, + }, + }, + } + deployment := GrafanaDeployment(cr, "", "") + for _, container := range deployment.Spec.Template.Spec.Containers { + if container.Name != "grafana" { + continue + } + + noProxyExist := false + for _, env := range container.Env { + if env.Name == "NO_PROXY" { + noProxyExist = true + assert.Equal(t, ".svc.cluster.local,.svc", env.Value) + } + } + assert.True(t, noProxyExist) + } + }) + + t.Run("noProxy is not setting", func(t *testing.T) { + cr := &grafanav1alpha1.Grafana{ + Spec: grafanav1alpha1.GrafanaSpec{ + Deployment: &grafanav1alpha1.GrafanaDeployment{ + HttpProxy: &grafanav1alpha1.GrafanaHttpProxy{ + Enabled: true, + URL: "http://1.2.3.4", + SecureURL: "http://1.2.3.4", + }, + }, + }, + } + deployment := GrafanaDeployment(cr, "", "") + for _, container := range deployment.Spec.Template.Spec.Containers { + if container.Name != "grafana" { + continue + } + + noProxyExist := false + for _, env := range container.Env { + if env.Name == "NO_PROXY" { + noProxyExist = true + } + } + assert.False(t, noProxyExist) + } + }) +} diff --git a/deploy/manifests/latest/crds.yaml b/deploy/manifests/latest/crds.yaml index 23352c8e3..cb6554937 100644 --- a/deploy/manifests/latest/crds.yaml +++ b/deploy/manifests/latest/crds.yaml @@ -5038,6 +5038,8 @@ spec: properties: enabled: type: boolean + noProxy: + type: string secureUrl: type: string url: diff --git a/documentation/api.md b/documentation/api.md index d97573037..7d8a51a6a 100644 --- a/documentation/api.md +++ b/documentation/api.md @@ -11868,6 +11868,13 @@ GrafanaHttpProxy provides a means to configure the Grafana deployment to use an
true + + noProxy + string + +
+ + false secureUrl string