Skip to content

Commit d3da138

Browse files
authored
feat(server): add runtime affinity settings in region (#1548)
1 parent 2b252f2 commit d3da138

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

server/src/initializer/initializer.service.ts

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class InitializerService {
5555
driver: 'kubernetes',
5656
kubeconfig: null,
5757
npmInstallFlags: '',
58+
runtimeAffinity: {},
5859
},
5960
databaseConf: {
6061
driver: 'mongodb',

server/src/instance/instance.service.ts

+6-24
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import {
66
} from '@kubernetes/client-node'
77
import { Injectable, Logger } from '@nestjs/common'
88
import { GetApplicationNamespace } from 'src/utils/getter'
9-
import {
10-
LABEL_KEY_APP_ID,
11-
LABEL_KEY_NODE_TYPE,
12-
MB,
13-
NodeType,
14-
} from '../constants'
9+
import { LABEL_KEY_APP_ID, MB } from '../constants'
1510
import { StorageService } from '../storage/storage.service'
1611
import { DatabaseService } from 'src/database/database.service'
1712
import { ClusterService } from 'src/region/cluster/cluster.service'
@@ -398,27 +393,14 @@ export class InstanceService {
398393
},
399394
},
400395
],
401-
affinity: {
402-
nodeAffinity: {
403-
// required to schedule on runtime node
404-
requiredDuringSchedulingIgnoredDuringExecution: {
405-
nodeSelectorTerms: [
406-
{
407-
matchExpressions: [
408-
{
409-
key: LABEL_KEY_NODE_TYPE,
410-
operator: 'In',
411-
values: [NodeType.Runtime],
412-
},
413-
],
414-
},
415-
],
416-
},
417-
}, // end of nodeAffinity {}
418-
}, // end of affinity {}
419396
}, // end of spec {}
420397
}, // end of template {}
421398
}
399+
400+
if (region.clusterConf.runtimeAffinity) {
401+
spec.template.spec.affinity = region.clusterConf.runtimeAffinity
402+
}
403+
422404
return spec
423405
}
424406

server/src/region/entities/region.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type RegionClusterConf = {
1616
driver: string
1717
kubeconfig: string
1818
npmInstallFlags: string
19+
runtimeAffinity: any
1920
}
2021

2122
export type RegionDatabaseConf = {

0 commit comments

Comments
 (0)