From 59568dc7dea8c44e08d41b1a7d79a0db25fe4f24 Mon Sep 17 00:00:00 2001 From: Akash LM Date: Mon, 11 Dec 2023 13:19:35 +0530 Subject: [PATCH] Add persistence support in Agent --- .github/workflows/helm_release.yml | 1 - charts/agent/Chart.yaml | 2 +- charts/agent/templates/deployment.yaml | 60 ++++++++++++++++++++++++-- charts/agent/templates/pvc.yaml | 13 ++++++ charts/agent/values.yaml | 31 +++++++++++-- 5 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 charts/agent/templates/pvc.yaml diff --git a/.github/workflows/helm_release.yml b/.github/workflows/helm_release.yml index f16b4250..597ddaf8 100644 --- a/.github/workflows/helm_release.yml +++ b/.github/workflows/helm_release.yml @@ -23,7 +23,6 @@ jobs: - name: Add Helm repos run: | helm repo add tools https://kube-tarian.github.io/helmrepo-supporting-tools - helm repo add bitnami https://charts.bitnami.com/bitnami - name: Run chart-releaser uses: helm/chart-releaser-action@v1.1.0 diff --git a/charts/agent/Chart.yaml b/charts/agent/Chart.yaml index 9133af69..dfadb805 100644 --- a/charts/agent/Chart.yaml +++ b/charts/agent/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.1.7 +version: 1.1.8 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/agent/templates/deployment.yaml b/charts/agent/templates/deployment.yaml index 1ce92e1d..05a8abd3 100644 --- a/charts/agent/templates/deployment.yaml +++ b/charts/agent/templates/deployment.yaml @@ -75,8 +75,24 @@ spec: value: "{{ .Values.schedule.kubepreupgradeInterval }}" - name: TRIVY_INTERVAL value: "{{ .Values.schedule.trivyInterval }}" + {{- if .Values.persistence.enabled }} + volumeMounts: + - name: data + mountPath: {{ .Values.persistence.mountPath }} + {{- end }} resources: - {{- toYaml .Values.resources | nindent 12 }} + limits: + cpu: {{ .Values.resources.limits.cpu }} + memory: {{ .Values.resources.limits.memory }} + {{- if not .Values.persistence.enabled }} + ephemeral-storage: {{ .Values.resources.limits.ephemeralstorage }} + {{- end }} + requests: + cpu: {{ .Values.resources.requests.cpu }} + memory: {{ .Values.resources.requests.memory }} + {{- if not .Values.persistence.enabled }} + ephemeral-storage: {{ .Values.resources.requests.ephemeralstorage }} + {{- end }} {{- if .Values.git_bridge.enabled }} - name: git-bridge image: "{{ .Values.git_bridge.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" @@ -99,8 +115,24 @@ spec: {{- end }} - name: NATS_ADDRESS value: {{ .Values.nats.host }} + {{- if .Values.git_bridge.persistence.enabled }} + volumeMounts: + - name: data + mountPath: {{ .Values.git_bridge.persistence.mountPath }} + {{- end }} resources: - {{- toYaml .Values.git_bridge.resources | nindent 12 }} + limits: + cpu: {{ .Values.git_bridge.resources.limits.cpu }} + memory: {{ .Values.git_bridge.resources.limits.memory }} + {{- if not .Values.git_bridge.persistence.enabled }} + ephemeral-storage: {{ .Values.git_bridge.resources.limits.ephemeralstorage }} + {{- end }} + requests: + cpu: {{ .Values.git_bridge.resources.requests.cpu }} + memory: {{ .Values.git_bridge.resources.requests.memory }} + {{- if not .Values.git_bridge.persistence.enabled }} + ephemeral-storage: {{ .Values.git_bridge.resources.requests.ephemeralstorage }} + {{- end }} {{- end }} {{- if .Values.container_bridge.enabled }} - name: container-bridge @@ -124,9 +156,31 @@ spec: {{- end }} - name: NATS_ADDRESS value: {{ .Values.nats.host }} + {{- if .Values.container_bridge.persistence.enabled }} + volumeMounts: + - name: data + mountPath: {{ .Values.container_bridge.persistence.mountPath }} + {{- end }} resources: - {{- toYaml .Values.container_bridge.resources | nindent 12 }} + limits: + cpu: {{ .Values.container_bridge.resources.limits.cpu }} + memory: {{ .Values.container_bridge.resources.limits.memory }} + {{- if not .Values.container_bridge.persistence.enabled }} + ephemeral-storage: {{ .Values.container_bridge.resources.limits.ephemeralstorage }} + {{- end }} + requests: + cpu: {{ .Values.container_bridge.resources.requests.cpu }} + memory: {{ .Values.container_bridge.resources.requests.memory }} + {{- if not .Values.container_bridge.persistence.enabled }} + ephemeral-storage: {{ .Values.container_bridge.resources.requests.ephemeralstorage }} + {{- end }} {{- end }} + {{- if .Values.persistence.enabled }} + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ include "agent.fullname" . }}-data + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/agent/templates/pvc.yaml b/charts/agent/templates/pvc.yaml new file mode 100644 index 00000000..920c3dab --- /dev/null +++ b/charts/agent/templates/pvc.yaml @@ -0,0 +1,13 @@ +{{- if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "agent.fullname" . }}-data +spec: + accessModes: + - {{ .Values.persistence.accessMode }} + storageClassName: {{ .Values.persistence.storageClass | default "" }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- end }} \ No newline at end of file diff --git a/charts/agent/values.yaml b/charts/agent/values.yaml index 7613d4ca..48aa6710 100644 --- a/charts/agent/values.yaml +++ b/charts/agent/values.yaml @@ -52,10 +52,18 @@ git_bridge: limits: cpu: 200m memory: 256Mi - ephemeral-storage: 100Mi + ephemeralstorage: 100Mi requests: cpu: 200m memory: 256Mi + ephemeralstorage: 100Mi + persistence: + enabled: true + existingClaim: "" + storageClass: "" + mountPath: /mnt/agent/gb + accessMode: ReadWriteOnce + size: 5Gi ingress: enabled: true annotations: @@ -87,10 +95,18 @@ container_bridge: limits: cpu: 200m memory: 256Mi - ephemeral-storage: 100Mi + ephemeralstorage: 100Mi requests: cpu: 200m memory: 256Mi + ephemeralstorage: 100Mi + persistence: + enabled: true + existingClaim: "" + storageClass: "" + mountPath: /mnt/agent/cb + accessMode: ReadWriteOnce + size: 5Gi ingress: enabled: true annotations: @@ -127,10 +143,19 @@ resources: limits: cpu: 2 memory: 2Gi - ephemeral-storage: 1Gi + ephemeralstorage: 1Gi requests: cpu: 200m memory: 256Mi + ephemeralstorage: 256Mi + +persistence: + enabled: true + existingClaim: "" + storageClass: "" + mountPath: /mnt/agent/kbz + accessMode: ReadWriteOnce + size: 5Gi autoscaling: enabled: false