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

feat: Add vertical pod autoscaler template #249

Merged
merged 14 commits into from
Jul 6, 2023
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

All notable changes to this project will be documented here.

### v2.1.18
- feat: Add vertical pod autoscaler template [PR-249](https://github.com/stakater/application/pull/249)

### v2.1.17
- feat: allow overriding revisionHistoryLimit [PR-257](https://github.com/stakater/application/pull/257)

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ Stakater [Forecastle](https://github.com/stakater/Forecastle) parameters
| autoscaling.maxReplicas | Sets maximum replica count when autoscaling is enabled | `10` |
| autoscaling.metrics | Configuration for hpa metrics, set when autoscaling is enabled | `{}` |

### VPA - Vertical Pod Autoscaler Parameters

| Name | Description | Value |
| ------------------------ | -------------------------------------------------------------------------------------------- | --------------- |
| vpa.enabled | Enable vertical pod autoscaler | `false` |
| vpa.additionalLabels | Labels for vertical pod autoscaler | `{}` |
| vpa.annotations | Annotations for vertical pod autoscaler | `{}` |
| vpa.containerPolicies | container policies for individual containers. | `[]` |


### EndpointMonitor Paramaters

Stakater [IngressMonitorController](https://github.com/stakater/IngressMonitorController) EndpointMonitor parameters
Expand Down
16 changes: 16 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,21 @@ local_resource(
cmd='helm install grafana-operator -n grafana-operator oci://ghcr.io/stakater/charts/grafana-operator --version=0.0.1 --set operator.installPlanApproval=Automatic'
)

# Install openshift-vertical-pod-autoscaler
vpa_namespace = "openshift-vertical-pod-autoscaler"
namespace_create(vpa_namespace)
local_resource(
'openshift-vertical-pod-autoscaler',
cmd='helm install openshift-vertical-pod-autoscaler -n openshift-vertical-pod-autoscaler oci://ghcr.io/stakater/charts/openshift-vertical-pod-autoscaler'
)

# Wait until VPA CRD becomes available
local_resource(
'wait-for-crds',
cmd='timeout 300s bash -c "until kubectl wait --for condition=Established crd/verticalpodautoscalers.autoscaling.k8s.io; do sleep 10; done"',
resource_deps=[
'openshift-vertical-pod-autoscaler'
])

# Install cert-manager
aslafy-z marked this conversation as resolved.
Show resolved Hide resolved
# it exists already
5 changes: 5 additions & 0 deletions Tiltfile-delete
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def delete_external_secrets_operator():
print('Deleting external-secrets operator')
local('helm uninstall external-secrets-operator -n external-secrets-operator')

def delete_openshift_vertical_pod_autoscaler():
print('Uninstalling openshift-vertical-pod-autoscaler')
local('helm uninstall openshift-vertical-pod-autoscaler -n openshift-vertical-pod-autoscaler')

def delete_imc_crds():
print('Deleting imc crds')
local('oc get crds -o name | grep \'endpointmonitor\\.stakater\\.com\' | xargs -r -n 1 oc delete')
Expand All @@ -34,6 +38,7 @@ def delete_grafana_crds():

delete_grafana_operator()
delete_external_secrets_operator()
delete_openshift_vertical_pod_autoscaler()
delete_imc_crds()
delete_forecastle_crds()
delete_ss_crds()
Expand Down
27 changes: 27 additions & 0 deletions application/templates/vpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.vpa.enabled -}}
{{- if not (.Capabilities.APIVersions.Has "autoscaling.k8s.io/v1/VerticalPodAutoscaler") }}
{{- fail "There is no VerticalPodAutoscaler resource definition in the target cluster!" }}
{{- end }}
apiVersion: "autoscaling.k8s.io/v1"
kind: VerticalPodAutoscaler
metadata:
name: {{ template "application.name" . }}
namespace: {{ include "application.namespace" . }}
labels:
{{- include "application.labels" . | nindent 4 }}
{{- with .Values.vpa.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.vpa.annotations }}
annotations:
{{- toYaml .Values.vpa.annotations | nindent 4 }}
{{- end }}
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "application.name" . }}
resourcePolicy:
containerPolicies:
{{- toYaml .Values.vpa.containerPolicies | nindent 6 }}
{{- end }}
21 changes: 21 additions & 0 deletions application/values-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,27 @@ autoscaling:
type: Utilization
averageUtilization: 60

# autoscaling is used for vertical pod autoscaling
vpa:
# enabled is a boolean flag for enabling or disabling vpa
enabled: true
# additionalLabels defines additional labels
additionalLabels:
# key: value
# annotations defines annotations in key value pair
annotations:
# key: value
# container policies for individual containers.
# There can be at most one entry for every named container and optionally a single wildcard entry with `containerName = '*'`, which handles all containers that do not have individual policies.
containerPolicies:
- containerName: '*'
minAllowed:
cpu: 0.5
memory: 1Gi
maxAllowed:
cpu: 1
memory: 5Gi

# EndpointMonitor for IMC (https://github.com/stakater/IngressMonitorController)
endpointMonitor:
enabled: true
Expand Down
15 changes: 15 additions & 0 deletions application/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,21 @@ autoscaling:
type: Utilization
averageUtilization: 60

##########################################################
# VPA - Vertical Pod Autoscaling
##########################################################
vpa:
# enabled is a boolean flag for enabling or disabling vpa
enabled: false
# additionalLabels defines additional labels
additionalLabels:
# key: value
# annotations defines annotations in key value pair
annotations:
# key: value
# container policies for individual containers.
containerPolicies: []

##########################################################
# EndpointMonitor for IMC
# https://github.com/stakater/IngressMonitorController
Expand Down