From 5414bfcdfd9032df65654c420922175e3d5c1e52 Mon Sep 17 00:00:00 2001 From: Iridias Date: Tue, 2 Aug 2022 16:40:26 +0200 Subject: [PATCH 1/2] support specifying existing volume in grafana dataStorage --- api/integreatly/v1alpha1/grafana_types.go | 1 + .../crd/bases/integreatly.org_grafanas.yaml | 2 ++ controllers/model/grafanaDataPvc.go | 9 ++++++ .../Grafana-existingVolume.yaml | 28 +++++++++++++++++++ deploy/manifests/latest/crds.yaml | 2 ++ documentation/api.md | 7 +++++ 6 files changed, 49 insertions(+) create mode 100644 deploy/examples/persistentvolume/Grafana-existingVolume.yaml diff --git a/api/integreatly/v1alpha1/grafana_types.go b/api/integreatly/v1alpha1/grafana_types.go index 3314f651e..3231c804a 100644 --- a/api/integreatly/v1alpha1/grafana_types.go +++ b/api/integreatly/v1alpha1/grafana_types.go @@ -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 { diff --git a/config/crd/bases/integreatly.org_grafanas.yaml b/config/crd/bases/integreatly.org_grafanas.yaml index ee6067c95..1ad6eb287 100644 --- a/config/crd/bases/integreatly.org_grafanas.yaml +++ b/config/crd/bases/integreatly.org_grafanas.yaml @@ -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 diff --git a/controllers/model/grafanaDataPvc.go b/controllers/model/grafanaDataPvc.go index 7d778eecc..8d4cf8b06 100644 --- a/controllers/model/grafanaDataPvc.go +++ b/controllers/model/grafanaDataPvc.go @@ -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, @@ -41,6 +49,7 @@ func getPVCSpec(cr *v1alpha1.Grafana) corev1.PersistentVolumeClaimSpec { }, }, StorageClassName: getStorageClass(cr), + VolumeName: getVolumeName(cr), } } diff --git a/deploy/examples/persistentvolume/Grafana-existingVolume.yaml b/deploy/examples/persistentvolume/Grafana-existingVolume.yaml new file mode 100644 index 000000000..9bf61de87 --- /dev/null +++ b/deploy/examples/persistentvolume/Grafana-existingVolume.yaml @@ -0,0 +1,28 @@ +apiVersion: integreatly.org/v1alpha1 +kind: Grafana +metadata: + name: example-grafana +spec: + ingress: + enabled: True + 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]} diff --git a/deploy/manifests/latest/crds.yaml b/deploy/manifests/latest/crds.yaml index 8c1bb3c12..7d67396e6 100644 --- a/deploy/manifests/latest/crds.yaml +++ b/deploy/manifests/latest/crds.yaml @@ -2776,6 +2776,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 diff --git a/documentation/api.md b/documentation/api.md index 8ad9cfc9f..a98f94b10 100644 --- a/documentation/api.md +++ b/documentation/api.md @@ -7518,6 +7518,13 @@ GrafanaDataStorage provides a means to configure the grafana data storage
false + + volumeName + string + +
+ + false From 224dd3b33b46fc10ae6594783ad91e9342f72d65 Mon Sep 17 00:00:00 2001 From: Edvin Norling Date: Sun, 28 Aug 2022 17:38:57 +0200 Subject: [PATCH 2/2] add ingress prefix in example --- deploy/examples/persistentvolume/Grafana-existingVolume.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deploy/examples/persistentvolume/Grafana-existingVolume.yaml b/deploy/examples/persistentvolume/Grafana-existingVolume.yaml index 9bf61de87..956bec499 100644 --- a/deploy/examples/persistentvolume/Grafana-existingVolume.yaml +++ b/deploy/examples/persistentvolume/Grafana-existingVolume.yaml @@ -5,6 +5,8 @@ metadata: spec: ingress: enabled: True + pathType: Prefix + path: "/" dataStorage: accessModes: - ReadWriteMany @@ -26,3 +28,4 @@ spec: dashboardLabelSelector: - matchExpressions: - {key: app, operator: In, values: [grafana]} +