add changeset

Signed-off-by: Matteo Silvestri <matteosilv@gmail.com>
This commit is contained in:
Matteo Silvestri
2022-09-01 15:13:31 +02:00
parent f5701aa793
commit bf3cc134eb
2 changed files with 52 additions and 1 deletions
+51
View File
@@ -0,0 +1,51 @@
---
'@backstage/backend-common': patch
---
Implemented KubernetesContainerRunner: a ContainerRunner implementation that leverages Jobs on a kubernetes cluster
```ts
const kubeConfig = new KubeConfig();
kubeConfig.loadFromDefault();
const options: KubernetesContainerRunnerOptions = {
kubeConfig,
// namespace where Jobs will be created
namespace: 'default',
// Jobs name will be prefixed with this name
name: 'my-runner',
// An existing Kubernetes volume that will be used
// as base for mounts
mountBase: {
volumeName: 'workdir',
// Every mount must start with the base path
// see example below
basePath: '/workdir',
},
// Define a Pod template for the Jobs. It has to include
// a volume definition named as the mountBase volumeName
podTemplate: {
spec: {
containers: [],
volumes: [
{
name: 'workdir',
persistentVolumeClaim: {
claimName: 'workdir-claim',
},
},
],
},
},
};
const containerRunner = new KubernetesContainerRunner(options);
const runOptions: RunContainerOptions = {
imageName: 'golang:1.17',
args: ['echo', 'hello world'],
mountDirs: {
'/workdir/app': '/app',
},
};
containerRunner.runContainer(runOptions);
```
@@ -109,7 +109,7 @@ describeIfKubernetes('KubernetesContainerRunner', () => {
args: ['echo', 'hello world'],
logStream,
mountDirs: {
'/notWorkdir/app': '/app',
hostdir: '/app',
},
};
await expect(containerRunner.runContainer(runOptions)).rejects.toThrow(