Skip to content

Commit

Permalink
fix(server): add storage service conf for runtime, add cors conf for …
Browse files Browse the repository at this point in the history
…bucket ingress
  • Loading branch information
maslow committed Oct 8, 2023
1 parent 6a9b546 commit fc73e6f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions server/src/gateway/ingress/bucket-ingress.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,22 @@ export class BucketGatewayService {
'laf.dev/ingress.type': 'bucket',
// apisix ingress annotations
'k8s.apisix.apache.org/enable-cors': 'true',
'k8s.apisix.apache.org/cors-allow-credential': 'false',
'k8s.apisix.apache.org/cors-allow-headers': '*',
'k8s.apisix.apache.org/cors-allow-methods': '*',
'k8s.apisix.apache.org/cors-allow-origin': '*',
'k8s.apisix.apache.org/cors-expose-headers': '*',
'k8s.apisix.apache.org/svc-namespace': namespace,

// k8s nginx ingress annotations
// websocket is enabled by default in k8s nginx ingress
'nginx.ingress.kubernetes.io/enable-cors': 'true',
'nginx.ingress.kubernetes.io/cors-allow-credentials': 'true',
'nginx.ingress.kubernetes.io/cors-allow-methods': '*',
'nginx.ingress.kubernetes.io/cors-allow-headers':
'DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,x-laf-develop-token,x-laf-func-data,x-amz-content-sha256,x-amz-security-token,x-amz-user-agent,x-amz-date',
'nginx.ingress.kubernetes.io/cors-expose-headers': '*',
'nginx.ingress.kubernetes.io/cors-allow-origin': '*',
},
},
spec: { ingressClassName, rules: [minioRule, bucketRule] },
Expand Down
2 changes: 1 addition & 1 deletion server/src/gateway/ingress/runtime-ingress.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class RuntimeGatewayService {
// k8s nginx ingress annotations
// websocket is enabled by default in k8s nginx ingress
'nginx.ingress.kubernetes.io/enable-cors': 'true',
'nginx.ingress.kubernetes.io/cors-allow-credentials': 'true',
'nginx.ingress.kubernetes.io/cors-allow-credentials': 'false',
'nginx.ingress.kubernetes.io/cors-allow-methods': '*',
'nginx.ingress.kubernetes.io/cors-allow-headers':
'DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,x-laf-develop-token,x-laf-func-data',
Expand Down
10 changes: 8 additions & 2 deletions server/src/instance/instance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ export class InstanceService {
spec: {
selector: labels,
type: 'ClusterIP',
ports: [{ port: 8000, targetPort: 8000, protocol: 'TCP' }],
ports: [
{ port: 8000, targetPort: 8000, protocol: 'TCP', name: 'http' },
{ port: 9000, targetPort: 9000, protocol: 'TCP', name: 'storage' },
],
},
})
this.logger.log(`create k8s service ${res.body?.metadata?.name}`)
Expand Down Expand Up @@ -305,7 +308,10 @@ export class InstanceService {
command: ['sh', '/app/start.sh'],
name: appid,
env,
ports: [{ containerPort: 8000, name: 'http' }],
ports: [
{ containerPort: 8000, name: 'http' },
{ containerPort: 9000, name: 'storage' },
],
resources: {
limits: {
cpu: `${limitCpu}m`,
Expand Down

0 comments on commit fc73e6f

Please sign in to comment.