Skip to content

Commit 36ea1e8

Browse files
committed
Add support for a second remote cluster (cloud bursting)
1 parent afd9975 commit 36ea1e8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

functions/k8sCommand.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ async function k8sCommand(ins, outs, context, cb) {
1111
// let cluster = await getCluster();
1212
// const token = await getGCPToken();
1313

14+
// support for two clusters (cloud bursting)
15+
// if 'HF_VAR_REMOTE_CLUSTER' is defined, we check where this job is assigned to:
16+
// - the local cluster: we do nothing
17+
// - the remote cluster: we set KUBECONFIG to load its configuration
18+
var remoteClusterId = process.env.HF_VAR_REMOTE_CLUSTER;
19+
if (remoteClusterId) {
20+
let partition = context.executor.partition;
21+
if (partition == remoteClusterId) {
22+
// this will read the kube_config of the remote cluster
23+
process.env.KUBECONFIG=process.env.HF_VAR_KUBE_CONFIG_PATH || "./kube_config";
24+
}
25+
}
26+
1427
const kc = new k8s.KubeConfig();
1528
kc.loadFromDefault(); // loadFromString(JSON.stringify(kconfig))
1629

0 commit comments

Comments
 (0)