From 8a0954d58e8a0ea6873cd916aa4b7474747d8ea7 Mon Sep 17 00:00:00 2001 From: fmo00 Date: Mon, 29 Jul 2024 22:00:54 -0300 Subject: [PATCH 1/2] added payment-webhook service and deployment --- k8s/api-deployment.yaml | 50 +++++++++++++++++++ k8s/api-service.yaml | 25 ++++++++++ .../infra/k8s => k8s}/db-deployment.yaml | 0 {snack-bar-api/infra/k8s => k8s}/db-pv.yaml | 0 {snack-bar-api/infra/k8s => k8s}/db-pvc.yaml | 0 .../infra/k8s => k8s}/db-service.yaml | 0 {snack-bar-api/infra/k8s => k8s}/hpa.yaml | 0 {snack-bar-api/infra/k8s => k8s}/metrics.yaml | 0 .../infra/k8s => k8s}/migration-job.yaml | 0 .../infra/k8s => k8s}/namespace.yaml | 0 snack-bar-api/infra/k8s/api-deployment.yaml | 26 ---------- snack-bar-api/infra/k8s/api-service.yaml | 12 ----- 12 files changed, 75 insertions(+), 38 deletions(-) create mode 100644 k8s/api-deployment.yaml create mode 100644 k8s/api-service.yaml rename {snack-bar-api/infra/k8s => k8s}/db-deployment.yaml (100%) rename {snack-bar-api/infra/k8s => k8s}/db-pv.yaml (100%) rename {snack-bar-api/infra/k8s => k8s}/db-pvc.yaml (100%) rename {snack-bar-api/infra/k8s => k8s}/db-service.yaml (100%) rename {snack-bar-api/infra/k8s => k8s}/hpa.yaml (100%) rename {snack-bar-api/infra/k8s => k8s}/metrics.yaml (100%) rename {snack-bar-api/infra/k8s => k8s}/migration-job.yaml (100%) rename {snack-bar-api/infra/k8s => k8s}/namespace.yaml (100%) delete mode 100644 snack-bar-api/infra/k8s/api-deployment.yaml delete mode 100644 snack-bar-api/infra/k8s/api-service.yaml diff --git a/k8s/api-deployment.yaml b/k8s/api-deployment.yaml new file mode 100644 index 0000000..586fee0 --- /dev/null +++ b/k8s/api-deployment.yaml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: snack-bar-api + namespace: snack-bar +spec: + replicas: 1 + selector: + matchLabels: + app: snack-bar-api + template: + metadata: + labels: + app: snack-bar-api + spec: + containers: + - name: snack-bar-api + image: deborasilveira/snack-bar-api:latest + ports: + - containerPort: 3000 + env: + - name: DATABASE_URL + value: 'postgresql://root:root@snack-bar-db:5432/snack-api-db' + resources: + requests: + cpu: 100m +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: payment-webhook-api + namespace: snack-bar +spec: + replicas: 1 + selector: + matchLabels: + app: payment-webhook-api + template: + metadata: + labels: + app: payment-webhook-api + spec: + containers: + - name: payment-webhook-api + image: fmo00/payment-webhook-api:latest + ports: + - containerPort: 3001 + resources: + requests: + cpu: 100m diff --git a/k8s/api-service.yaml b/k8s/api-service.yaml new file mode 100644 index 0000000..60f5bfd --- /dev/null +++ b/k8s/api-service.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +kind: Service +metadata: + name: snack-bar-api + namespace: snack-bar +spec: + selector: + app: snack-bar-api + ports: + - port: 3000 + targetPort: 3000 + type: LoadBalancer +--- +apiVersion: v1 +kind: Service +metadata: + name: payment-webhook-api + namespace: snack-bar +spec: + selector: + app: payment-webhook-api + ports: + - port: 3001 + targetPort: 3001 + type: NodePort diff --git a/snack-bar-api/infra/k8s/db-deployment.yaml b/k8s/db-deployment.yaml similarity index 100% rename from snack-bar-api/infra/k8s/db-deployment.yaml rename to k8s/db-deployment.yaml diff --git a/snack-bar-api/infra/k8s/db-pv.yaml b/k8s/db-pv.yaml similarity index 100% rename from snack-bar-api/infra/k8s/db-pv.yaml rename to k8s/db-pv.yaml diff --git a/snack-bar-api/infra/k8s/db-pvc.yaml b/k8s/db-pvc.yaml similarity index 100% rename from snack-bar-api/infra/k8s/db-pvc.yaml rename to k8s/db-pvc.yaml diff --git a/snack-bar-api/infra/k8s/db-service.yaml b/k8s/db-service.yaml similarity index 100% rename from snack-bar-api/infra/k8s/db-service.yaml rename to k8s/db-service.yaml diff --git a/snack-bar-api/infra/k8s/hpa.yaml b/k8s/hpa.yaml similarity index 100% rename from snack-bar-api/infra/k8s/hpa.yaml rename to k8s/hpa.yaml diff --git a/snack-bar-api/infra/k8s/metrics.yaml b/k8s/metrics.yaml similarity index 100% rename from snack-bar-api/infra/k8s/metrics.yaml rename to k8s/metrics.yaml diff --git a/snack-bar-api/infra/k8s/migration-job.yaml b/k8s/migration-job.yaml similarity index 100% rename from snack-bar-api/infra/k8s/migration-job.yaml rename to k8s/migration-job.yaml diff --git a/snack-bar-api/infra/k8s/namespace.yaml b/k8s/namespace.yaml similarity index 100% rename from snack-bar-api/infra/k8s/namespace.yaml rename to k8s/namespace.yaml diff --git a/snack-bar-api/infra/k8s/api-deployment.yaml b/snack-bar-api/infra/k8s/api-deployment.yaml deleted file mode 100644 index b119c91..0000000 --- a/snack-bar-api/infra/k8s/api-deployment.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: snack-bar-api - namespace: snack-bar -spec: - replicas: 1 - selector: - matchLabels: - app: snack-bar-api - template: - metadata: - labels: - app: snack-bar-api - spec: - containers: - - name: snack-bar-api - image: deborasilveira/snack-bar-api:latest - ports: - - containerPort: 3000 - env: - - name: DATABASE_URL - value: "postgresql://root:root@snack-bar-db:5432/snack-api-db" - resources: - requests: - cpu: 100m diff --git a/snack-bar-api/infra/k8s/api-service.yaml b/snack-bar-api/infra/k8s/api-service.yaml deleted file mode 100644 index 6cdc311..0000000 --- a/snack-bar-api/infra/k8s/api-service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: snack-bar-api - namespace: snack-bar -spec: - selector: - app: snack-bar-api - ports: - - port: 3000 - targetPort: 3000 - type: LoadBalancer From a767a9ef80db81323f505a49d372b87d7d40b243 Mon Sep 17 00:00:00 2001 From: ds2 Date: Tue, 30 Jul 2024 20:53:17 -0300 Subject: [PATCH 2/2] (refactor): update k8s --- k8s/api-deployment.yaml | 7 ++++++- k8s/api-service.yaml | 2 +- payment-webhook | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/k8s/api-deployment.yaml b/k8s/api-deployment.yaml index 586fee0..3d9b7c3 100644 --- a/k8s/api-deployment.yaml +++ b/k8s/api-deployment.yaml @@ -42,9 +42,14 @@ spec: spec: containers: - name: payment-webhook-api - image: fmo00/payment-webhook-api:latest + image: deborasilveira/payment-webhook-api:latest ports: - containerPort: 3001 + env: + - name: MERCADO_PAGO_ACCESS_TOKEN + value: 'TEST-7418278903320835-072411-cef84b2f32a8952e205f8f50e3e20d15-391569826' + - name: MERCADO_PAGO_API_URL + value: 'https://api.mercadopago.com/v1' resources: requests: cpu: 100m diff --git a/k8s/api-service.yaml b/k8s/api-service.yaml index 60f5bfd..760f5c1 100644 --- a/k8s/api-service.yaml +++ b/k8s/api-service.yaml @@ -22,4 +22,4 @@ spec: ports: - port: 3001 targetPort: 3001 - type: NodePort + type: LoadBalancer diff --git a/payment-webhook b/payment-webhook index cd72877..71f2837 160000 --- a/payment-webhook +++ b/payment-webhook @@ -1 +1 @@ -Subproject commit cd72877ba5b06f3b9b067f5e4a690b8538b5493d +Subproject commit 71f2837d3a96fb96c5f7c34947f8aef72e4588b8