2022-12-28 19:22:54 +00:00
|
|
|
import * as k8s from '@pulumi/kubernetes';
|
2022-05-18 07:26:57 +00:00
|
|
|
import * as pulumi from '@pulumi/pulumi';
|
|
|
|
|
import { DeploymentEnvironment } from '../types';
|
2022-12-28 19:22:54 +00:00
|
|
|
import { ServiceDeployment } from '../utils/service-deployment';
|
2022-05-18 07:26:57 +00:00
|
|
|
import { Clickhouse } from './clickhouse';
|
|
|
|
|
import { DbMigrations } from './db-migrations';
|
|
|
|
|
|
|
|
|
|
const commonConfig = new pulumi.Config('common');
|
|
|
|
|
const commonEnv = commonConfig.requireObject<Record<string, string>>('env');
|
|
|
|
|
|
|
|
|
|
export type UsageEstimator = ReturnType<typeof deployUsageEstimation>;
|
|
|
|
|
|
|
|
|
|
export function deployUsageEstimation({
|
2022-12-20 14:34:46 +00:00
|
|
|
image,
|
|
|
|
|
imagePullSecret,
|
|
|
|
|
release,
|
2022-05-18 07:26:57 +00:00
|
|
|
deploymentEnv,
|
|
|
|
|
clickhouse,
|
|
|
|
|
dbMigrations,
|
|
|
|
|
}: {
|
2022-12-20 14:34:46 +00:00
|
|
|
image: string;
|
|
|
|
|
imagePullSecret: k8s.core.v1.Secret;
|
|
|
|
|
release: string;
|
2022-05-18 07:26:57 +00:00
|
|
|
deploymentEnv: DeploymentEnvironment;
|
|
|
|
|
clickhouse: Clickhouse;
|
|
|
|
|
dbMigrations: DbMigrations;
|
|
|
|
|
}) {
|
2022-12-20 14:34:46 +00:00
|
|
|
return new ServiceDeployment(
|
2022-05-18 07:26:57 +00:00
|
|
|
'usage-estimator',
|
|
|
|
|
{
|
2022-12-20 14:34:46 +00:00
|
|
|
image,
|
|
|
|
|
imagePullSecret,
|
2022-05-18 07:26:57 +00:00
|
|
|
replicas: 1,
|
|
|
|
|
readinessProbe: '/_readiness',
|
|
|
|
|
livenessProbe: '/_health',
|
|
|
|
|
env: {
|
|
|
|
|
...deploymentEnv,
|
|
|
|
|
...commonEnv,
|
2022-10-04 12:30:21 +00:00
|
|
|
SENTRY: commonEnv.SENTRY_ENABLED,
|
2022-05-18 07:26:57 +00:00
|
|
|
CLICKHOUSE_PROTOCOL: clickhouse.config.protocol,
|
|
|
|
|
CLICKHOUSE_HOST: clickhouse.config.host,
|
|
|
|
|
CLICKHOUSE_PORT: clickhouse.config.port,
|
|
|
|
|
CLICKHOUSE_USERNAME: clickhouse.config.username,
|
|
|
|
|
CLICKHOUSE_PASSWORD: clickhouse.config.password,
|
2022-12-20 14:34:46 +00:00
|
|
|
RELEASE: release,
|
2022-05-18 07:26:57 +00:00
|
|
|
},
|
|
|
|
|
exposesMetrics: true,
|
|
|
|
|
port: 4000,
|
|
|
|
|
},
|
2022-11-24 10:00:41 +00:00
|
|
|
[dbMigrations],
|
2022-05-18 07:26:57 +00:00
|
|
|
).deploy();
|
|
|
|
|
}
|