From 005b20a0926c5b11d85c42f692dcb0e06e5a4489 Mon Sep 17 00:00:00 2001 From: Andrew Srg Date: Sun, 17 Mar 2024 22:52:26 +0200 Subject: [PATCH 1/4] feature: add kubernetes config --- .gitignore | 1 + kubeconf/config.yml | 12 +++++ kubeconf/deployment.yml | 95 +++++++++++++++++++++++++++++++++++ kubeconf/secrets_template.yml | 14 ++++++ kubeconf/service.yml | 11 ++++ 5 files changed, 133 insertions(+) create mode 100644 kubeconf/config.yml create mode 100644 kubeconf/deployment.yml create mode 100644 kubeconf/secrets_template.yml create mode 100644 kubeconf/service.yml diff --git a/.gitignore b/.gitignore index 6f0482f..2f62c7b 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ dmypy.json /pytest.ini /docker-compose.yml /keycloak/ +/kubeconf/secrets.yml diff --git a/kubeconf/config.yml b/kubeconf/config.yml new file mode 100644 index 0000000..5046f99 --- /dev/null +++ b/kubeconf/config.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: costy-config + +data: + auth0_audience: "https://dev-66quvcmw46dh86sh.us.auth0.com/api/v2/" + auth0_authorize_url: "https://dev-66quvcmw46dh86sh.us.auth0.com/oauth/token" + auth0_connection: "Username-Password-Authentication" + auth0_issuer: "https://dev-66quvcmw46dh86sh.us.auth0.com/" + auth0_jwks_uri: "https://dev-66quvcmw46dh86sh.us.auth0.com/.well-known/jwks.json" + auth0_register_url: "https://dev-66quvcmw46dh86sh.us.auth0.com/dbconnections/signup" diff --git a/kubeconf/deployment.yml b/kubeconf/deployment.yml new file mode 100644 index 0000000..82be0c3 --- /dev/null +++ b/kubeconf/deployment.yml @@ -0,0 +1,95 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: costy-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: costy-app + template: + metadata: + labels: + app: costy-app + spec: + containers: + - name: app + image: sergienkoandrew/costy + ports: + - containerPort: 80 + command: [ "/bin/sh","-c" ] + args: ["python -m uvicorn costy.main.web:init_app --reload --factory --host 0.0.0.0 --port 80"] + readinessProbe: + httpGet: + path: /schema/openapi.json + port: 80 + periodSeconds: 5 + failureThreshold: 5 + successThreshold: 1 + timeoutSeconds: 5 + env: + - name: DB_NAME + valueFrom: + secretKeyRef: + name: costy-secrets + key: db_name + - name: DB_USER + valueFrom: + secretKeyRef: + name: costy-secrets + key: db_username + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: costy-secrets + key: db_password + - name: DB_HOST + valueFrom: + secretKeyRef: + name: costy-secrets + key: db_host + - name: DB_PORT + valueFrom: + secretKeyRef: + name: costy-secrets + key: db_port + - name: AUTH0_CLIENT_ID + valueFrom: + secretKeyRef: + name: costy-secrets + key: auth0_client_id + - name: AUTH0_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: costy-secrets + key: auth0_client_secret + - name: AUTH0_AUDIENCE + valueFrom: + configMapKeyRef: + name: costy-config + key: auth0_audience + - name: AUTH0_AUTHORIZE_URL + valueFrom: + configMapKeyRef: + name: costy-config + key: auth0_authorize_url + - name: AUTH0_CONNECTION + valueFrom: + configMapKeyRef: + name: costy-config + key: auth0_connection + - name: AUTH0_ISSUER + valueFrom: + configMapKeyRef: + name: costy-config + key: auth0_issuer + - name: AUTH0_JWKS_URI + valueFrom: + configMapKeyRef: + name: costy-config + key: auth0_jwks_uri + - name: AUTH0_REGISTER_URL + valueFrom: + configMapKeyRef: + name: costy-config + key: auth0_register_url diff --git a/kubeconf/secrets_template.yml b/kubeconf/secrets_template.yml new file mode 100644 index 0000000..ebf56d5 --- /dev/null +++ b/kubeconf/secrets_template.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Secret +metadata: + name: costy-secrets +type: Opaque + +stringData: + db_name: "" + db_username: "" + db_password: "" + db_host: "" + db_port: "" + auth0_client_id: "" + auth0_client_secret: "" diff --git a/kubeconf/service.yml b/kubeconf/service.yml new file mode 100644 index 0000000..1b2eaa9 --- /dev/null +++ b/kubeconf/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: costy-service +spec: + type: LoadBalancer + ports: + - port: 80 + targetPort: 80 + selector: + app: costy-app From c5e7848fb919e48412d7cc6ff58c57b089d2d74a Mon Sep 17 00:00:00 2001 From: Andrew Srg Date: Mon, 18 Mar 2024 12:58:18 +0200 Subject: [PATCH 2/4] refactor: fix branch name in ci workflow --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a47750f..c1ba684 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -3,7 +3,7 @@ name: tests on: pull_request: push: - branches: [main] + branches: [2.x/main] permissions: contents: read From 3bab5b7b6fbfa4b5b40b67ed1b7ee341219078be Mon Sep 17 00:00:00 2001 From: Andrew Srg Date: Mon, 18 Mar 2024 12:59:31 +0200 Subject: [PATCH 3/4] refactor: add develop branch name in ci workflow --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c1ba684..0e519e8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -3,7 +3,7 @@ name: tests on: pull_request: push: - branches: [2.x/main] + branches: [2.x/main, 2.x/develop] permissions: contents: read From 337e4336a9b4d61943ad907f65c2e5904e174305 Mon Sep 17 00:00:00 2001 From: Andrew Srg Date: Mon, 18 Mar 2024 13:22:38 +0200 Subject: [PATCH 4/4] refactor: edit tests run command in pipeline --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0e519e8..a1fa8cc 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -50,7 +50,7 @@ jobs: pip install -e .[ci-tests] - name: Test with pytest run: | - pytest tests --cov="../src" + coverage run --source=src/ -m pytest - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 with: