Skip to content

Commit

Permalink
helm: clean up logic for autodelete pvcs
Browse files Browse the repository at this point in the history
  • Loading branch information
captncraig committed Jan 3, 2024
1 parent 4171583 commit 4883cf3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions operations/helm/charts/grafana-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ internal API changes are not present.
Unreleased
----------

### Bugfixes

- Statefulset should use value `.controller.enableStatefulSetAutoDeletePVC` instead of just `.enableStatefulSetAutoDeletePVC`. (@captncraig)

### Enhancements

- Update `rbac` to include necessary rules for the `otelcol.processor.k8sattributes` component. (@rlankfo)
- Add value `.controller.minK8sVersionForAutoDelete` to support earlier k8s versions with beta feature gates enabled. (@captncraig)

0.29.0 (2023-11-30)
-------------------
Expand Down
1 change: 1 addition & 0 deletions operations/helm/charts/grafana-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ use the older mode (called "static mode"), set the `agent.mode` value to
| controller.hostNetwork | bool | `false` | Configures Pods to use the host network. When set to true, the ports that will be used must be specified. |
| controller.hostPID | bool | `false` | Configures Pods to use the host PID namespace. |
| controller.initContainers | list | `[]` | |
| controller.minK8sVersionForAutoDelete | string | `">= 1.27"` | The StatefulSetAutoDeletePVC feature gate went into alpha status with k8s 1.27. If you have it enabled on an earlier version, you can lower this value as far as 1.23. |
| controller.nodeSelector | object | `{}` | nodeSelector to apply to Grafana Agent pods. |
| controller.parallelRollout | bool | `true` | Whether to deploy pods in parallel. Only used when controller.type is 'statefulset'. |
| controller.podAnnotations | object | `{}` | Extra pod annotations to add. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ controller:
type: statefulset
autoscaling:
enabled: true
enableStatefulSetAutoDeletePVC: true
minK8sVersionForAutoDelete: ">= 1.26"
agent:
resources:
requests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{- if eq .Values.controller.type "statefulset" }}
{{- if .Values.enableStatefulSetAutoDeletePVC }}
{{- fail "Value 'enableStatefulSetAutoDeletePVC' should be nested inside 'controller' options." }}
{{- end }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand Down Expand Up @@ -35,8 +38,8 @@ spec:
- {{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- if and (semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version) (.Values.enableStatefulSetAutoDeletePVC) }}
{{/*
{{- if and (semverCompare .Values.controller.minK8sVersionForAutoDelete .Capabilities.KubeVersion.Version) (.Values.controller.enableStatefulSetAutoDeletePVC) }}
{{- /*
Data on the read nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
*/}}
Expand Down
3 changes: 3 additions & 0 deletions operations/helm/charts/grafana-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ controller:
# -- Whether to enable automatic deletion of stale PVCs due to a scale down operation, when controller.type is 'statefulset'.
enableStatefulSetAutoDeletePVC: false

# -- The StatefulSetAutoDeletePVC feature gate went into alpha status with k8s 1.27. If you have it enabled on an earlier version, you can lower this value as far as 1.23.
minK8sVersionForAutoDelete: ">= 1.27"

autoscaling:
# -- Creates a HorizontalPodAutoscaler for controller type deployment.
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion operations/helm/scripts/rebuild-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ for chart_file in $(find * -name Chart.yaml -print | sort); do
FILENAME=$(basename ${FILE_PATH})
TESTNAME=${FILENAME%-values.yaml}
# Render chart
helm template --namespace default --debug ${CHART_NAME} ${CHART_DIR} -f ${FILE_PATH} --output-dir ${TEST_DIR}/${TESTNAME} --set '$chart_tests=true'
helm template --namespace default --kube-version 1.26 --debug ${CHART_NAME} ${CHART_DIR} -f ${FILE_PATH} --output-dir ${TEST_DIR}/${TESTNAME} --set '$chart_tests=true'
done
fi
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ spec:
- name: config
configMap:
name: grafana-agent
persistentVolumeClaimRetentionPolicy:
whenDeleted: Delete
whenScaled: Delete

0 comments on commit 4883cf3

Please sign in to comment.