Skip to content

Merge upstream main #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hooks",
"version": "0.6.2",
"version": "0.6.2-element",
"description": "Three projects are included - k8s: a kubernetes hook implementation that spins up pods dynamically to run a job - docker: A hook implementation of the runner's docker implementation - A hook lib, which contains shared typescript definitions and utilities that the other packages consume",
"main": "",
"directories": {
22 changes: 21 additions & 1 deletion packages/k8s/src/hooks/prepare-job.ts
Original file line number Diff line number Diff line change
@@ -203,10 +203,27 @@ export function createContainerSpec(
container.entryPointArgs = DEFAULT_CONTAINER_ENTRY_POINT_ARGS
}

const resources = new k8s.V1ResourceRequirements()
const limit_cpu = process.env.ACTIONS_POD_RESOURCE_LIMIT_CPU
const limit_memory = process.env.ACTIONS_POD_RESOURCE_LIMIT_MEMORY
const request_memory = process.env.ACTIONS_POD_RESOURCE_REQUEST_MEMORY
const request_cpu = process.env.ACTIONS_POD_RESOURCE_REQUEST_CPU
const imagePullPolicy = process.env.ACTIONS_POD_IMAGE_PULL_POLICY
const tailscaleAuthSecret = process.env.ACTIONS_POD_TAILSCALE_SECRET
resources.requests = {
...(request_cpu != undefined) && {cpu: request_cpu},
...(request_memory != undefined) && {memory: request_memory},
}
resources.limits = {
...(limit_cpu != undefined) && {cpu: limit_cpu},
...(limit_memory != undefined) && {memory: limit_memory},
}
const podContainer = {
name,
image: container.image,
ports: containerPorts(container)
imagePullPolicy: imagePullPolicy ? imagePullPolicy : "Always",
ports: containerPorts(container),
resources: resources
} as k8s.V1Container
if (container.workingDirectory) {
podContainer.workingDir = container.workingDirectory
@@ -228,6 +245,9 @@ export function createContainerSpec(
podContainer.env.push({ name: key, value: value as string })
}
}
if (tailscaleAuthSecret != undefined){
podContainer.env.push({ name: "AUTH_KEY", value: tailscaleAuthSecret })
}

podContainer.volumeMounts = containerVolumes(
container.userMountVolumes,
16 changes: 16 additions & 0 deletions packages/k8s/src/hooks/run-container-step.ts
Original file line number Diff line number Diff line change
@@ -105,8 +105,24 @@ function createContainerSpec(
extension?: k8s.V1PodTemplateSpec
): k8s.V1Container {
const podContainer = new k8s.V1Container()
const resources = new k8s.V1ResourceRequirements()
const limit_cpu = process.env.ACTIONS_POD_RESOURCE_LIMIT_CPU
const limit_memory = process.env.ACTIONS_POD_RESOURCE_LIMIT_MEMORY
const request_memory = process.env.ACTIONS_POD_RESOURCE_REQUEST_MEMORY
const request_cpu = process.env.ACTIONS_POD_RESOURCE_REQUEST_CPU
const imagePullPolicy = process.env.ACTIONS_POD_IMAGE_PULL_POLICY
resources.requests = {
...(request_cpu != undefined) && {cpu: request_cpu},
...(request_memory != undefined) && {memory: request_memory},
}
resources.limits = {
...(limit_cpu != undefined) && {cpu: limit_cpu},
...(limit_memory != undefined) && {memory: limit_memory},
}
podContainer.name = JOB_CONTAINER_NAME
podContainer.image = container.image
podContainer.resources = resources
podContainer.imagePullPolicy = imagePullPolicy ? imagePullPolicy : "Always"
podContainer.workingDir = container.workingDirectory
podContainer.command = container.entryPoint
? [container.entryPoint]