Skip to content

Commit 6116131

Browse files
Merge pull request #208 from sja/add-hpa
add autoscaling
2 parents 5569f5a + 44fff1b commit 6116131

File tree

6 files changed

+65
-4
lines changed

6 files changed

+65
-4
lines changed

helm/oauth2-proxy/Chart.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: oauth2-proxy
2-
version: 7.5.5
2+
version: 7.6.0
33
apiVersion: v2
44
appVersion: 7.6.0
55
home: https://oauth2-proxy.github.io/oauth2-proxy/
@@ -34,8 +34,8 @@ maintainers:
3434
kubeVersion: ">=1.9.0-0"
3535
annotations:
3636
artifacthub.io/changes: |
37-
- kind: changed
38-
description: Updated the Redis chart to the latest version
37+
- kind: added
38+
description: Added autoscaling
3939
links:
4040
- name: Github PR
41-
url: https://github.com/oauth2-proxy/manifests/issues/206
41+
url: https://github.com/oauth2-proxy/manifests/pull/208

helm/oauth2-proxy/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ The following table lists the configurable parameters of the oauth2-proxy chart
114114
| `config.configFile` | custom [oauth2_proxy.cfg](https://github.com/oauth2-proxy/oauth2-proxy/blob/master/contrib/oauth2-proxy.cfg.example) contents for settings not overridable via environment nor command line | `""` |
115115
| `config.existingConfig` | existing Kubernetes configmap to use for the configuration file. See [config template](https://github.com/oauth2-proxy/manifests/blob/master/helm/oauth2-proxy/templates/configmap.yaml) for the required values | `nil` |
116116
| `config.cookieName` | The name of the cookie that oauth2-proxy will create. | `""` |
117+
| `autoscaling.enabled` | Deploy a Horizontal Pod Autoscaler. | `false` |
118+
| `autoscaling.minReplicas` | Minimum replicas for the Horizontal Pod Autoscaler. | `1` |
119+
| `autoscaling.maxReplicas` | Maximum replicas for the Horizontal Pod Autoscaler. | `10` |
120+
| `autoscaling.targetCPUUtilizationPercentage` | Horizontal Pod Autoscaler setting. | `80` |
121+
| `autoscaling.targetMemoryUtilizationPercentage` | Horizontal Pod Autoscaler setting. | `` |
122+
| `autoscaling.annotations` | Horizontal Pod Autoscaler annotations. | `{}` |
117123
| `alphaConfig.enabled` | Flag to toggle any alpha config-related logic | `false` |
118124
| `alphaConfig.annotations` | Configmap annotations | `{}` |
119125
| `alphaConfig.serverConfigData` | Arbitrary configuration data to append to the server section | `{}` |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Enables Horizontal Pod Autoscaler and removes replica count in deployment
2+
autoscaling:
3+
enabled: true
4+
annotations:
5+
test-annotations/test: true

helm/oauth2-proxy/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ metadata:
1111
name: {{ template "oauth2-proxy.fullname" . }}
1212
namespace: {{ template "oauth2-proxy.namespace" $ }}
1313
spec:
14+
{{- if not .Values.autoscaling.enabled }}
1415
replicas: {{ .Values.replicaCount }}
16+
{{- end }}
1517
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
1618
{{- with .Values.strategy }}
1719
strategy:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
labels:
6+
app: {{ template "oauth2-proxy.name" . }}
7+
{{- include "oauth2-proxy.labels" . | indent 4 }}
8+
{{- if .Values.autoscaling.annotations }}
9+
annotations:
10+
{{ toYaml .Values.autoscaling.annotations | indent 8 }}
11+
{{- end }}
12+
name: {{ template "oauth2-proxy.fullname" . }}
13+
namespace: {{ template "oauth2-proxy.namespace" $ }}
14+
spec:
15+
scaleTargetRef:
16+
apiVersion: apps/v1
17+
kind: Deployment
18+
name: {{ template "oauth2-proxy.name" . }}
19+
minReplicas: {{ .Values.autoscaling.minReplicas }}
20+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
21+
metrics:
22+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
- type: Resource
24+
resource:
25+
name: cpu
26+
target:
27+
type: Utilization
28+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
29+
{{- end }}
30+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
31+
- type: Resource
32+
resource:
33+
name: memory
34+
target:
35+
type: Utilization
36+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
37+
{{- end }}
38+
{{- end }}

helm/oauth2-proxy/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@ podDisruptionBudget:
277277
enabled: true
278278
minAvailable: 1
279279

280+
## Horizontal Pod Autoscaling
281+
## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
282+
autoscaling:
283+
enabled: false
284+
minReplicas: 1
285+
maxReplicas: 10
286+
targetCPUUtilizationPercentage: 80
287+
# targetMemoryUtilizationPercentage: 80
288+
annotations: {}
289+
280290
# Configure Kubernetes security context for pod
281291
# Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
282292
podSecurityContext: {}

0 commit comments

Comments
 (0)