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

support specifying existing volume in grafana dataStorage #810

Merged
merged 4 commits into from Aug 28, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 {
NissesSenap marked this conversation as resolved.
Show resolved Hide resolved
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