From eb1e735d4527481f510fd5139cd341e520ddfa07 Mon Sep 17 00:00:00 2001 From: Niko Kovacevic Date: Wed, 30 Sep 2020 17:30:57 -0600 Subject: [PATCH] Add PV for kubecost-cost-analyzer-db --- README.md | 1 + .../cost-analyzer-deployment-template.yaml | 36 +++++++++++++++++++ cost-analyzer/values.yaml | 1 + 3 files changed, 38 insertions(+) diff --git a/README.md b/README.md index 02f3aac75..92bbf8629 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Parameter | Description | Default `prometheus.pushgateway.persistentVolume.enabled` | If true, Prometheus Pushgateway will create a Persistent Volume Claim. | `true` `persistentVolume.enabled` | If true, Kubecost will create a Persistent Volume Claim for product config data. | `true` `persistentVolume.size` | Define PVC size for cost-analyzer | `0.2Gi` +`persistentVolume.dbSize` | Define PVC size for cost-analyzer's flat file database | `32.0Gi` `ingress.enabled` | If true, Ingress will be created | `false` `ingress.annotations` | Ingress annotations | `{}` `ingress.paths` | Ingress paths | `["/"]` diff --git a/cost-analyzer/templates/cost-analyzer-deployment-template.yaml b/cost-analyzer/templates/cost-analyzer-deployment-template.yaml index eec1d15e0..a09a399f8 100755 --- a/cost-analyzer/templates/cost-analyzer-deployment-template.yaml +++ b/cost-analyzer/templates/cost-analyzer-deployment-template.yaml @@ -145,6 +145,22 @@ spec: {{- else }} persistentVolumeClaim: claimName: {{ template "cost-analyzer.fullname" . }} +{{- end }} + - name: persistent-db +{{- if .Values.persistentVolume }} +{{- if .Values.persistentVolume.enabled }} + persistentVolumeClaim: +{{- if .Values.persistentVolume.existingClaim }} + claimName: {{ .Values.persistentVolume.existingClaim }} +{{- else }} + claimName: {{ template "cost-analyzer.fullname" . }}-db +{{- end -}} +{{- else }} + emptyDir: {} +{{- end -}} +{{- else }} + persistentVolumeClaim: + claimName: {{ template "cost-analyzer.fullname" . }}-db {{- end }} initContainers: {{- if .Values.supportNFS }} @@ -162,6 +178,22 @@ spec: mountPath: /var/configs securityContext: runAsUser: 0 +{{ end }} +{{- if .Values.supportNFS }} + - name: db-perms-fix + {{- if .Values.initChownDataImage }} + image: {{ .Values.initChownDataImage }} + {{- else }} + image: busybox + {{- end }} + resources: +{{ toYaml .Values.initChownData.resources | indent 12 }} + command: ["/bin/chmod", "-R", "777", "/var/db"] + volumeMounts: + - name: persistent-db + mountPath: /var/db + securityContext: + runAsUser: 0 {{ end }} containers: {{- if .Values.kubecostModel }} @@ -191,6 +223,8 @@ spec: volumeMounts: - name: persistent-configs mountPath: /var/configs + - name: persistent-db + mountPath: /var/db {{- if .Values.kubecostProductConfigs }} {{- if .Values.kubecostProductConfigs.gcpSecretName }} - name: gcp-key-secret @@ -241,6 +275,8 @@ spec: value: /var/configs/key.json - name: CONFIG_PATH value: /var/configs/ + - name: DB_PATH + value: /var/db/ - name: CLUSTER_PROFILE {{- if .Values.kubecostProductConfigs }} value: {{ .Values.kubecostProductConfigs.clusterProfile | default "production" }} diff --git a/cost-analyzer/values.yaml b/cost-analyzer/values.yaml index 576721506..0f69673e5 100755 --- a/cost-analyzer/values.yaml +++ b/cost-analyzer/values.yaml @@ -152,6 +152,7 @@ podSecurityPolicy: # Define persistence volume for cost-analyzer persistentVolume: size: 0.2Gi + dbSize: 32.0Gi enabled: true # Note that setting this to false means configurations will be wiped out on pod restart. # storageClass: "-" # # existingClaim: kubecost-cost-analyzer # a claim in the same namespace as kubecost