Fixes Storage Service Integration

This commit is contained in:
2023-08-23 18:48:11 -03:00
parent e4b637e07e
commit 338e33401a
7 changed files with 27 additions and 43 deletions

View File

@@ -23,6 +23,13 @@ function application_deploy() {
kubectl apply -f ./deployment/portfolio-namespace.yaml; 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 \ kubectl apply -f \
./deployment/cert-manager/cert-manager-certificate.yaml; ./deployment/cert-manager/cert-manager-certificate.yaml;

View File

@@ -16,7 +16,7 @@ spec:
containers: containers:
- name: backend - name: backend
image: yoshiunfriendly/backend-hideyoshi.com image: yoshiunfriendly/backend-hideyoshi.com
imagePullPolicy: "Always" imagePullPolicy: Always
ports: ports:
- containerPort: 8070 - containerPort: 8070
env: env:
@@ -155,12 +155,21 @@ spec:
name: redis-secret name: redis-secret
key: redis-password key: redis-password
- name: STORAGE_SERVICE_PATH - name: STORAGE_SERVICE_URL
valueFrom: valueFrom:
secretKeyRef: configMapKeyRef:
name: storage-secret name: storage-config
key: storage_url 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 apiVersion: v1
kind: Service kind: Service

View File

@@ -5,7 +5,6 @@ from pathlib import Path, PosixPath
import argparse import argparse
import os import os
ENV_VARIABLES = [ ENV_VARIABLES = [
"FRONTEND_PATH", "FRONTEND_PATH",
"BACKEND_URL", "BACKEND_URL",
@@ -35,7 +34,6 @@ ENV_VARIABLES = [
"AWS_BUCKET_NAME", "AWS_BUCKET_NAME",
] ]
FORCE_BASE64_FIELD = [ FORCE_BASE64_FIELD = [
"OAUTH_GITHUB_CLIENT_ID", "OAUTH_GITHUB_CLIENT_ID",
"OAUTH_GITHUB_CLIENT_SECRET", "OAUTH_GITHUB_CLIENT_SECRET",
@@ -67,17 +65,14 @@ def setting_environment(environment: str):
match environment: match environment:
case "staging": case "staging":
DOMAIN="staging.hideyoshi.com.br" DOMAIN = "staging.hideyoshi.com.br"
API_DOMAIN="api.staging.hideyoshi.com.br" API_DOMAIN = "api.staging.hideyoshi.com.br"
STORAGE_API_DOMAIN="storage.staging.hideyoshi.com.br"
case _: case _:
DOMAIN="hideyoshi.com.br" DOMAIN = "hideyoshi.com.br"
API_DOMAIN="api.hideyoshi.com.br" API_DOMAIN = "api.hideyoshi.com.br"
STORAGE_API_DOMAIN="storage.hideyoshi.com.br"
os.environ["DOMAIN"] = DOMAIN os.environ["DOMAIN"] = DOMAIN
os.environ["API_DOMAIN"] = API_DOMAIN os.environ["API_DOMAIN"] = API_DOMAIN
os.environ["STORAGE_API_DOMAIN"] = STORAGE_API_DOMAIN
def load_secret_file(file: str): def load_secret_file(file: str):
@@ -102,8 +97,8 @@ def envsubst_file(file: PosixPath):
with open(file) as f: with open(file) as f:
formated_file = envsubst(f.read()) formated_file = envsubst(f.read())
new_file = Path("deployment")\ new_file = Path("deployment") \
.joinpath(*[part.split('.')[0] for part in file.parts if part != "template"])\ .joinpath(*[part.split('.')[0] for part in file.parts if part != "template"]) \
.with_suffix(".yaml") .with_suffix(".yaml")
with open(new_file, 'w') as f: with open(new_file, 'w') as f:
@@ -143,4 +138,4 @@ if __name__ == "__main__":
args = parser.parse_args() args = parser.parse_args()
main(**vars(args)) main(**vars(args))

View File

@@ -7,7 +7,6 @@ spec:
dnsNames: dnsNames:
- ${DOMAIN} - ${DOMAIN}
- ${API_DOMAIN} - ${API_DOMAIN}
- ${STORAGE_API_DOMAIN}
secretName: letsencrypt-cluster-certificate-tls secretName: letsencrypt-cluster-certificate-tls
issuerRef: issuerRef:
name: cluster-certificate-issuer name: cluster-certificate-issuer

View File

@@ -16,13 +16,6 @@ spec:
- host: ${DOMAIN} - host: ${DOMAIN}
http: http:
paths: paths:
- path: /api/storage
pathType: Prefix
backend:
service:
name: storage-service
port:
number: 8000
- path: /api(/|$)(.*) - path: /api(/|$)(.*)
pathType: Prefix pathType: Prefix
backend: backend:
@@ -32,13 +25,6 @@ spec:
number: 8070 number: 8070
- http: - http:
paths: paths:
- path: /api/storage
pathType: Prefix
backend:
service:
name: storage-service
port:
number: 8000
- path: /api(/|$)(.*) - path: /api(/|$)(.*)
pathType: Prefix pathType: Prefix
backend: backend:

View File

@@ -12,7 +12,6 @@ spec:
- hosts: - hosts:
- ${DOMAIN} - ${DOMAIN}
- ${API_DOMAIN} - ${API_DOMAIN}
- ${STORAGE_API_DOMAIN}
secretName: letsencrypt-cluster-certificate-tls secretName: letsencrypt-cluster-certificate-tls
rules: rules:
- host: ${DOMAIN} - host: ${DOMAIN}
@@ -35,16 +34,6 @@ spec:
name: backend-service name: backend-service
port: port:
number: 8070 number: 8070
- host: ${STORAGE_API_DOMAIN}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: storage-service
port:
number: 8000
- http: - http:
paths: paths:
- path: / - path: /

View File

@@ -5,7 +5,6 @@ metadata:
name: storage-secret name: storage-secret
type: Opaque type: Opaque
data: data:
storage_url: $STORAGE_URL
storage_type: $STORAGE_TYPE storage_type: $STORAGE_TYPE
aws_access_key_id: $AWS_ACCESS_KEY_ID aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_access_access_key: $AWS_SECRET_ACCESS_KEY aws_access_access_key: $AWS_SECRET_ACCESS_KEY