diff --git a/charts/udash-agent/README.md b/charts/udash-agent/README.md index 7846fa6..e61868a 100644 --- a/charts/udash-agent/README.md +++ b/charts/udash-agent/README.md @@ -123,6 +123,11 @@ helm uninstall udash-agent | images.agentrelay.tag | string | `"v0.14.0@sha256:a52edcb9535d8c392a2e592bf7c3b4fc0c14ecd4b1360aa96639145038b5da75"` | Overrides the image tag whose default is the chart appVersion. | | nameOverride | string | `""` | Override for the chart name used in resource names. | | nodeSelector | object | `{}` | Node selector for pod scheduling. | +| persistence.accessModes | list | `["ReadWriteOnce"]` | Access modes for the PersistentVolumeClaim. | +| persistence.annotations | object | `{}` | Annotations to add to the PersistentVolumeClaim. | +| persistence.enabled | bool | `false` | Enable a PersistentVolumeClaim to persist the Updatecli tmp folder (`/tmp/updatecli`) across executions. One PVC is created per agent CronJob and per Argo workflow entry. | +| persistence.size | string | `"1Gi"` | Size of the PersistentVolumeClaim. | +| persistence.storageClassName | string | `""` | Storage class name for the PersistentVolumeClaim. Leave empty to use the cluster default. | | podAnnotations | object | `{}` | Annotations to add to all pods. | | podSecurityContext | object | `{}` | Pod-level security context. | | resources | object | `{}` | Resource requests and limits for all containers. Ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | diff --git a/charts/udash-agent/templates/argoworkflow.yaml b/charts/udash-agent/templates/argoworkflow.yaml index 5fc9277..2363013 100644 --- a/charts/udash-agent/templates/argoworkflow.yaml +++ b/charts/udash-agent/templates/argoworkflow.yaml @@ -15,16 +15,28 @@ spec: - name: updatecli-compose-file description: the updatecli compose file default: updatecli-compose.yaml + {{- if $.Values.persistence.enabled }} + - name: tmp-pvc-name + description: PersistentVolumeClaim name for the updatecli tmp folder + {{- end }} templates: - name: main volumes: - name: workspace emptyDir: {} + {{- if $.Values.persistence.enabled }} + - name: updatecli-tmp + persistentVolumeClaim: + claimName: "{{ "{{" }} inputs.parameters.tmp-pvc-name {{ "}}" }}" + {{- end }} inputs: parameters: - name: repo-url - name: repo-branch - name: updatecli-compose-file + {{- if $.Values.persistence.enabled }} + - name: tmp-pvc-name + {{- end }} containerSet: volumeMounts: - mountPath: /workspace @@ -55,6 +67,11 @@ spec: # {{- end }} resources: {{- toYaml $.Values.resources | nindent 14 }} + {{- if $.Values.persistence.enabled }} + volumeMounts: + - mountPath: /tmp/updatecli + name: updatecli-tmp + {{- end }} args: - | cd /workspace @@ -123,4 +140,8 @@ spec: value: "{{ $workflow.branch }}" - name: updatecli-compose-file value: "{{ $workflow.composefile }}" + {{- if $.Values.persistence.enabled }} + - name: tmp-pvc-name + value: "{{ include "udash.fullname" $ }}-workflow-{{ $id }}" + {{- end }} #{{ end }} diff --git a/charts/udash-agent/templates/cronjob-agent.yaml b/charts/udash-agent/templates/cronjob-agent.yaml index de1a066..8f8de4e 100644 --- a/charts/udash-agent/templates/cronjob-agent.yaml +++ b/charts/udash-agent/templates/cronjob-agent.yaml @@ -52,11 +52,20 @@ spec: - name: "config" mountPath: "/etc/updatecli/" readonly: true + {{- if $.Values.persistence.enabled }} + - name: updatecli-tmp + mountPath: /tmp/updatecli + {{- end }} volumes: - name: config configMap: name: '{{ include "udash.configMapName" $ }}-agent-{{ $id }}' + {{- if $.Values.persistence.enabled }} + - name: updatecli-tmp + persistentVolumeClaim: + claimName: '{{ include "udash.fullname" $ }}-agent-{{ $id }}' + {{- end }} {{- with $.Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/udash-agent/templates/pvc-agent.yaml b/charts/udash-agent/templates/pvc-agent.yaml new file mode 100644 index 0000000..567670e --- /dev/null +++ b/charts/udash-agent/templates/pvc-agent.yaml @@ -0,0 +1,24 @@ +{{- if $.Values.persistence.enabled }} +{{ range $id, $agent := .Values.agents }} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "udash.fullname" $ }}-agent-{{ $id }} + labels: + {{- include "udash.labels" $ | nindent 4 }} + {{- with $.Values.persistence.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + accessModes: + {{- toYaml $.Values.persistence.accessModes | nindent 4 }} + resources: + requests: + storage: {{ $.Values.persistence.size }} + {{- if $.Values.persistence.storageClassName }} + storageClassName: {{ $.Values.persistence.storageClassName }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/udash-agent/templates/pvc-workflow.yaml b/charts/udash-agent/templates/pvc-workflow.yaml new file mode 100644 index 0000000..c84c9d9 --- /dev/null +++ b/charts/udash-agent/templates/pvc-workflow.yaml @@ -0,0 +1,24 @@ +{{- if and $.Values.persistence.enabled $.Values.workflows }} +{{ range $id, $workflow := .Values.workflows }} +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "udash.fullname" $ }}-workflow-{{ $id }} + labels: + {{- include "udash.labels" $ | nindent 4 }} + {{- with $.Values.persistence.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + accessModes: + {{- toYaml $.Values.persistence.accessModes | nindent 4 }} + resources: + requests: + storage: {{ $.Values.persistence.size }} + {{- if $.Values.persistence.storageClassName }} + storageClassName: {{ $.Values.persistence.storageClassName }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/udash-agent/values.yaml b/charts/udash-agent/values.yaml index 384997c..c17fd4b 100644 --- a/charts/udash-agent/values.yaml +++ b/charts/udash-agent/values.yaml @@ -110,6 +110,19 @@ autoscaling: targetCPUUtilizationPercentage: 80 # targetMemoryUtilizationPercentage: 80 +persistence: + # -- Enable a PersistentVolumeClaim to persist the Updatecli tmp folder (`/tmp/updatecli`) across executions. One PVC is created per agent CronJob and per Argo workflow entry. + enabled: false + # -- Storage class name for the PersistentVolumeClaim. Leave empty to use the cluster default. + storageClassName: "" + # -- Access modes for the PersistentVolumeClaim. + accessModes: + - ReadWriteOnce + # -- Size of the PersistentVolumeClaim. + size: 1Gi + # -- Annotations to add to the PersistentVolumeClaim. + annotations: {} + # -- Node selector for pod scheduling. nodeSelector: {} # -- Tolerations for pod scheduling.