33import * as k8s from '@pulumi/kubernetes' ;
44import {
55 appsAffinityAndTolerations ,
6+ CloudPostgres ,
67 DOCKER_REPO ,
8+ ExactNamespace ,
79 HELM_MAX_HISTORY_SIZE ,
810 imagePullSecretByNamespaceNameForServiceAccount ,
911 infraAffinityAndTolerations ,
@@ -18,6 +20,7 @@ import yaml from 'js-yaml';
1820
1921import { createCachePvc } from './cache' ;
2022import { ghaConfig } from './config' ;
23+ import { createCloudSQLInstanceForPerformanceTests } from './performanceTests' ;
2124
2225type ResourcesSpec = {
2326 requests ?: {
@@ -403,7 +406,8 @@ function installK8sRunnerScaleSet(
403406 cachePvcName : string ,
404407 resources : ResourcesSpec ,
405408 serviceAccountName : string ,
406- dependsOn : Resource [ ]
409+ dependsOn : Resource [ ] ,
410+ performanceTestsDb : CloudPostgres
407411) : Release {
408412 const podConfigMapName = `${ name } -pod-config` ;
409413 // A configMap that will be mounted to runner pods and provide additional pod spec for the workflow pods
@@ -534,6 +538,21 @@ function installK8sRunnerScaleSet(
534538 name : 'ACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATE' ,
535539 value : '/pod.yaml' ,
536540 } ,
541+ {
542+ name : 'PERFORMANCE_TESTS_DB_HOST' ,
543+ value : performanceTestsDb . address ,
544+ } ,
545+ {
546+ name : 'PERFORMANCE_TESTS_DB_USER' ,
547+ value : 'cnadmin' ,
548+ } ,
549+ {
550+ name : 'PERFORMANCE_TESTS_DB_PASSWORD' ,
551+ valueFrom : {
552+ key : 'postgresPassword' ,
553+ name : performanceTestsDb . secretName ,
554+ } ,
555+ } ,
537556 ] ,
538557 volumeMounts : [
539558 {
@@ -701,9 +720,10 @@ function installK8sRunnerScaleSets(
701720 runnersNamespace : Namespace ,
702721 tokenSecret : Secret ,
703722 cachePvcName : string ,
704- serviceAccountName : string
723+ serviceAccountName : string ,
724+ performanceTestsDb : CloudPostgres
705725) : void {
706- const dependsOn = [ controller , runnersNamespace , tokenSecret ] ;
726+ const dependsOn = [ controller , runnersNamespace , tokenSecret , performanceTestsDb ] ;
707727
708728 runnerSpecs
709729 . filter ( spec => spec . k8s )
@@ -715,7 +735,8 @@ function installK8sRunnerScaleSets(
715735 cachePvcName ,
716736 spec . resources ,
717737 serviceAccountName ,
718- dependsOn
738+ dependsOn ,
739+ performanceTestsDb
719740 ) ;
720741 } ) ;
721742}
@@ -754,12 +775,17 @@ function installPodMonitor(runnersNamespace: Namespace) {
754775 ) ;
755776}
756777
778+ const GHA_NAMESPACE_NAME = 'gha-runners' ;
757779export function installRunnerScaleSets ( controller : k8s . helm . v3 . Release ) : void {
758- const runnersNamespace = new Namespace ( 'gha-runners' , {
780+ const runnersNamespace = new Namespace ( GHA_NAMESPACE_NAME , {
759781 metadata : {
760- name : 'gha-runners' ,
782+ name : GHA_NAMESPACE_NAME ,
761783 } ,
762784 } ) ;
785+ const exactNs : ExactNamespace = {
786+ ns : runnersNamespace ,
787+ logicalName : GHA_NAMESPACE_NAME ,
788+ } ;
763789
764790 const tokenSecret = new k8s . core . v1 . Secret (
765791 'gh-access-token' ,
@@ -791,7 +817,15 @@ export function installRunnerScaleSets(controller: k8s.helm.v3.Release): void {
791817 const saName = 'k8s-runners' ;
792818 installRunnersServiceAccount ( runnersNamespace , saName ) ;
793819
820+ const performanceTestsDb = createCloudSQLInstanceForPerformanceTests ( exactNs ) ;
794821 installDockerRunnerScaleSets ( controller , runnersNamespace , tokenSecret , cachePvc , saName ) ;
795- installK8sRunnerScaleSets ( controller , runnersNamespace , tokenSecret , cachePvcName , saName ) ;
822+ installK8sRunnerScaleSets (
823+ controller ,
824+ runnersNamespace ,
825+ tokenSecret ,
826+ cachePvcName ,
827+ saName ,
828+ performanceTestsDb
829+ ) ;
796830 installPodMonitor ( runnersNamespace ) ;
797831}
0 commit comments