diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a47750f..a1fa8cc 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, 2.x/develop] permissions: contents: read @@ -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: 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