diff --git a/addons/grafana/parameter.cue b/addons/grafana/parameter.cue index 225e14a3e..242af8b80 100644 --- a/addons/grafana/parameter.cue +++ b/addons/grafana/parameter.cue @@ -27,7 +27,7 @@ parameter: { // +usage=The clusters to install clusters?: [...string] // +usage=Specify the image of kube-state-metrics - image: *"grafana/grafana:8.5.3" | string + image: *"grafana/grafana:10.2.1" | string // +usage=Specify the imagePullPolicy of the image imagePullPolicy: *"IfNotPresent" | "Never" | "Always" // +usage=Specify the number of CPU units @@ -35,7 +35,7 @@ parameter: { // +usage=Specifies the attributes of the memory resource required for the container. memory: *"1024Mi" | string // +usage=Specify the service type for expose prometheus server. Default to be ClusterIP. - serviceType: *"ClusterIP" | "NodePort" | "LoadBalancer" + serviceType: *"NodePort" | "ClusterIP" | "LoadBalancer" // +usage=Specify the storage size to use. If empty, emptyDir will be used. Otherwise pvc will be used. storage?: =~"^([1-9][0-9]{0,63})(E|P|T|G|M|K|Ei|Pi|Ti|Gi|Mi|Ki)$" // +usage=Specify the storage class to use. @@ -43,5 +43,5 @@ parameter: { // +usage=Specify the admin user for grafana adminUser: *"admin" | string // +usage=Specify the admin password for grafana - adminPassword: *"kubevela" | string + adminPassword: *"admin" | string } diff --git a/addons/grafana/resources/grafana.cue b/addons/grafana/resources/grafana.cue index f6a08cd79..4d6ab9c9f 100644 --- a/addons/grafana/resources/grafana.cue +++ b/addons/grafana/resources/grafana.cue @@ -20,10 +20,20 @@ grafana: { path: "/api/health" port: 3000 } - volumeMounts: emptyDir: [{ - name: "storage" - mountPath: "/var/lib/grafana" - }] + + if parameter.storage == _|_ { + volumeMounts: emptyDir: [{ + name: "storage-volume" + mountPath: "/var/lib/grafana" + }] + } + if parameter.storage != _|_ { + volumeMounts: pvc: [{ + name: "storage-volume" + mountPath: "/var/lib/grafana" + claimName: "grafana-storage" + }] + } env: [{ name: "GF_SECURITY_ADMIN_USER" valueFrom: secretKeyRef: { diff --git a/addons/grafana/template.cue b/addons/grafana/template.cue index 422761948..46d79d9f9 100644 --- a/addons/grafana/template.cue +++ b/addons/grafana/template.cue @@ -23,7 +23,7 @@ output: { policies: commonPolicies + [{ type: "override" name: "grafana-core" - properties: selector: [o11yNamespace.name, grafanaAccess.name, grafana.name] + properties: selector: [o11yNamespace.name, grafanaStorage.name,grafanaAccess.name, grafana.name] }, { type: "override" name: "grafana-dashboards"