akash-network / support

Akash Support and Issue Tracking
Apache License 2.0
5 stars 4 forks source link

provider to support CORS headers #http_options #89

Open andy108369 opened 1 year ago

andy108369 commented 1 year ago

provider needs to support CORS headers as currently the only way by annotating the deployment's ingress resource the following way:

ns=$(provider-services show-cluster-ns --dseq $AKASH_DSEQ --provider $AKASH_PROVIDER)
kubectl -n $ns annotate ing/console-proxy.akash.network \
  nginx.ingress.kubernetes.io/cors-allow-origin="https://console.akash.network" \
  nginx.ingress.kubernetes.io/enable-cors="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,upstream" \
  --overwrite

YAML:

$ kubectl -n $ns get ing console-proxy.akash.network  -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/cors-allow-headers: DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,upstream
    nginx.ingress.kubernetes.io/cors-allow-origin: https://console.akash.network
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "1048576"
    nginx.ingress.kubernetes.io/proxy-next-upstream: error timeout
    nginx.ingress.kubernetes.io/proxy-next-upstream-timeout: "0"
    nginx.ingress.kubernetes.io/proxy-next-upstream-tries: "3"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "60"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "60"
  creationTimestamp: "2023-02-27T22:27:30Z"
...

Refs https://docs.akash.network/features/deployment-http-options

Additionally, we also have to let the console-proxy access the provider it is deployed at

kubectl -n $ns patch netpol akash-deployment-restrictions --type=json -p='[{"op": "add", "path": "/spec/egress/-", "value":{"to":[{"namespaceSelector":{"matchLabels":{"kubernetes.io/metadata.name":"ingress-nginx"}},"podSelector":{}}]}}]'

there is a separate issue with the explanation of that https://github.com/akash-network/support/issues/1#issuecomment-1447428051