Skip to content

Commit

Permalink
Merge pull request #143 from bcgov/scaling-config
Browse files Browse the repository at this point in the history
Deployment scaling configuration changes
  • Loading branch information
jatindersingh93 authored Jan 30, 2025
2 parents 2ab89f0 + a052529 commit a8ae378
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 156 deletions.
17 changes: 3 additions & 14 deletions .github/environments/values.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
autoscaling:
enabled: true
maxReplicas: 4
enabled: false
pdb:
enabled: false

config:
enabled: true
Expand Down Expand Up @@ -44,31 +45,19 @@ postgres:
requests:
cpu: 20m
memory: 128Mi
limits:
cpu: 50m
memory: 256Mi
sidecars:
pgbackrest:
resources:
requests:
cpu: 5m
memory: 16Mi
limits:
cpu: 20m
memory: 64Mi
pgbackrestConfig:
resources:
requests:
cpu: 5m
memory: 32Mi
limits:
cpu: 20m
memory: 64Mi
jobs:
resources:
requests:
cpu: 10m
memory: 64Mi
limits:
cpu: 50m
memory: 128Mi
42 changes: 8 additions & 34 deletions .github/environments/values.prod.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
autoscaling:
enabled: true
maxReplicas: 4
pdb:
enabled: true

config:
enabled: true
Expand Down Expand Up @@ -32,20 +33,14 @@ postgres:
storageClassName: "netapp-block-standard"
resources:
requests:
cpu: 200m
memory: 256Mi
limits:
cpu: 400m
cpu: 256Mi
memory: 512Mi
sidecars:
replicaCertCopy:
resources:
requests:
cpu: 1m
memory: 32Mi
limits:
cpu: 50m
memory: 64Mi
cpu: 25m
memory: 50Mi

# -------- backups ---------
pgBackRestConfig:
Expand All @@ -56,34 +51,22 @@ postgres:
repoHost:
resources:
requests:
cpu: 50m
memory: 256Mi
limits:
cpu: 100m
memory: 512Mi
memory: 256Mi
sidecars:
pgbackrest:
resources:
requests:
cpu: 30m
memory: 64Mi
limits:
cpu: 90m
memory: 256Mi
cpu: 50m
memory: 100Mi
pgbackrestConfig:
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi
jobs:
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 100m
memory: 256Mi
configuration:
Expand Down Expand Up @@ -137,9 +120,6 @@ postgres:
requests:
cpu: 1m
memory: 16Mi
limits:
cpu: 35m
memory: 32Mi

redis:
architecture: replication
Expand All @@ -161,9 +141,6 @@ redis:
accessMode: ReadWriteOnce
size: 25Mi
resources:
limits:
cpu: 100m
memory: 256Mi
requests:
cpu: 25m
memory: 64Mi
Expand All @@ -184,9 +161,6 @@ redis:
whenScaled: Delete
whenDeleted: Delete
resources:
limits:
cpu: 100m
memory: 256Mi
requests:
cpu: 25m
memory: 64Mi
27 changes: 2 additions & 25 deletions .github/environments/values.test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
autoscaling:
enabled: true
maxReplicas: 4
pdb:
enabled: true

config:
enabled: true
Expand Down Expand Up @@ -35,18 +36,12 @@ postgres:
requests:
cpu: 200m
memory: 256Mi
limits:
cpu: 400m
memory: 512Mi
sidecars:
replicaCertCopy:
resources:
requests:
cpu: 1m
memory: 32Mi
limits:
cpu: 50m
memory: 64Mi

# -------- backups ---------
pgBackRestConfig:
Expand All @@ -59,34 +54,22 @@ postgres:
requests:
cpu: 50m
memory: 256Mi
limits:
cpu: 100m
memory: 512Mi
sidecars:
pgbackrest:
resources:
requests:
cpu: 30m
memory: 64Mi
limits:
cpu: 90m
memory: 256Mi
pgbackrestConfig:
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi
jobs:
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
cpu: 100m
memory: 256Mi
configuration:
# secret for saving backups to S3
- secret:
Expand Down Expand Up @@ -151,9 +134,6 @@ redis:
accessMode: ReadWriteOnce
size: 25Mi
resources:
limits:
cpu: 100m
memory: 256Mi
requests:
cpu: 25m
memory: 64Mi
Expand All @@ -174,9 +154,6 @@ redis:
whenScaled: Delete
whenDeleted: Delete
resources:
limits:
cpu: 100m
memory: 256Mi
requests:
cpu: 25m
memory: 64Mi
2 changes: 1 addition & 1 deletion charts/ches/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: common-hosted-email-service
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.7
version: 1.0.8
kubeVersion: ">= 1.13.0"
description: An API for sending emails with scheduling and mail merge features
# A chart can be either an 'application' or a 'library' chart.
Expand Down
30 changes: 5 additions & 25 deletions charts/ches/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# common-hosted-email-service

![Version: 1.0.7](https://img.shields.io/badge/Version-1.0.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.8.0](https://img.shields.io/badge/AppVersion-0.8.0-informational?style=flat-square)
![Version: 1.0.8](https://img.shields.io/badge/Version-1.0.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.8.0](https://img.shields.io/badge/AppVersion-0.8.0-informational?style=flat-square)

An API for sending emails with scheduling and mail merge features

Expand Down Expand Up @@ -29,10 +29,9 @@ Kubernetes: `>= 1.13.0`

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| autoscaling.behavior | object | `{"scaleDown":{"policies":[{"periodSeconds":120,"type":"Pods","value":1}],"selectPolicy":"Max","stabilizationWindowSeconds":120},"scaleUp":{"policies":[{"periodSeconds":30,"type":"Pods","value":2}],"selectPolicy":"Max","stabilizationWindowSeconds":0}}` | behavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). |
| autoscaling.enabled | bool | `false` | Specifies whether the Horizontal Pod Autoscaler should be created |
| autoscaling.maxReplicas | int | `16` | |
| autoscaling.minReplicas | int | `2` | |
| autoscaling.maxReplicas | int | `8` | |
| autoscaling.minReplicas | int | `3` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| config.configMap | object | `{"DB_PORT":"5432","SERVER_ATTACHMENTLIMIT":"20mb","SERVER_BODYLIMIT":"100mb","SERVER_LOGLEVEL":"http","SERVER_PORT":"3000","SERVER_SMTPHOST":"apps.smtp.gov.bc.ca"}` | These values will be wholesale added to the configmap as is; refer to the ches documentation for what each of these values mean and whether you need them defined. Ensure that all values are represented explicitly as strings, as non-string values will not translate over as expected into container environment variables. For configuration keys named `*_ENABLED`, either leave them commented/undefined, or set them to string value "true". |
| config.enabled | bool | `false` | Set to true if you want to let Helm manage and overwrite your configmaps. |
Expand All @@ -45,6 +44,8 @@ Kubernetes: `>= 1.13.0`
| imagePullSecrets | list | `[]` | Specify docker-registry secret names as an array |
| nameOverride | string | `nil` | String to partially override fullname |
| networkPolicy.enabled | bool | `true` | Specifies whether a network policy should be created |
| pdb.enabled | bool | `false` | |
| pdb.minAvailable | int | `2` | |
| podAnnotations | object | `{}` | Annotations for ches pods |
| podSecurityContext | object | `{}` | Privilege and access control settings |
| postgres.databaseInitSQL.key | string | `"bootstrap.sql"` | |
Expand All @@ -56,37 +57,23 @@ Kubernetes: `>= 1.13.0`
| postgres.instances[0].dataVolumeClaimSpec.storageClassName | string | `"netapp-block-standard"` | |
| postgres.instances[0].name | string | `"db"` | |
| postgres.instances[0].replicas | int | `2` | |
| postgres.instances[0].resources.limits.cpu | string | `"100m"` | |
| postgres.instances[0].resources.limits.memory | string | `"256Mi"` | |
| postgres.instances[0].resources.requests.cpu | string | `"50m"` | |
| postgres.instances[0].resources.requests.memory | string | `"128Mi"` | |
| postgres.instances[0].sidecars.replicaCertCopy.resources.limits.cpu | string | `"50m"` | |
| postgres.instances[0].sidecars.replicaCertCopy.resources.limits.memory | string | `"64Mi"` | |
| postgres.instances[0].sidecars.replicaCertCopy.resources.requests.cpu | string | `"1m"` | |
| postgres.instances[0].sidecars.replicaCertCopy.resources.requests.memory | string | `"32Mi"` | |
| postgres.monitoring | bool | `false` | |
| postgres.pgBackRestConfig.jobs.resources.limits.cpu | string | `"50m"` | |
| postgres.pgBackRestConfig.jobs.resources.limits.memory | string | `"128Mi"` | |
| postgres.pgBackRestConfig.jobs.resources.requests.cpu | string | `"10m"` | |
| postgres.pgBackRestConfig.jobs.resources.requests.memory | string | `"64Mi"` | |
| postgres.pgBackRestConfig.manual.options[0] | string | `"--type=full"` | |
| postgres.pgBackRestConfig.manual.repoName | string | `"repo1"` | |
| postgres.pgBackRestConfig.repoHost.resources.limits.cpu | string | `"50m"` | |
| postgres.pgBackRestConfig.repoHost.resources.limits.memory | string | `"256Mi"` | |
| postgres.pgBackRestConfig.repoHost.resources.requests.cpu | string | `"20m"` | |
| postgres.pgBackRestConfig.repoHost.resources.requests.memory | string | `"128Mi"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrest.resources.limits.cpu | string | `"20m"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrest.resources.limits.memory | string | `"64Mi"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrest.resources.requests.cpu | string | `"5m"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrest.resources.requests.memory | string | `"16Mi"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrestConfig.resources.limits.cpu | string | `"20m"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrestConfig.resources.limits.memory | string | `"64Mi"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrestConfig.resources.requests.cpu | string | `"5m"` | |
| postgres.pgBackRestConfig.sidecars.pgbackrestConfig.resources.requests.memory | string | `"32Mi"` | |
| postgres.pgBouncerConfig.config.global.client_tls_sslmode | string | `"disable"` | |
| postgres.pgBouncerConfig.replicas | int | `2` | |
| postgres.pgBouncerConfig.resources.limits.cpu | string | `"20m"` | |
| postgres.pgBouncerConfig.resources.limits.memory | string | `"64Mi"` | |
| postgres.pgBouncerConfig.resources.requests.cpu | string | `"5m"` | |
| postgres.pgBouncerConfig.resources.requests.memory | string | `"32Mi"` | |
| postgres.postgresVersion | int | `16` | ------------------------------ note: override methodology: - defaults exist in subchart postgres - overrides that apply to all ches environments are defined in this values.yaml file - overrides specific to a single environment are defined in values.<environment>.yaml name of the cluster. in ches pipeline we pass this in Helm deploy command in github action eg: --set postgres.name=postgres-master name: postgres-master |
Expand All @@ -103,8 +90,6 @@ Kubernetes: `>= 1.13.0`
| redis.replica.persistentVolumeClaimRetentionPolicy.enabled | bool | `true` | |
| redis.replica.persistentVolumeClaimRetentionPolicy.whenDeleted | string | `"Delete"` | |
| redis.replica.replicaCount | int | `2` | |
| redis.replica.resources.limits.cpu | string | `"50m"` | |
| redis.replica.resources.limits.memory | string | `"150Mi"` | |
| redis.replica.resources.requests.cpu | string | `"20m"` | |
| redis.replica.resources.requests.memory | string | `"50Mi"` | |
| redis.replica.shareProcessNamespace | bool | `true` | |
Expand All @@ -120,13 +105,8 @@ Kubernetes: `>= 1.13.0`
| redis.sentinel.persistentVolumeClaimRetentionPolicy.whenScaled | string | `"Delete"` | |
| redis.sentinel.podSecurityContext | object | `{}` | |
| redis.sentinel.quorum | int | `1` | |
| redis.sentinel.resources.limits.cpu | string | `"50m"` | |
| redis.sentinel.resources.limits.memory | string | `"150Mi"` | |
| redis.sentinel.resources.requests.cpu | string | `"20m"` | |
| redis.sentinel.resources.requests.memory | string | `"50Mi"` | |
| replicaCount | int | `2` | |
| resources.limits.cpu | string | `"200m"` | Limit Peak CPU (in millicores ex. 1000m) |
| resources.limits.memory | string | `"256Mi"` | Limit Peak Memory (in gigabytes Gi or megabytes Mi ex. 2Gi) |
| resources.requests.cpu | string | `"50m"` | Requested CPU (in millicores ex. 500m) |
| resources.requests.memory | string | `"128Mi"` | Requested Memory (in gigabytes Gi or megabytes Mi ex. 500Mi) |
| route.annotations | object | `{}` | Annotations to add to the route |
Expand Down
3 changes: 0 additions & 3 deletions charts/ches/templates/app.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ spec:
requests:
cpu: 10m
memory: 16Mi
limits:
cpu: 50m
memory: 64Mi
volumeMounts:
- name: log-storage
mountPath: /var/log
Expand Down
20 changes: 19 additions & 1 deletion charts/ches/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ spec:
{{- end }}
{{- with .Values.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 10
periodSeconds: 60
- type: Pods
value: 2
periodSeconds: 60
selectPolicy: Min
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 30
- type: Pods
value: 2
periodSeconds: 30
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/ches/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if and .Values.pdb .Values.pdb.enabled }}
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "ches.fullname" . }}
labels:
{{- include "ches.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "ches.selectorLabels" . | nindent 6 }}
minAvailable: {{ .Values.pdb.minAvailable }}
{{- end }}
Loading

0 comments on commit a8ae378

Please sign in to comment.