From a052529c44a4efb5b09c67f41fc801dc16a3ed8c Mon Sep 17 00:00:00 2001 From: Csaky Date: Thu, 30 Jan 2025 12:33:41 -0800 Subject: [PATCH] Deployment scaling configuration changes --- .github/environments/values.dev.yaml | 17 ++----- .github/environments/values.prod.yaml | 42 ++++------------- .github/environments/values.test.yaml | 27 +---------- charts/ches/Chart.yaml | 2 +- charts/ches/README.md | 30 +++---------- charts/ches/templates/app.dc.yaml | 3 -- charts/ches/templates/hpa.yaml | 20 ++++++++- charts/ches/templates/pdb.yaml | 14 ++++++ charts/ches/values.yaml | 65 +++++---------------------- 9 files changed, 64 insertions(+), 156 deletions(-) create mode 100644 charts/ches/templates/pdb.yaml diff --git a/.github/environments/values.dev.yaml b/.github/environments/values.dev.yaml index 2783d59..6e6632d 100644 --- a/.github/environments/values.dev.yaml +++ b/.github/environments/values.dev.yaml @@ -1,7 +1,8 @@ --- autoscaling: - enabled: true - maxReplicas: 4 + enabled: false +pdb: + enabled: false config: enabled: true @@ -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 diff --git a/.github/environments/values.prod.yaml b/.github/environments/values.prod.yaml index dd1c0ed..6fda584 100644 --- a/.github/environments/values.prod.yaml +++ b/.github/environments/values.prod.yaml @@ -1,7 +1,8 @@ --- autoscaling: enabled: true - maxReplicas: 4 +pdb: + enabled: true config: enabled: true @@ -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: @@ -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: @@ -137,9 +120,6 @@ postgres: requests: cpu: 1m memory: 16Mi - limits: - cpu: 35m - memory: 32Mi redis: architecture: replication @@ -161,9 +141,6 @@ redis: accessMode: ReadWriteOnce size: 25Mi resources: - limits: - cpu: 100m - memory: 256Mi requests: cpu: 25m memory: 64Mi @@ -184,9 +161,6 @@ redis: whenScaled: Delete whenDeleted: Delete resources: - limits: - cpu: 100m - memory: 256Mi requests: cpu: 25m memory: 64Mi diff --git a/.github/environments/values.test.yaml b/.github/environments/values.test.yaml index a4edc6f..5dabddd 100644 --- a/.github/environments/values.test.yaml +++ b/.github/environments/values.test.yaml @@ -1,7 +1,8 @@ --- autoscaling: enabled: true - maxReplicas: 4 +pdb: + enabled: true config: enabled: true @@ -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: @@ -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: @@ -151,9 +134,6 @@ redis: accessMode: ReadWriteOnce size: 25Mi resources: - limits: - cpu: 100m - memory: 256Mi requests: cpu: 25m memory: 64Mi @@ -174,9 +154,6 @@ redis: whenScaled: Delete whenDeleted: Delete resources: - limits: - cpu: 100m - memory: 256Mi requests: cpu: 25m memory: 64Mi diff --git a/charts/ches/Chart.yaml b/charts/ches/Chart.yaml index 5a11e14..8d5e1d1 100644 --- a/charts/ches/Chart.yaml +++ b/charts/ches/Chart.yaml @@ -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. diff --git a/charts/ches/README.md b/charts/ches/README.md index 24cdd4c..8819e2e 100644 --- a/charts/ches/README.md +++ b/charts/ches/README.md @@ -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 @@ -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. | @@ -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"` | | @@ -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..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 | @@ -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` | | @@ -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 | diff --git a/charts/ches/templates/app.dc.yaml b/charts/ches/templates/app.dc.yaml index cd99e9e..0c06620 100644 --- a/charts/ches/templates/app.dc.yaml +++ b/charts/ches/templates/app.dc.yaml @@ -172,9 +172,6 @@ spec: requests: cpu: 10m memory: 16Mi - limits: - cpu: 50m - memory: 64Mi volumeMounts: - name: log-storage mountPath: /var/log diff --git a/charts/ches/templates/hpa.yaml b/charts/ches/templates/hpa.yaml index a1490d4..e82b079 100644 --- a/charts/ches/templates/hpa.yaml +++ b/charts/ches/templates/hpa.yaml @@ -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 }} diff --git a/charts/ches/templates/pdb.yaml b/charts/ches/templates/pdb.yaml new file mode 100644 index 0000000..fc2f3ec --- /dev/null +++ b/charts/ches/templates/pdb.yaml @@ -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 }} diff --git a/charts/ches/values.yaml b/charts/ches/values.yaml index 52200c5..be91aae 100644 --- a/charts/ches/values.yaml +++ b/charts/ches/values.yaml @@ -2,7 +2,7 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 2 +# replicaCount: 2 image: # -- Default image repository @@ -43,27 +43,13 @@ securityContext: autoscaling: # -- Specifies whether the Horizontal Pod Autoscaler should be created enabled: false - - # -- behavior configures the scaling behavior of the target in both Up and Down directions (scaleUp and scaleDown fields respectively). - behavior: - scaleDown: - stabilizationWindowSeconds: 120 - selectPolicy: Max - policies: - - type: Pods - value: 1 - periodSeconds: 120 - scaleUp: - stabilizationWindowSeconds: 0 - selectPolicy: Max - policies: - - type: Pods - value: 2 - periodSeconds: 30 - minReplicas: 2 - maxReplicas: 16 + minReplicas: 3 + maxReplicas: 8 targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 +# pod disruption budget. +pdb: + enabled: false + minAvailable: 2 # the minimum number of pods that must be available during the disruption budget. serviceAccount: # -- Specifies whether a service account should be created @@ -106,11 +92,11 @@ resources: # choice for the user. This also increases chances charts run on environments with little # resources, such as Minikube. If you do want to specify resources, uncomment the following # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - limits: - # -- Limit Peak CPU (in millicores ex. 1000m) - cpu: 200m - # -- Limit Peak Memory (in gigabytes Gi or megabytes Mi ex. 2Gi) - memory: 256Mi + # limits: + # # -- Limit Peak CPU (in millicores ex. 1000m) + # cpu: 200m + # # -- Limit Peak Memory (in gigabytes Gi or megabytes Mi ex. 2Gi) + # memory: 256Mi requests: # -- Requested CPU (in millicores ex. 500m) cpu: 50m @@ -160,9 +146,6 @@ redis: accessMode: ReadWriteOnce size: 25Mi resources: - limits: - cpu: 50m - memory: 150Mi requests: cpu: 20m memory: 50Mi @@ -183,9 +166,6 @@ redis: whenScaled: Delete whenDeleted: Delete resources: - limits: - cpu: 50m - memory: 150Mi requests: cpu: 20m memory: 50Mi @@ -230,18 +210,12 @@ postgres: requests: cpu: 50m memory: 128Mi - limits: - cpu: 100m - memory: 256Mi sidecars: replicaCertCopy: resources: requests: cpu: 1m memory: 32Mi - limits: - cpu: 50m - memory: 64Mi # ------- postgres user/db configuration ---------- users: @@ -272,34 +246,22 @@ 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 # ----- pgBouncer (network pooling) ------ pgBouncerConfig: @@ -311,9 +273,6 @@ postgres: requests: cpu: 5m memory: 32Mi - limits: - cpu: 20m - memory: 64Mi # -------- monitoring ---------- monitoring: false