1
- import * as pulumi from '@pulumi/pulumi' ;
2
1
import { serviceLocalEndpoint } from '../utils/local-endpoint' ;
3
2
import { ServiceDeployment } from '../utils/service-deployment' ;
4
3
import { CommerceService } from './commerce' ;
@@ -7,6 +6,8 @@ import { Docker } from './docker';
7
6
import { Environment } from './environment' ;
8
7
import { Kafka } from './kafka' ;
9
8
import { Observability } from './observability' ;
9
+ import { Postgres } from './postgres' ;
10
+ import { Redis } from './redis' ;
10
11
import { Sentry } from './sentry' ;
11
12
import { Tokens } from './tokens' ;
12
13
@@ -15,6 +16,8 @@ export type Usage = ReturnType<typeof deployUsage>;
15
16
export function deployUsage ( {
16
17
environment,
17
18
tokens,
19
+ postgres,
20
+ redis,
18
21
kafka,
19
22
dbMigrations,
20
23
commerce,
@@ -27,6 +30,8 @@ export function deployUsage({
27
30
image : string ;
28
31
environment : Environment ;
29
32
tokens : Tokens ;
33
+ postgres : Postgres ;
34
+ redis : Redis ;
30
35
kafka : Kafka ;
31
36
dbMigrations : DbMigrations ;
32
37
commerce : CommerceService ;
@@ -39,60 +44,78 @@ export function deployUsage({
39
44
const kafkaBufferDynamic =
40
45
kafka . config . bufferDynamic === 'true' || kafka . config . bufferDynamic === '1' ? '1' : '0' ;
41
46
42
- return new ServiceDeployment (
43
- 'usage-service' ,
44
- {
45
- image,
46
- imagePullSecret : docker . secret ,
47
- replicas,
48
- readinessProbe : {
49
- initialDelaySeconds : 10 ,
50
- periodSeconds : 5 ,
51
- failureThreshold : 2 ,
52
- timeoutSeconds : 5 ,
53
- endpoint : '/_readiness' ,
54
- } ,
55
- livenessProbe : '/_health' ,
56
- startupProbe : '/_health' ,
57
- availabilityOnEveryNode : true ,
58
- env : {
59
- ...environment . envVars ,
60
- SENTRY : sentry . enabled ? '1' : '0' ,
61
- REQUEST_LOGGING : '0' ,
62
- KAFKA_BUFFER_SIZE : kafka . config . bufferSize ,
63
- KAFKA_SASL_MECHANISM : kafka . config . saslMechanism ,
64
- KAFKA_CONCURRENCY : kafka . config . concurrency ,
65
- KAFKA_BUFFER_INTERVAL : kafka . config . bufferInterval ,
66
- KAFKA_BUFFER_DYNAMIC : kafkaBufferDynamic ,
67
- KAFKA_TOPIC : kafka . config . topic ,
68
- TOKENS_ENDPOINT : serviceLocalEndpoint ( tokens . service ) ,
69
- COMMERCE_ENDPOINT : serviceLocalEndpoint ( commerce . service ) ,
70
- OPENTELEMETRY_COLLECTOR_ENDPOINT :
71
- observability . enabled &&
72
- observability . enabledForUsageService &&
73
- observability . tracingEndpoint
74
- ? observability . tracingEndpoint
75
- : '' ,
76
- } ,
77
- exposesMetrics : true ,
78
- port : 4000 ,
79
- pdb : true ,
80
- autoScaling : {
81
- cpu : {
82
- cpuAverageToScale : 60 ,
83
- limit : cpuLimit ,
47
+ return (
48
+ new ServiceDeployment (
49
+ 'usage-service' ,
50
+ {
51
+ image,
52
+ imagePullSecret : docker . secret ,
53
+ replicas,
54
+ readinessProbe : {
55
+ initialDelaySeconds : 10 ,
56
+ periodSeconds : 5 ,
57
+ failureThreshold : 2 ,
58
+ timeoutSeconds : 5 ,
59
+ endpoint : '/_readiness' ,
60
+ } ,
61
+ livenessProbe : '/_health' ,
62
+ startupProbe : '/_health' ,
63
+ availabilityOnEveryNode : true ,
64
+ env : {
65
+ ...environment . envVars ,
66
+ SENTRY : sentry . enabled ? '1' : '0' ,
67
+ REQUEST_LOGGING : '0' ,
68
+ KAFKA_BUFFER_SIZE : kafka . config . bufferSize ,
69
+ KAFKA_SASL_MECHANISM : kafka . config . saslMechanism ,
70
+ KAFKA_CONCURRENCY : kafka . config . concurrency ,
71
+ KAFKA_BUFFER_INTERVAL : kafka . config . bufferInterval ,
72
+ KAFKA_BUFFER_DYNAMIC : kafkaBufferDynamic ,
73
+ KAFKA_TOPIC : kafka . config . topic ,
74
+ TOKENS_ENDPOINT : serviceLocalEndpoint ( tokens . service ) ,
75
+ COMMERCE_ENDPOINT : serviceLocalEndpoint ( commerce . service ) ,
76
+ OPENTELEMETRY_COLLECTOR_ENDPOINT :
77
+ observability . enabled &&
78
+ observability . enabledForUsageService &&
79
+ observability . tracingEndpoint
80
+ ? observability . tracingEndpoint
81
+ : '' ,
82
+ } ,
83
+ exposesMetrics : true ,
84
+ port : 4000 ,
85
+ pdb : true ,
86
+ autoScaling : {
87
+ cpu : {
88
+ cpuAverageToScale : 60 ,
89
+ limit : cpuLimit ,
90
+ } ,
91
+ maxReplicas,
84
92
} ,
85
- maxReplicas,
86
93
} ,
87
- } ,
88
- [ dbMigrations , tokens . deployment , tokens . service , commerce . deployment , commerce . service ] . filter (
89
- Boolean ,
90
- ) ,
91
- )
92
- . withSecret ( 'KAFKA_SASL_USERNAME' , kafka . secret , 'saslUsername' )
93
- . withSecret ( 'KAFKA_SASL_PASSWORD' , kafka . secret , 'saslPassword' )
94
- . withSecret ( 'KAFKA_SSL' , kafka . secret , 'ssl' )
95
- . withSecret ( 'KAFKA_BROKER' , kafka . secret , 'endpoint' )
96
- . withConditionalSecret ( sentry . enabled , 'SENTRY_DSN' , sentry . secret , 'dsn' )
97
- . deploy ( ) ;
94
+ [
95
+ dbMigrations ,
96
+ tokens . deployment ,
97
+ tokens . service ,
98
+ commerce . deployment ,
99
+ commerce . service ,
100
+ ] . filter ( Boolean ) ,
101
+ )
102
+ // Redis
103
+ . withSecret ( 'REDIS_HOST' , redis . secret , 'host' )
104
+ . withSecret ( 'REDIS_PORT' , redis . secret , 'port' )
105
+ . withSecret ( 'REDIS_PASSWORD' , redis . secret , 'password' )
106
+ // PG
107
+ . withSecret ( 'POSTGRES_HOST' , postgres . pgBouncerSecret , 'host' )
108
+ . withSecret ( 'POSTGRES_PORT' , postgres . pgBouncerSecret , 'port' )
109
+ . withSecret ( 'POSTGRES_USER' , postgres . pgBouncerSecret , 'user' )
110
+ . withSecret ( 'POSTGRES_PASSWORD' , postgres . pgBouncerSecret , 'password' )
111
+ . withSecret ( 'POSTGRES_DB' , postgres . pgBouncerSecret , 'database' )
112
+ . withSecret ( 'POSTGRES_SSL' , postgres . pgBouncerSecret , 'ssl' )
113
+ // Kafka
114
+ . withSecret ( 'KAFKA_SASL_USERNAME' , kafka . secret , 'saslUsername' )
115
+ . withSecret ( 'KAFKA_SASL_PASSWORD' , kafka . secret , 'saslPassword' )
116
+ . withSecret ( 'KAFKA_SSL' , kafka . secret , 'ssl' )
117
+ . withSecret ( 'KAFKA_BROKER' , kafka . secret , 'endpoint' )
118
+ . withConditionalSecret ( sentry . enabled , 'SENTRY_DSN' , sentry . secret , 'dsn' )
119
+ . deploy ( )
120
+ ) ;
98
121
}
0 commit comments