From 4cac21107c90561a1e915d0ea2e14fab6d38cfeb Mon Sep 17 00:00:00 2001 From: Ashley Felton Date: Wed, 17 Apr 2024 09:01:02 +0800 Subject: [PATCH] Added Kustomize resources: HorizontalPodAutoscaler for deployment workloads, update gunicorn. --- kustomize/base/deployment.yaml | 1 - kustomize/base/deployment_hpa.yaml | 17 +++++++++++++++ kustomize/base/kustomization.yaml | 1 + .../overlays/prod/deployment_hpa_patch.yaml | 7 +++++++ kustomize/overlays/prod/kustomization.yaml | 3 ++- .../overlays/uat/deployment_hpa_patch.yaml | 7 +++++++ kustomize/overlays/uat/kustomization.yaml | 1 + poetry.lock | 21 ++++++++++--------- pyproject.toml | 4 ++-- 9 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 kustomize/base/deployment_hpa.yaml create mode 100644 kustomize/overlays/prod/deployment_hpa_patch.yaml create mode 100644 kustomize/overlays/uat/deployment_hpa_patch.yaml diff --git a/kustomize/base/deployment.yaml b/kustomize/base/deployment.yaml index d5c5a1e..9fdd3bd 100644 --- a/kustomize/base/deployment.yaml +++ b/kustomize/base/deployment.yaml @@ -3,7 +3,6 @@ kind: Deployment metadata: name: resourcetracking-deployment spec: - replicas: 2 strategy: type: RollingUpdate template: diff --git a/kustomize/base/deployment_hpa.yaml b/kustomize/base/deployment_hpa.yaml new file mode 100644 index 0000000..c277130 --- /dev/null +++ b/kustomize/base/deployment_hpa.yaml @@ -0,0 +1,17 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: resourcetracking-deployment-hpa +spec: + minReplicas: 1 + maxReplicas: 3 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + metrics: + - resource: + name: cpu + target: + type: Utilization + averageUtilization: 250 + type: Resource diff --git a/kustomize/base/kustomization.yaml b/kustomize/base/kustomization.yaml index 0c3c1bf..52de8b3 100644 --- a/kustomize/base/kustomization.yaml +++ b/kustomize/base/kustomization.yaml @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - deployment.yaml + - deployment_hpa.yaml - service.yaml - geoserver_statefulset.yaml - geoserver_headless.yaml diff --git a/kustomize/overlays/prod/deployment_hpa_patch.yaml b/kustomize/overlays/prod/deployment_hpa_patch.yaml new file mode 100644 index 0000000..27e958e --- /dev/null +++ b/kustomize/overlays/prod/deployment_hpa_patch.yaml @@ -0,0 +1,7 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: resourcetracking-deployment-hpa +spec: + scaleTargetRef: + name: resourcetracking-deployment-prod diff --git a/kustomize/overlays/prod/kustomization.yaml b/kustomize/overlays/prod/kustomization.yaml index 30f9924..ef19d5c 100644 --- a/kustomize/overlays/prod/kustomization.yaml +++ b/kustomize/overlays/prod/kustomization.yaml @@ -23,10 +23,11 @@ labels: variant: prod patches: - path: deployment_patch.yaml + - path: deployment_hpa_patch.yaml - path: service_patch.yaml - path: geoserver_statefulset_patch.yaml - path: geoserver_headless_patch.yaml - path: geoserver_service_patch.yaml images: - name: ghcr.io/dbca-wa/resource_tracking - newTag: 1.4.8 + newTag: 1.4.9 diff --git a/kustomize/overlays/uat/deployment_hpa_patch.yaml b/kustomize/overlays/uat/deployment_hpa_patch.yaml new file mode 100644 index 0000000..d9f058e --- /dev/null +++ b/kustomize/overlays/uat/deployment_hpa_patch.yaml @@ -0,0 +1,7 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: resourcetracking-deployment-hpa +spec: + scaleTargetRef: + name: resourcetracking-deployment-uat diff --git a/kustomize/overlays/uat/kustomization.yaml b/kustomize/overlays/uat/kustomization.yaml index 5574295..3f78d91 100644 --- a/kustomize/overlays/uat/kustomization.yaml +++ b/kustomize/overlays/uat/kustomization.yaml @@ -22,6 +22,7 @@ labels: variant: uat patches: - path: deployment_patch.yaml + - path: deployment_hpa_patch.yaml - path: service_patch.yaml - path: geoserver_statefulset_patch.yaml - path: geoserver_headless_patch.yaml diff --git a/poetry.lock b/poetry.lock index 6965ec4..9f998a0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -633,22 +633,23 @@ typing = ["typing-extensions (>=4.8)"] [[package]] name = "gunicorn" -version = "21.2.0" +version = "22.0.0" description = "WSGI HTTP Server for UNIX" optional = false -python-versions = ">=3.5" +python-versions = ">=3.7" files = [ - {file = "gunicorn-21.2.0-py3-none-any.whl", hash = "sha256:3213aa5e8c24949e792bcacfc176fef362e7aac80b76c56f6b5122bf350722f0"}, - {file = "gunicorn-21.2.0.tar.gz", hash = "sha256:88ec8bff1d634f98e61b9f65bc4bf3cd918a90806c6f5c48bc5603849ec81033"}, + {file = "gunicorn-22.0.0-py3-none-any.whl", hash = "sha256:350679f91b24062c86e386e198a15438d53a7a8207235a78ba1b53df4c4378d9"}, + {file = "gunicorn-22.0.0.tar.gz", hash = "sha256:4a0b436239ff76fb33f11c07a16482c521a7e09c1ce3cc293c2330afe01bec63"}, ] [package.dependencies] packaging = "*" [package.extras] -eventlet = ["eventlet (>=0.24.1)"] +eventlet = ["eventlet (>=0.24.1,!=0.36.0)"] gevent = ["gevent (>=1.4.0)"] setproctitle = ["setproctitle"] +testing = ["coverage", "eventlet", "gevent", "pytest", "pytest-cov"] tornado = ["tornado (>=0.2)"] [[package]] @@ -1272,13 +1273,13 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "virtualenv" -version = "20.25.1" +version = "20.25.2" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.25.1-py3-none-any.whl", hash = "sha256:961c026ac520bac5f69acb8ea063e8a4f071bcc9457b9c1f28f6b085c511583a"}, - {file = "virtualenv-20.25.1.tar.gz", hash = "sha256:e08e13ecdca7a0bd53798f356d5831434afa5b07b93f0abdf0797b7a06ffe197"}, + {file = "virtualenv-20.25.2-py3-none-any.whl", hash = "sha256:6e1281a57849c8a54da89ba82e5eb7c8937b9d057ff01aaf5bc9afaa3552e90f"}, + {file = "virtualenv-20.25.2.tar.gz", hash = "sha256:fa7edb8428620518010928242ec17aa7132ae435319c29c1651d1cf4c4173aad"}, ] [package.dependencies] @@ -1287,7 +1288,7 @@ filelock = ">=3.12.2,<4" platformdirs = ">=3.9.1,<5" [package.extras] -docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] [[package]] @@ -1321,4 +1322,4 @@ brotli = ["Brotli"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "9b939226429e84caf55f9062e4d287207afc5cb489b98341dd5ffd2c10056391" +content-hash = "3a9e0357b6c1a18771f84bf948b93c62c90813bcb0539dba43e6fc81bd2aafb7" diff --git a/pyproject.toml b/pyproject.toml index c1ad8cd..6268c2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "resource_tracking" -version = "1.4.8" +version = "1.4.9" description = "DBCA internal corporate application to download and serve data from remote tracking devices." authors = ["DBCA OIM "] license = "Apache-2.0" @@ -12,7 +12,7 @@ psycopg2 = "2.9.9" dbca-utils = "2.0.2" python-dotenv = "1.0.1" dj-database-url = "2.1.0" -gunicorn = "21.2.0" +gunicorn = "22.0.0" django-extensions = "3.2.3" django-tastypie = "0.14.6" django-geojson = "4.0.0"