Skip to content

Commit

Permalink
support specifying existing volume in grafana dataStorage (#810)
Browse files Browse the repository at this point in the history
* support specifying existing volume in grafana dataStorage
  • Loading branch information
Iridias committed Aug 28, 2022
1 parent 9520d85 commit b7f9dc5
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/integreatly/v1alpha1/grafana_types.go
Expand Up @@ -92,6 +92,7 @@ type GrafanaDataStorage struct {
AccessModes []v1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
Size resource.Quantity `json:"size,omitempty"`
Class string `json:"class,omitempty"`
VolumeName string `json:"volumeName,omitempty"`
}

type GrafanaServiceAccount struct {
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/integreatly.org_grafanas.yaml
Expand Up @@ -2125,6 +2125,8 @@ spec:
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
volumeName:
type: string
type: object
deployment:
description: GrafanaDeployment provides a means to configure the deployment
Expand Down
9 changes: 9 additions & 0 deletions controllers/model/grafanaDataPvc.go
Expand Up @@ -32,6 +32,14 @@ func getStorageClass(cr *v1alpha1.Grafana) *string {
return &cr.Spec.DataStorage.Class
}

func getVolumeName(cr *v1alpha1.Grafana) string {
if cr.Spec.DataStorage == nil {
return ""
}

return cr.Spec.DataStorage.VolumeName
}

func getPVCSpec(cr *v1alpha1.Grafana) corev1.PersistentVolumeClaimSpec {
return corev1.PersistentVolumeClaimSpec{
AccessModes: cr.Spec.DataStorage.AccessModes,
Expand All @@ -41,6 +49,7 @@ func getPVCSpec(cr *v1alpha1.Grafana) corev1.PersistentVolumeClaimSpec {
},
},
StorageClassName: getStorageClass(cr),
VolumeName: getVolumeName(cr),
}
}

Expand Down
31 changes: 31 additions & 0 deletions deploy/examples/persistentvolume/Grafana-existingVolume.yaml
@@ -0,0 +1,31 @@
apiVersion: integreatly.org/v1alpha1
kind: Grafana
metadata:
name: example-grafana
spec:
ingress:
enabled: True
pathType: Prefix
path: "/"
dataStorage:
accessModes:
- ReadWriteMany
size: 10Gi
volumeName: "grafanads"
class: "azurefile-csi"
config:
log:
mode: "console"
level: "warn"
security:
admin_user: "root"
admin_password: "secret"
auth:
disable_login_form: False
disable_signout_menu: True
auth.anonymous:
enabled: True
dashboardLabelSelector:
- matchExpressions:
- {key: app, operator: In, values: [grafana]}

2 changes: 2 additions & 0 deletions deploy/manifests/latest/crds.yaml
Expand Up @@ -2791,6 +2791,8 @@ spec:
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
volumeName:
type: string
type: object
deployment:
description: GrafanaDeployment provides a means to configure the deployment
Expand Down
7 changes: 7 additions & 0 deletions documentation/api.md
Expand Up @@ -7532,6 +7532,13 @@ GrafanaDataStorage provides a means to configure the grafana data storage
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>volumeName</b></td>
<td>string</td>
<td>
<br/>
</td>
<td>false</td>
</tr></tbody>
</table>

Expand Down

0 comments on commit b7f9dc5

Please sign in to comment.