mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 16:46:43 +00:00
Signed-off-by: Joan Miquel Luque Oliver <joan.luque@dynatrace.com>
This commit is contained in:
committed by
GitHub
parent
7afb8f9323
commit
b388518d40
@@ -95,10 +95,12 @@ export async function createPod(
|
|||||||
appPod.spec.containers = containers
|
appPod.spec.containers = containers
|
||||||
appPod.spec.restartPolicy = 'Never'
|
appPod.spec.restartPolicy = 'Never'
|
||||||
|
|
||||||
if (!useKubeScheduler()) {
|
const nodeName = await getCurrentNodeName()
|
||||||
appPod.spec.nodeName = await getCurrentNodeName()
|
if (useKubeScheduler()) {
|
||||||
|
appPod.spec.affinity = await getPodAffinity(nodeName)
|
||||||
|
} else {
|
||||||
|
appPod.spec.nodeName = nodeName
|
||||||
}
|
}
|
||||||
|
|
||||||
const claimName = getVolumeClaimName()
|
const claimName = getVolumeClaimName()
|
||||||
appPod.spec.volumes = [
|
appPod.spec.volumes = [
|
||||||
{
|
{
|
||||||
@@ -155,8 +157,11 @@ export async function createJob(
|
|||||||
job.spec.template.spec.containers = [container]
|
job.spec.template.spec.containers = [container]
|
||||||
job.spec.template.spec.restartPolicy = 'Never'
|
job.spec.template.spec.restartPolicy = 'Never'
|
||||||
|
|
||||||
if (!useKubeScheduler()) {
|
const nodeName = await getCurrentNodeName()
|
||||||
job.spec.template.spec.nodeName = await getCurrentNodeName()
|
if (useKubeScheduler()) {
|
||||||
|
job.spec.template.spec.affinity = await getPodAffinity(nodeName)
|
||||||
|
} else {
|
||||||
|
job.spec.template.spec.nodeName = nodeName
|
||||||
}
|
}
|
||||||
|
|
||||||
const claimName = getVolumeClaimName()
|
const claimName = getVolumeClaimName()
|
||||||
@@ -540,6 +545,26 @@ async function getCurrentNodeName(): Promise<string> {
|
|||||||
return nodeName
|
return nodeName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getPodAffinity(nodeName: string): Promise<k8s.V1Affinity> {
|
||||||
|
const affinity = new k8s.V1Affinity()
|
||||||
|
affinity.nodeAffinity = new k8s.V1NodeAffinity()
|
||||||
|
affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution =
|
||||||
|
new k8s.V1NodeSelector()
|
||||||
|
affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms =
|
||||||
|
[
|
||||||
|
{
|
||||||
|
matchExpressions: [
|
||||||
|
{
|
||||||
|
key: 'kubernetes.io/hostname',
|
||||||
|
operator: 'In',
|
||||||
|
values: [nodeName]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
return affinity
|
||||||
|
}
|
||||||
|
|
||||||
export function namespace(): string {
|
export function namespace(): string {
|
||||||
if (process.env['ACTIONS_RUNNER_KUBERNETES_NAMESPACE']) {
|
if (process.env['ACTIONS_RUNNER_KUBERNETES_NAMESPACE']) {
|
||||||
return process.env['ACTIONS_RUNNER_KUBERNETES_NAMESPACE']
|
return process.env['ACTIONS_RUNNER_KUBERNETES_NAMESPACE']
|
||||||
|
|||||||
Reference in New Issue
Block a user