Skip to content

Commit

Permalink
chore: increase pod replicas
Browse files Browse the repository at this point in the history
Increase django service replicas from 1 to 2
Increase PgBouncer service replicas from 1 to 2
  • Loading branch information
saladgg committed Aug 30, 2023
1 parent 0191af7 commit c1814ab
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 105 deletions.
162 changes: 81 additions & 81 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,81 @@
#name: CI
#
#on: [push]
#
#env:
# COMPOSE_DOCKER_CLI_BUILD: 1
# DJANGO_DEBUG: true
# DJANGO_EMAIL_BACKEND: "${{ secrets.DJANGO_EMAIL_BACKEND }}"
# DJANGO_GCP_STORAGE_BUCKET_NAME: "${{ secrets.DJANGO_GCP_STORAGE_BUCKET_NAME }}"
# DJANGO_SECRET_KEY: "${{ secrets.DJANGO_SECRET_KEY }}"
# DOCKER_BUILDKIT: 1 # Enable Buildkit and let compose use it to speed up image building
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# GOOGLE_ANALYTICS_ID: "${{ secrets.GOOGLE_ANALYTICS_ID }}"
# GOOGLE_APPLICATION_CREDENTIALS: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
# GOOGLE_CLOUD_PROJECT: "${{ secrets.GOOGLE_CLOUD_PROJECT }}"
# POSTGRES_DB: postgres
# POSTGRES_HOST: localhost
# POSTGRES_PASSWORD: postgres
# POSTGRES_PORT: 5432
# POSTGRES_USER: postgres
# TEST_POSTGRES_DB: idr_server_test
# TEST_POSTGRES_HOST: localhost
# TEST_POSTGRES_PASSWORD: postgres
# TEST_POSTGRES_PORT: 5432
# TEST_POSTGRES_USER: postgres
# USE_DOCKER: no
#
#jobs:
# build:
# runs-on: ubuntu-latest
# strategy:
# max-parallel: 4
# matrix:
# python-version: ["3.11"]
#
# # Service containers to run with `container-job`
# services:
# postgres:
# image: postgis/postgis:15-3.3
# env:
# POSTGRES_PASSWORD: postgres
# POSTGRES_DB: postgres
# POSTGRES_USER: postgres
# # Set health checks to wait until postgres has started
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# # Maps tcp port 5432 on service container to the host
# - 5432:5432
#
# steps:
# - uses: actions/checkout@v3
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v3
# with:
# python-version: ${{ matrix.python-version }}
#
# # Run all pre-commit hooks on all the files.
# # Getting only staged files can be tricky in case a new PR is opened
# # since the action is run on a branch in detached head state
# - name: Install and run pre-commit
# uses: pre-commit/action@v3.0.0
#
# - name: Install Requirements
# run: |
# sudo apt-get update
# sudo apt-get install postgis gdal-bin libgdal-dev
# python -m pip install --upgrade pip
# python -m pip install tox tox-gh-actions
# npm ci
#
# - name: Authenticate to Google Cloud
# uses: google-github-actions/auth@v0
# with:
# credentials_json: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
#
# - name: Test with tox
# run: tox -r
name: CI

on: [push]

env:
COMPOSE_DOCKER_CLI_BUILD: 1
DJANGO_DEBUG: true
DJANGO_EMAIL_BACKEND: "${{ secrets.DJANGO_EMAIL_BACKEND }}"
DJANGO_GCP_STORAGE_BUCKET_NAME: "${{ secrets.DJANGO_GCP_STORAGE_BUCKET_NAME }}"
DJANGO_SECRET_KEY: "${{ secrets.DJANGO_SECRET_KEY }}"
DOCKER_BUILDKIT: 1 # Enable Buildkit and let compose use it to speed up image building
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GOOGLE_ANALYTICS_ID: "${{ secrets.GOOGLE_ANALYTICS_ID }}"
GOOGLE_APPLICATION_CREDENTIALS: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
GOOGLE_CLOUD_PROJECT: "${{ secrets.GOOGLE_CLOUD_PROJECT }}"
POSTGRES_DB: postgres
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
TEST_POSTGRES_DB: idr_server_test
TEST_POSTGRES_HOST: localhost
TEST_POSTGRES_PASSWORD: postgres
TEST_POSTGRES_PORT: 5432
TEST_POSTGRES_USER: postgres
USE_DOCKER: no

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ["3.11"]

# Service containers to run with `container-job`
services:
postgres:
image: postgis/postgis:15-3.3
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_USER: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
# since the action is run on a branch in detached head state
- name: Install and run pre-commit
uses: pre-commit/action@v3.0.0

- name: Install Requirements
run: |
sudo apt-get update
sudo apt-get install postgis gdal-bin libgdal-dev
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
npm ci
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v0
with:
credentials_json: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"

- name: Test with tox
run: tox -r
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: ^deploy/
- id: check-added-large-files

- repo: https://github.com/psf/black
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ steps:
- django.configmap.config_name=${_CONFIGMAP_FILE}
- .

# Update essential variables and Deploy to cluster
# Update essential Variables and Deploy to cluster
- id: "update essential variables and start deployment to cluster"
dir: "deploy"
name: "gcr.io/$PROJECT_ID/helm:3.7.0"
Expand Down
8 changes: 4 additions & 4 deletions config/settings/gcp_k8ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from .base import * # noqa
from .base import env

################################################################################
# NOTICE: ENVIRONMENT VARIABLES HAVE BEEN SOURCED IN THE POD RUNNING THE SERVICE
################################################################################
# -----------------------------------------------------------
# NOTE: Environment Variables have been sourced as configmaps
# -----------------------------------------------------------


###############################################################################
Expand Down Expand Up @@ -225,4 +225,4 @@
integrations=integrations,
environment=env.str("SENTRY_ENVIRONMENT", default="production"),
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=1.0),
)
)
2 changes: 1 addition & 1 deletion config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@
integrations=integrations,
environment=env.str("SENTRY_ENVIRONMENT", default="production"),
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=1.0),
)
)
4 changes: 2 additions & 2 deletions deploy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ sources:
description: IDR-Server Deployment Chart

type: application
version: 0.1.6
appVersion: "v1.6.5"
version: 0.1.7
appVersion: "v1.6.5"
3 changes: 1 addition & 2 deletions deploy/templates/django/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
app: {{ .Values.django.app_name }}
spec:
replicas: {{ .Values.replica_count }}
replicas: {{ .Values.django.replica_count }}
selector:
matchLabels:
app: {{ .Values.django.app_name }}
Expand Down Expand Up @@ -35,4 +35,3 @@ spec:
- name: env-var-vol
configMap:
name: {{ .Values.django.configmap.config_name }}

1 change: 0 additions & 1 deletion deploy/templates/django/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ spec:
protocol: TCP
port: {{ .Values.django.image.container_port }}
targetPort: {{ .Values.django.image.container_port }}

1 change: 0 additions & 1 deletion deploy/templates/ingress/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ spec:
name: {{ .Values.django.app_name }}-service
port:
number: {{ .Values.django.image.container_port }}

2 changes: 0 additions & 2 deletions deploy/templates/pg-bouncer/db_configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ data:
POSTGRESQL_PASSWORD: {{ .Values.pg_bouncer.env.db_password }}
POSTGRESQL_HOST: {{ .Values.pg_bouncer.env.db_host }}
POSTGRESQL_PORT: {{ .Values.pg_bouncer.env.db_port | toString | quote }}


1 change: 0 additions & 1 deletion deploy/templates/pg-bouncer/dbuser_configmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ data:
# echo -n '"user" "pa$$worLd"' | base64
userlist.txt: |
{{ .Values.pg_bouncer.env.db_user | toString | quote }} {{ .Values.pg_bouncer.env.db_password | toString | quote }}
2 changes: 1 addition & 1 deletion deploy/templates/pg-bouncer/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ .Values.pg_bouncer.app_name }}
namespace: {{ .Values.namespace }}
spec:
replicas: 1
replicas: {{ .Values.pg_bouncer.replica_count }}
selector:
matchLabels:
app: {{ .Values.pg_bouncer.app_name }}
Expand Down
7 changes: 2 additions & 5 deletions deploy/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace: cluster_namespace
replica_count: 1

django:
app_name: django
replica_count: 1
replica_count: 2
image:
repository: repo
tag: commit_sha
Expand All @@ -19,7 +18,6 @@ django:

cloud_sql:
app_name: cloudsql-proxy
replica_count: 1
image:
repository: gcr.io/cloud-sql-connectors/cloud-sql-proxy
tag: "2.6.0"
Expand All @@ -28,7 +26,7 @@ cloud_sql:

pg_bouncer:
app_name: pgbouncer
replica_count: 1
replica_count: 2
image:
repository: bitnami/pgbouncer
tag: "1.19.1"
Expand All @@ -53,4 +51,3 @@ ingress:
acme:
server: "https://acme-v02.api.letsencrypt.org/directory"
email: "support@mail.fahariyajamii.org"

3 changes: 0 additions & 3 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,3 @@ gunicorn~=20.1.0
python-dotenv~=1.0.0
sentry-sdk~=1.19.0
uvicorn~=0.21.1

pytest~=7.2.2
Faker~=18.3.2

0 comments on commit c1814ab

Please sign in to comment.