From f619d79b7f003380fe4aea49493e5359d3bfb892 Mon Sep 17 00:00:00 2001 From: Alexander Berger Date: Tue, 3 Sep 2024 12:16:51 -0400 Subject: [PATCH 1/2] Adding cors config to ingress definitions --- deploy/k8s/overlays/jax-cluster-dev-10--dev/ingress.yaml | 9 +++++++++ deploy/k8s/overlays/jax-cluster-dev-10--sqa/ingress.yaml | 9 +++++++++ .../k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml | 5 +++++ .../k8s/overlays/jax-cluster-prod-10--stage/ingress.yaml | 9 +++++++++ pyproject.toml | 2 +- 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/deploy/k8s/overlays/jax-cluster-dev-10--dev/ingress.yaml b/deploy/k8s/overlays/jax-cluster-dev-10--dev/ingress.yaml index 920b443..30908a6 100644 --- a/deploy/k8s/overlays/jax-cluster-dev-10--dev/ingress.yaml +++ b/deploy/k8s/overlays/jax-cluster-dev-10--dev/ingress.yaml @@ -9,6 +9,15 @@ metadata: cert-manager.io/cluster-issuer: "letsencrypt-prod" nginx.ingress.kubernetes.io/auth-url: "http://oauth2-proxy.oauth2-proxy.svc.cluster.local/oauth2/auth" nginx.ingress.kubernetes.io/auth-signin: "https://auth.jax-cluster-dev-10.jax.org/oauth2/start?rd=https://$http_host$escaped_request_uri" + nginx.ingress.kubernetes.io/cors-allow-credentials: "true" + nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" + nginx.ingress.kubernetes.io/cors-allow-methods: "DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT" + nginx.ingress.kubernetes.io/cors-allow-origin: "https://*.jax.org, http://localhost:4200, http://localhost:8080" + nginx.ingress.kubernetes.io/enable-cors: "true" + nginx.ingress.kubernetes.io/auth-snippet: | + if ($request_method = "OPTIONS") { + return 202; + } spec: ingressClassName: nginx tls: diff --git a/deploy/k8s/overlays/jax-cluster-dev-10--sqa/ingress.yaml b/deploy/k8s/overlays/jax-cluster-dev-10--sqa/ingress.yaml index 03a712e..0c54698 100644 --- a/deploy/k8s/overlays/jax-cluster-dev-10--sqa/ingress.yaml +++ b/deploy/k8s/overlays/jax-cluster-dev-10--sqa/ingress.yaml @@ -9,6 +9,15 @@ metadata: cert-manager.io/cluster-issuer: "letsencrypt-prod" nginx.ingress.kubernetes.io/auth-url: "http://oauth2-proxy.oauth2-proxy.svc.cluster.local/oauth2/auth" nginx.ingress.kubernetes.io/auth-signin: "https://auth.jax-cluster-dev-10.jax.org/oauth2/start?rd=https://$http_host$escaped_request_uri" + nginx.ingress.kubernetes.io/enable-cors: "true" + nginx.ingress.kubernetes.io/cors-allow-credentials: "true" + nginx.ingress.kubernetes.io/cors-allow-methods: "DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT" + nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" + nginx.ingress.kubernetes.io/cors-allow-origin: "https://*.jax.org" + nginx.ingress.kubernetes.io/auth-snippet: | + if ($request_method = "OPTIONS") { + return 202; + } spec: ingressClassName: nginx tls: diff --git a/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml b/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml index b73be1f..020f692 100644 --- a/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml +++ b/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml @@ -7,6 +7,11 @@ metadata: # so that you don't hit the rate limit for the production issuer. # cert-manager.io/cluster-issuer: "letsencrypt-staging" cert-manager.io/cluster-issuer: "letsencrypt-prod" + nginx.ingress.kubernetes.io/enable-cors: "true" + nginx.ingress.kubernetes.io/cors-allow-credentials: "true" + nginx.ingress.kubernetes.io/cors-allow-methods: "DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT" + nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" + nginx.ingress.kubernetes.io/cors-allow-origin: "https://*.jax.org" spec: ingressClassName: nginx tls: diff --git a/deploy/k8s/overlays/jax-cluster-prod-10--stage/ingress.yaml b/deploy/k8s/overlays/jax-cluster-prod-10--stage/ingress.yaml index 9c28f33..932b8cc 100644 --- a/deploy/k8s/overlays/jax-cluster-prod-10--stage/ingress.yaml +++ b/deploy/k8s/overlays/jax-cluster-prod-10--stage/ingress.yaml @@ -9,6 +9,15 @@ metadata: cert-manager.io/cluster-issuer: "letsencrypt-prod" nginx.ingress.kubernetes.io/auth-url: "http://oauth2-proxy.oauth2-proxy.svc.cluster.local/oauth2/auth" nginx.ingress.kubernetes.io/auth-signin: "https://auth.jax-cluster-prod-10.jax.org/oauth2/start?rd=https://$http_host$escaped_request_uri" + nginx.ingress.kubernetes.io/enable-cors: "true" + nginx.ingress.kubernetes.io/cors-allow-credentials: "true" + nginx.ingress.kubernetes.io/cors-allow-methods: "DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT" + nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" + nginx.ingress.kubernetes.io/cors-allow-origin: "https://*.jax.org" + nginx.ingress.kubernetes.io/auth-snippet: | + if ($request_method = "OPTIONS") { + return 202; + } spec: ingressClassName: nginx tls: diff --git a/pyproject.toml b/pyproject.toml index a4bdd1f..88c328b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "geneweaver-api" -version = "0.8.0" +version = "0.8.1a0" description = "The Geneweaver API" authors = [ "Alexander Berger ", From fe18b65b4bf7f8ff9da09cf6091df8660d251436 Mon Sep 17 00:00:00 2001 From: Alexander Berger Date: Tue, 3 Sep 2024 13:31:34 -0400 Subject: [PATCH 2/2] Fix some ingress routes pointing to wrong service --- deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml b/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml index 020f692..68af2c4 100644 --- a/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml +++ b/deploy/k8s/overlays/jax-cluster-prod-10--prod/ingress.yaml @@ -30,7 +30,7 @@ spec: path: "/api" backend: service: - name: geneweaver-legacy + name: geneweaver-api port: number: 8000 - host: "geneweaver.jax.org" @@ -60,7 +60,7 @@ spec: path: "/api" backend: service: - name: geneweaver-legacy + name: geneweaver-api port: number: 8000 - host: "classic.geneweaver.org" @@ -70,6 +70,6 @@ spec: path: "/api" backend: service: - name: geneweaver-legacy + name: geneweaver-api port: number: 800 \ No newline at end of file