Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm: nginx HPA and tests kubeversion fixes #4299

Merged
merged 7 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion operations/helm/charts/mimir-distributed/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Entries should include a reference to the Pull Request that introduced the chang

## main / unreleased

* [ENHANCEMENT] Support autoscaling/v2 HorizontalPodAutoscaler for nginx autoscaling starting with Kubernetes 1.23.
* [ENHANCEMENT] Support autoscaling/v2 HorizontalPodAutoscaler for nginx autoscaling starting with Kubernetes 1.23. #4285
* [BUGFIX] Allow override of Kubernetes version for nginx HPA. #4299

## 4.2.0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Pin kube version so results are the same for running in CI and locally where the installed kube version may be different.
kubeVersionOverride: "1.20"

enterprise:
enabled: true
gateway:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Pin kube version so results are the same for running in CI and locally where the installed kube version may be different.
kubeVersionOverride: "1.20"

nginx:
enabled: false
gateway:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nginx auth secret name
Returns the HorizontalPodAutoscaler API version for this verison of kubernetes.
*/}}
{{- define "mimir.hpa.version" -}}
{{- if semverCompare ">= 1.23-0" .Capabilities.KubeVersion.Version -}}
{{- if semverCompare ">= 1.23-0" (include "mimir.kubeVersion" .) -}}
autoscaling/v2
{{- else -}}
autoscaling/v2beta1
Expand Down
14 changes: 13 additions & 1 deletion operations/helm/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ set -euo pipefail
# use a normal sed on macOS if available
SED=$(which gsed || which sed)

# DEFAULT_KUBE_VERSION is used if the input values do not contain "kubeVersionOverride"
DEFAULT_KUBE_VERSION="1.20"

CHART_PATH="operations/helm/charts/mimir-distributed"
INTERMEDIATE_PATH=""
OUTPUT_PATH=""
Expand Down Expand Up @@ -59,9 +62,18 @@ for FILEPATH in $TESTS; do
INTERMEDIATE_OUTPUT_DIR="${INTERMEDIATE_PATH}/${TEST_NAME}-generated"
OUTPUT_DIR="${OUTPUT_PATH}/${TEST_NAME}-generated"

echo ""
echo "Templating $TEST_NAME"
ARGS=("${TEST_NAME}" "${CHART_PATH}" "-f" "${FILEPATH}" "--output-dir" "${INTERMEDIATE_OUTPUT_DIR}" "--namespace" "citestns")

echo "Checking for kubeVersionOverride inside tests' values.yaml ..."
if ! grep "^kubeVersionOverride:" "${FILEPATH}" ; then
echo "Warning: injecting Kubernetes version override: kubeVersionOverride=${DEFAULT_KUBE_VERSION}"
ARGS+=("--set-string" "kubeVersionOverride=${DEFAULT_KUBE_VERSION}")
fi

set -x
helm template "${TEST_NAME}" "${CHART_PATH}" -f "${FILEPATH}" --output-dir "${INTERMEDIATE_OUTPUT_DIR}" --namespace citestns
helm template "${ARGS[@]}"
set +x

echo "Removing mutable config checksum, helm chart, application, image tag version for clarity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/gateway/gateway-v2-hpa.yaml
apiVersion: autoscaling/v2
# Source: mimir-distributed/templates/gateway/gateway-v2beta1-hpa.yaml
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: gateway-enterprise-values-mimir-gateway
Expand All @@ -21,12 +21,8 @@ spec:
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageUtilization: 70
targetAverageUtilization: 70
- type: Resource
resource:
name: cpu
target:
type: AverageValue
averageUtilization: 70
targetAverageUtilization: 70
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/ingester/ingester-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: gateway-enterprise-values-mimir-ingester
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/store-gateway/store-gateway-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: gateway-enterprise-values-mimir-store-gateway
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/gateway/gateway-v2-hpa.yaml
apiVersion: autoscaling/v2
# Source: mimir-distributed/templates/gateway/gateway-v2beta1-hpa.yaml
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: gateway-nginx-values-mimir-gateway
Expand All @@ -21,12 +21,8 @@ spec:
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageUtilization: 70
targetAverageUtilization: 70
- type: Resource
resource:
name: cpu
target:
type: AverageValue
averageUtilization: 70
targetAverageUtilization: 70
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/ingester/ingester-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: gateway-nginx-values-mimir-ingester
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/store-gateway/store-gateway-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: gateway-nginx-values-mimir-store-gateway
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/ingester/ingester-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: large-values-mimir-ingester
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/store-gateway/store-gateway-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: large-values-mimir-store-gateway
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/ingester/ingester-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: small-values-mimir-ingester
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Source: mimir-distributed/templates/store-gateway/store-gateway-pdb.yaml
apiVersion: policy/v1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: small-values-mimir-store-gateway
Expand Down