11import * as k8s from '@pulumi/kubernetes' ;
22import * as kx from '@pulumi/kubernetesx' ;
33import { Output } from '@pulumi/pulumi' ;
4+ import { memoryParser } from './k8s' ;
45import { getLocalComposeConfig } from './local-config' ;
56import { normalizeEnv , PodBuilder } from './pod-builder' ;
67
@@ -16,9 +17,13 @@ export class Redis {
1617 } ,
1718 ) { }
1819
19- deploy ( { limits } : { limits : k8s . types . input . core . v1 . ResourceRequirements [ 'limits' ] } ) {
20+ deploy ( input : { limits : { memory : string ; cpu : string } } ) {
2021 const redisService = getLocalComposeConfig ( ) . service ( 'redis' ) ;
2122 const name = 'redis-store' ;
23+ const limits : k8s . types . input . core . v1 . ResourceRequirements [ 'limits' ] = {
24+ memory : input . limits . memory ,
25+ cpu : input . limits . cpu ,
26+ } ;
2227
2328 const env : k8s . types . input . core . v1 . EnvVar [ ] = normalizeEnv ( this . options . env ?? { } ) . concat ( [
2429 {
@@ -76,6 +81,9 @@ export class Redis {
7681 } ,
7782 ] ;
7883
84+ const memoryInBytes = memoryParser ( input . limits . memory ) * 0.8 ; // Redis recommends 80%
85+ const memoryInMegabytes = Math . floor ( memoryInBytes / 1024 / 1024 ) ;
86+
7987 const pb = new PodBuilder ( {
8088 restartPolicy : 'Always' ,
8189 containers : [
@@ -97,6 +105,10 @@ export class Redis {
97105 command : [ '/bin/sh' , '/scripts/liveness.sh' ] ,
98106 } ,
99107 } ,
108+ // Note: this is needed, otherwise local config is not loaded at all
109+ command : [ '/opt/bitnami/scripts/redis/entrypoint.sh' ] ,
110+ // This is where we can pass actual flags to the bitnami/redis runtime
111+ args : [ '/opt/bitnami/scripts/redis/run.sh' , `--maxmemory ${ memoryInMegabytes } mb` ] ,
100112 readinessProbe : {
101113 initialDelaySeconds : 5 ,
102114 periodSeconds : 8 ,
0 commit comments