console/deployment/services/proxy.ts

129 lines
3.4 KiB
TypeScript
Raw Normal View History

2022-05-18 07:26:57 +00:00
import * as pulumi from '@pulumi/pulumi';
import { CertManager } from '../utils/cert-manager';
2022-12-28 19:22:54 +00:00
import { Proxy } from '../utils/reverse-proxy';
2022-05-18 07:26:57 +00:00
import { App } from './app';
2024-03-04 12:56:12 +00:00
import { Environment } from './environment';
2022-12-28 19:22:54 +00:00
import { GraphQL } from './graphql';
2024-04-07 08:57:03 +00:00
import { Observability } from './observability';
import { OTELCollector } from './otel-collector';
import { type PublicGraphQLAPIGateway } from './public-graphql-api-gateway';
2022-12-28 19:22:54 +00:00
import { Usage } from './usage';
2022-05-18 07:26:57 +00:00
export function deployProxy({
graphql,
app,
usage,
2024-03-04 12:56:12 +00:00
environment,
2024-04-07 08:57:03 +00:00
observability,
publicGraphQLAPIGateway,
otelCollector,
2022-05-18 07:26:57 +00:00
}: {
2024-04-07 08:57:03 +00:00
observability: Observability;
2024-03-04 12:56:12 +00:00
environment: Environment;
2022-05-18 07:26:57 +00:00
graphql: GraphQL;
app: App;
usage: Usage;
publicGraphQLAPIGateway: PublicGraphQLAPIGateway;
otelCollector: OTELCollector;
2022-05-18 07:26:57 +00:00
}) {
const { tlsIssueName } = new CertManager().deployCertManagerAndIssuer();
2024-03-04 12:56:12 +00:00
const commonConfig = new pulumi.Config('common');
2022-05-18 07:26:57 +00:00
return new Proxy(tlsIssueName, {
address: commonConfig.get('staticIp'),
aksReservedIpResourceGroup: commonConfig.get('aksReservedIpResourceGroup'),
2022-05-18 07:26:57 +00:00
})
2024-03-26 08:18:00 +00:00
.deployProxy({
envoy: {
replicas: environment.podsConfig.envoy.replicas,
cpu: environment.podsConfig.envoy.cpuLimit,
memory: environment.podsConfig.envoy.memoryLimit,
2024-03-26 08:18:00 +00:00
},
2024-04-07 08:57:03 +00:00
tracing: observability.enabled
? { collectorService: observability.observability!.otlpCollectorService }
: undefined,
2024-03-26 08:18:00 +00:00
})
2024-03-04 12:56:12 +00:00
.registerService({ record: environment.appDns }, [
2022-05-18 07:26:57 +00:00
{
name: 'app',
path: '/',
service: app.service,
requestTimeout: '60s',
2022-05-18 07:26:57 +00:00
},
{
name: 'server',
path: '/server',
service: graphql.service,
requestTimeout: '60s',
2022-05-18 07:26:57 +00:00
},
{
name: 'registry-api-health',
path: '/registry/_health',
customRewrite: '/_health',
service: graphql.service,
},
{
name: 'registry-api',
path: '/registry',
customRewrite: '/graphql',
service: graphql.service,
requestTimeout: '60s',
retriable: true,
2022-05-18 07:26:57 +00:00
},
{
name: 'graphql-api',
path: '/graphql',
customRewrite: '/graphql',
service: graphql.service,
requestTimeout: '60s',
retriable: true,
},
{
name: 'graphql-api-subscriptions',
path: '/graphql/stream',
customRewrite: '/graphql',
service: graphql.service,
requestTimeout: 'infinity',
// we send a ping every 12 seconds
idleTimeout: '30s',
retriable: true,
},
{
name: 'auth',
path: '/auth-api',
customRewrite: '/auth-api',
service: graphql.service,
requestTimeout: '60s',
retriable: true,
rateLimit: {
maxRequests: 10,
unit: 'minute',
},
},
2022-05-18 07:26:57 +00:00
{
name: 'usage',
path: '/usage',
service: usage.service,
retriable: true,
2022-05-18 07:26:57 +00:00
},
])
.registerService({ record: environment.apiDns }, [
{
name: 'public-graphql-api',
path: '/graphql',
customRewrite: '/graphql',
service: publicGraphQLAPIGateway.service,
requestTimeout: '60s',
retriable: true,
},
{
name: 'otel-traces',
path: '/otel/v1/traces',
customRewrite: '/v1/traces',
service: otelCollector.service,
requestTimeout: '60s',
retriable: true,
},
]);
2022-05-18 07:26:57 +00:00
}