From 338e33401a282ae6c83d7355663d564d4932efd6 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Wed, 23 Aug 2023 18:48:11 -0300 Subject: [PATCH] Fixes Storage Service Integration --- deploy.sh | 7 +++++++ deployment/backend/backend.yaml | 17 +++++++++++++---- setup.py | 19 +++++++------------ .../cert-manager-certificate.template.yaml | 1 - template/nginx-ingress/nginx-ingress-api.yaml | 14 -------------- .../nginx-ingress/nginx-ingress-root.yaml | 11 ----------- template/storage/storage-secret.template.yaml | 1 - 7 files changed, 27 insertions(+), 43 deletions(-) diff --git a/deploy.sh b/deploy.sh index 8f75173..786940a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -23,6 +23,13 @@ function application_deploy() { kubectl apply -f ./deployment/portfolio-namespace.yaml; + + kubectl apply -f ./deployment/postgres/postgres-secret.yaml; + kubectl apply -f ./deployment/redis/redis-secret.yaml; + kubectl apply -f ./deployment/storage/storage-secret.yaml; + kubectl apply -f ./deployment/backend/backend-secret.yaml; + kubectl apply -f ./deployment/frontend/frontend-secret.yaml; + kubectl apply -f \ ./deployment/cert-manager/cert-manager-certificate.yaml; diff --git a/deployment/backend/backend.yaml b/deployment/backend/backend.yaml index 46d71d1..7f4662a 100644 --- a/deployment/backend/backend.yaml +++ b/deployment/backend/backend.yaml @@ -16,7 +16,7 @@ spec: containers: - name: backend image: yoshiunfriendly/backend-hideyoshi.com - imagePullPolicy: "Always" + imagePullPolicy: Always ports: - containerPort: 8070 env: @@ -155,12 +155,21 @@ spec: name: redis-secret key: redis-password - - name: STORAGE_SERVICE_PATH + - name: STORAGE_SERVICE_URL valueFrom: - secretKeyRef: - name: storage-secret + configMapKeyRef: + name: storage-config key: storage_url + - name: STORAGE_SERVICE_PORT + valueFrom: + configMapKeyRef: + name: storage-config + key: storage_port + + - name: STORAGE_SERVICE_PATH + value: "http://$(STORAGE_SERVICE_URL):$(STORAGE_SERVICE_PORT)" + --- apiVersion: v1 kind: Service diff --git a/setup.py b/setup.py index 289aa8d..02676e5 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ from pathlib import Path, PosixPath import argparse import os - ENV_VARIABLES = [ "FRONTEND_PATH", "BACKEND_URL", @@ -35,7 +34,6 @@ ENV_VARIABLES = [ "AWS_BUCKET_NAME", ] - FORCE_BASE64_FIELD = [ "OAUTH_GITHUB_CLIENT_ID", "OAUTH_GITHUB_CLIENT_SECRET", @@ -67,17 +65,14 @@ def setting_environment(environment: str): match environment: case "staging": - DOMAIN="staging.hideyoshi.com.br" - API_DOMAIN="api.staging.hideyoshi.com.br" - STORAGE_API_DOMAIN="storage.staging.hideyoshi.com.br" + DOMAIN = "staging.hideyoshi.com.br" + API_DOMAIN = "api.staging.hideyoshi.com.br" case _: - DOMAIN="hideyoshi.com.br" - API_DOMAIN="api.hideyoshi.com.br" - STORAGE_API_DOMAIN="storage.hideyoshi.com.br" + DOMAIN = "hideyoshi.com.br" + API_DOMAIN = "api.hideyoshi.com.br" os.environ["DOMAIN"] = DOMAIN os.environ["API_DOMAIN"] = API_DOMAIN - os.environ["STORAGE_API_DOMAIN"] = STORAGE_API_DOMAIN def load_secret_file(file: str): @@ -102,8 +97,8 @@ def envsubst_file(file: PosixPath): with open(file) as f: formated_file = envsubst(f.read()) - new_file = Path("deployment")\ - .joinpath(*[part.split('.')[0] for part in file.parts if part != "template"])\ + new_file = Path("deployment") \ + .joinpath(*[part.split('.')[0] for part in file.parts if part != "template"]) \ .with_suffix(".yaml") with open(new_file, 'w') as f: @@ -143,4 +138,4 @@ if __name__ == "__main__": args = parser.parse_args() - main(**vars(args)) \ No newline at end of file + main(**vars(args)) diff --git a/template/cert-manager/cert-manager-certificate.template.yaml b/template/cert-manager/cert-manager-certificate.template.yaml index a5b05e7..09d5a1b 100644 --- a/template/cert-manager/cert-manager-certificate.template.yaml +++ b/template/cert-manager/cert-manager-certificate.template.yaml @@ -7,7 +7,6 @@ spec: dnsNames: - ${DOMAIN} - ${API_DOMAIN} - - ${STORAGE_API_DOMAIN} secretName: letsencrypt-cluster-certificate-tls issuerRef: name: cluster-certificate-issuer diff --git a/template/nginx-ingress/nginx-ingress-api.yaml b/template/nginx-ingress/nginx-ingress-api.yaml index 7c94e11..1c3d214 100644 --- a/template/nginx-ingress/nginx-ingress-api.yaml +++ b/template/nginx-ingress/nginx-ingress-api.yaml @@ -16,13 +16,6 @@ spec: - host: ${DOMAIN} http: paths: - - path: /api/storage - pathType: Prefix - backend: - service: - name: storage-service - port: - number: 8000 - path: /api(/|$)(.*) pathType: Prefix backend: @@ -32,13 +25,6 @@ spec: number: 8070 - http: paths: - - path: /api/storage - pathType: Prefix - backend: - service: - name: storage-service - port: - number: 8000 - path: /api(/|$)(.*) pathType: Prefix backend: diff --git a/template/nginx-ingress/nginx-ingress-root.yaml b/template/nginx-ingress/nginx-ingress-root.yaml index 243089e..e752f56 100644 --- a/template/nginx-ingress/nginx-ingress-root.yaml +++ b/template/nginx-ingress/nginx-ingress-root.yaml @@ -12,7 +12,6 @@ spec: - hosts: - ${DOMAIN} - ${API_DOMAIN} - - ${STORAGE_API_DOMAIN} secretName: letsencrypt-cluster-certificate-tls rules: - host: ${DOMAIN} @@ -35,16 +34,6 @@ spec: name: backend-service port: number: 8070 - - host: ${STORAGE_API_DOMAIN} - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: storage-service - port: - number: 8000 - http: paths: - path: / diff --git a/template/storage/storage-secret.template.yaml b/template/storage/storage-secret.template.yaml index 0d3c07d..4da3faf 100644 --- a/template/storage/storage-secret.template.yaml +++ b/template/storage/storage-secret.template.yaml @@ -5,7 +5,6 @@ metadata: name: storage-secret type: Opaque data: - storage_url: $STORAGE_URL storage_type: $STORAGE_TYPE aws_access_key_id: $AWS_ACCESS_KEY_ID aws_access_access_key: $AWS_SECRET_ACCESS_KEY