Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/k8s/src/k8s/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,32 @@ export async function createPod(
})
}

function addSharedVolumes(
podSpec: k8s.V1PodSpec,
jobContainer: k8s.V1Container,
services: k8s.V1Container[]
): void {
podSpec.volumes = podSpec.volumes || []
const sharedVolumeName = 'shared-data'
// Add a shared directory so job container and service containers can share data.
podSpec.volumes.push({
name: sharedVolumeName,
emptyDir: {}
})
jobContainer.volumeMounts = jobContainer.volumeMounts || []
jobContainer.volumeMounts.push({
name: sharedVolumeName,
mountPath: '/shared'
})
for (const service of services) {
service.volumeMounts = service.volumeMounts || []
service.volumeMounts.push({
name: sharedVolumeName,
mountPath: '/shared'
})
}
}

export async function createPodSpec(
jobContainer?: k8s.V1Container,
services?: k8s.V1Container[],
Expand Down Expand Up @@ -182,6 +208,10 @@ export async function createPodSpec(
}
)

if (jobContainer && services?.length) {
addSharedVolumes(podSpec, jobContainer, services)
}

if (registry) {
const secret = await createDockerSecret(registry)
if (!secret?.metadata?.name) {
Expand Down
Loading