Created
January 7, 2023 22:05
-
-
Save PatrickKalkman/e68a7ae5e8dd8e9b4252afbfa8e042ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import k8s from '@kubernetes/client-node'; | |
import log from './log.js'; | |
const kubernetesClient = {}; | |
kubernetesClient.setNumberOfEncoders = async (numberOfEncoders) => { | |
try { | |
const kubeconfig = new k8s.KubeConfig(); | |
if (process.env.NODE_ENV === 'production') { | |
kubeconfig.loadFromCluster(); | |
} else { | |
kubeconfig.loadFromDefault(); | |
} | |
const k8sAppsApi = kubeconfig.makeApiClient(k8s.AppsV1Api); | |
const result = await k8sAppsApi.readNamespacedDeployment('workflow-encoder-encodingpool', 'default'); | |
let deployment = result.body; | |
deployment.spec.replicas = numberOfEncoders; | |
return await k8sAppsApi.replaceNamespacedDeployment('workflow-encoder-encodingpool', 'default', deployment); | |
} catch (error) { | |
log.error(error); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment