Skip to content

Commit

Permalink
Support setting tolerations, nodeSelector, and affinity during helm i…
Browse files Browse the repository at this point in the history
…nstall (#8)

* add affinity/nodeSelector/tolerations in helm chart deployment file

* add hpa

* configure hpa when autoscaling is true

* resolve comments
  • Loading branch information
linglingye001 authored Jan 31, 2024
1 parent 04da47a commit 5716345
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
21 changes: 17 additions & 4 deletions deploy/parameter/helm-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,31 @@ securityContext:

resources:
limits:
cpu: 500m
memory: 128Mi
cpu: 100m
memory: 256Mi
requests:
cpu: 10m
cpu: 20m
memory: 64Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 5
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80

env:
azureClientId: ""
azureTenantId: ""
azureTenantId: ""

# Pod scheduling preferences
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}

# Node labels for pod assignment
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
nodeSelector: {}

# Tolerations for nodes that have taints on them.
# ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration
tolerations: []
26 changes: 26 additions & 0 deletions deploy/templates/autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "az-appconfig-k8s-provider.fullname" . }}-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "az-appconfig-k8s-provider.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
12 changes: 12 additions & 0 deletions deploy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ spec:
labels:
{{- include "az-appconfig-k8s-provider.selectorLabels" . | nindent 8 }}
spec:
{{- if .Values.nodeSelector }}
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{- toYaml .Values.tolerations | nindent 8 }}
{{- end }}
containers:
- args:
- --leader-elect
Expand Down

0 comments on commit 5716345

Please sign in to comment.