diff --git a/apps/config/mongo-api-secrets.yaml b/apps/config/mongo-api-secrets.yaml new file mode 100644 index 0000000..46d792d --- /dev/null +++ b/apps/config/mongo-api-secrets.yaml @@ -0,0 +1,34 @@ +apiVersion: secrets.infisical.com/v1alpha1 +kind: InfisicalSecret + +metadata: + name: acta-mongo-api-secrets + +spec: + hostAPI: https://app.infisical.com/api + resyncInterval: 60 + + authentication: + universalAuth: + credentialsRef: + secretName: infisical-universal-auth + secretNamespace: acta-prod + secretsScope: + projectId: 051dcf5e-00ed-4d46-8b36-baad0a621f5d + envSlug: prod + secretsPath: /mongo-api + recursive: false + + managedKubeSecretReferences: + - secretName: acta-mongo-api-env + secretNamespace: acta-prod + creationPolicy: Owner + + template: + includeAllSecrets: false + data: + PORT: "{{ .PORT.Value }}" + MONGODB_URI: "{{ .MONGODB_URI.Value }}" + ACTA_PG_API_BASE_URL: "{{ .ACTA_PG_API_BASE_URL.Value }}" + ACTA_PG_API_CONNECT_TIMEOUT: "{{ .ACTA_PG_API_CONNECT_TIMEOUT.Value }}" + ACTA_PG_API_READ_TIMEOUT: "{{ .ACTA_PG_API_READ_TIMEOUT.Value }}" \ No newline at end of file diff --git a/apps/kustomization.yaml b/apps/kustomization.yaml index 18309af..ca75c5b 100644 --- a/apps/kustomization.yaml +++ b/apps/kustomization.yaml @@ -5,4 +5,6 @@ namespace: acta-prod resources: - pg-api.yaml - - config/pg-api-secrets.yaml \ No newline at end of file + - mongo-api.yaml + - config/pg-api-secrets.yaml + - config/mongo-api-secrets.yaml diff --git a/apps/mongo-api.yaml b/apps/mongo-api.yaml new file mode 100644 index 0000000..b8df10b --- /dev/null +++ b/apps/mongo-api.yaml @@ -0,0 +1,91 @@ +apiVersion: apps/v1 +kind: Deployment + +metadata: + name: acta-mongo-api + annotations: + # reinicia os pods quando o infisical atualizar os secrets + secrets.infisical.com/auto-reload: "true" + labels: + app.kubernetes.io/name: acta-mongo-api + app.kubernetes.io/part-of: acta + +spec: + replicas: 1 + revisionHistoryLimit: 1 + + selector: + matchLabels: + app.kubernetes.io/name: acta-mongo-api + + template: + metadata: + labels: + app.kubernetes.io/name: acta-mongo-api + app.kubernetes.io/part-of: acta + + spec: + containers: + - name: acta-mongo-api + image: ghcr.io/appacta/acta-mongo-api:sha-695a7ddd23c317234cc0c3d447ecfdcb5504b3eb + imagePullPolicy: IfNotPresent + + ports: + - name: http + containerPort: 8081 + protocol: TCP + + envFrom: + - secretRef: + name: acta-mongo-api-env + + startupProbe: + tcpSocket: + port: http + periodSeconds: 10 + failureThreshold: 60 + + readinessProbe: + httpGet: + path: /api/v1/health + port: http + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 3 + + # verifica se o processo continua aceitando conexoes na porta + livenessProbe: + tcpSocket: + port: http + periodSeconds: 20 + timeoutSeconds: 5 + failureThreshold: 3 + + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + cpu: 500m + memory: 512Mi +--- +apiVersion: v1 +kind: Service + +metadata: + name: acta-mongo-api + labels: + app.kubernetes.io/name: acta-mongo-api + app.kubernetes.io/part-of: acta + +spec: + type: ClusterIP + + selector: + app.kubernetes.io/name: acta-mongo-api + + ports: + - name: http + port: 8081 + targetPort: http + protocol: TCP \ No newline at end of file diff --git a/apps/pg-api.yaml b/apps/pg-api.yaml index b256cfb..e323f44 100644 --- a/apps/pg-api.yaml +++ b/apps/pg-api.yaml @@ -106,4 +106,4 @@ spec: - name: http port: 8080 targetPort: http - protocol: TCP + protocol: TCP \ No newline at end of file