Skip to content

Commit

Permalink
Merge pull request #678 from HubertStefanski/https-proxy
Browse files Browse the repository at this point in the history
feat: add HTTPSProxy to env var
  • Loading branch information
pb82 committed Feb 22, 2022
2 parents ad25aae + 6c31f48 commit 97f526b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/integreatly/v1alpha1/grafana_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ type GrafanaDeployment struct {
// GrafanaHttpProxy provides a means to configure the Grafana deployment
// to use an HTTP(S) proxy when making requests and resolving plugins.
type GrafanaHttpProxy struct {
Enabled bool `json:"enabled"`
URL string `json:"url,omitempty"`
Enabled bool `json:"enabled"`
URL string `json:"url,omitempty"`
SecureURL string `json:"secureUrl,omitempty"`
}

// GrafanaIngress provides a means to configure the ingress created
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/integreatly.org_grafanas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4404,6 +4404,8 @@ spec:
properties:
enabled:
type: boolean
secureUrl:
type: string
url:
type: string
required:
Expand Down
12 changes: 12 additions & 0 deletions controllers/model/grafanaDeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ func getContainers(cr *v1alpha1.Grafana, configHash, dsHash string) []v13.Contai
Name: "HTTP_PROXY",
Value: cr.Spec.Deployment.HttpProxy.URL,
})
if cr.Spec.Deployment.HttpProxy.SecureURL != "" {
envVars = append(envVars, v13.EnvVar{
Name: "HTTPS_PROXY",
Value: cr.Spec.Deployment.HttpProxy.SecureURL,
})
}
}

if cr.Spec.Deployment != nil && cr.Spec.Deployment.Env != nil {
Expand Down Expand Up @@ -642,6 +648,12 @@ func getInitContainers(cr *v1alpha1.Grafana, plugins string) []v13.Container {
Name: "HTTP_PROXY",
Value: cr.Spec.Deployment.HttpProxy.URL,
})
if cr.Spec.Deployment.HttpProxy.SecureURL != "" {
envVars = append(envVars, v13.EnvVar{
Name: "HTTPS_PROXY",
Value: cr.Spec.Deployment.HttpProxy.SecureURL,
})
}
}

var volumeName = constants.GrafanaPluginsVolumeName
Expand Down
2 changes: 2 additions & 0 deletions deploy/manifests/latest/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4981,6 +4981,8 @@ spec:
properties:
enabled:
type: boolean
secureUrl:
type: string
url:
type: string
required:
Expand Down
7 changes: 7 additions & 0 deletions documentation/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11700,6 +11700,13 @@ GrafanaHttpProxy provides a means to configure the Grafana deployment to use an
<br/>
</td>
<td>true</td>
</tr><tr>
<td><b>secureUrl</b></td>
<td>string</td>
<td>
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>url</b></td>
<td>string</td>
Expand Down
16 changes: 16 additions & 0 deletions documentation/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ stringData:
```

If the plugin doesn't install, try restarting the grafana deployment.

## Install plugins through a HTTP(S) Proxy

To install plugins through a HTTP(S) Proxy, you will have to define the `spec.deployment.HttpProxy` section of the Grafana CR. EG:

If you need to use HTTPS, please add your HTTPS proxy URL to the `secureURL` section.

```yaml
spec:
...
deployment:
HttpProxy:
enabled: true
url: <your proxy URL here>
secureURL: <your HTTPS proxy URL here>
```

0 comments on commit 97f526b

Please sign in to comment.