mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-17 18:26:44 +00:00
Mount volume with ahrdcoded path
This commit is contained in:
3278
package-lock.json
generated
3278
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
7160
packages/docker/package-lock.json
generated
7160
packages/docker/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
3128
packages/hooklib/package-lock.json
generated
3128
packages/hooklib/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
6861
packages/k8s/package-lock.json
generated
6861
packages/k8s/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -114,7 +114,7 @@ function createPodSpec(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateBuildTag(): string {
|
function generateBuildTag(): string {
|
||||||
return `${generateRandomString()}:${uuidv4().substring(0, 6)}`
|
return `${generateRandomString()}:${generateRandomString(6)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateBuildHandle(): string {
|
function generateBuildHandle(): string {
|
||||||
@@ -123,7 +123,7 @@ function generateBuildHandle(): string {
|
|||||||
|
|
||||||
function generateRandomString(length = 10): string {
|
function generateRandomString(length = 10): string {
|
||||||
let v = ''
|
let v = ''
|
||||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
const chars = 'abcdefghijklmnopqrstuvwxyz'
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
v += chars.charAt(Math.floor(Math.random() * length))
|
v += chars.charAt(Math.floor(Math.random() * length))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import * as k8s from '@kubernetes/client-node'
|
import * as k8s from '@kubernetes/client-node'
|
||||||
|
import { getVolumeClaimName } from '../hooks/constants'
|
||||||
|
import { POD_VOLUME_NAME } from '.'
|
||||||
|
|
||||||
const REGISTRY_CONFIG_MAP_YAML = `
|
const REGISTRY_CONFIG_MAP_YAML = `
|
||||||
storage:
|
storage:
|
||||||
@@ -188,6 +190,14 @@ export function kanikoPod(
|
|||||||
c.image = 'gcr.io/kaniko-project/executor:latest'
|
c.image = 'gcr.io/kaniko-project/executor:latest'
|
||||||
c.name = 'kaniko'
|
c.name = 'kaniko'
|
||||||
c.imagePullPolicy = 'Always'
|
c.imagePullPolicy = 'Always'
|
||||||
|
c.volumeMounts = [
|
||||||
|
{
|
||||||
|
name: POD_VOLUME_NAME,
|
||||||
|
mountPath: '/mnt/kan',
|
||||||
|
subPath: "_actions/fhammerl/container-actions-demo/main/docker-built-from-file",
|
||||||
|
readOnly: true
|
||||||
|
}
|
||||||
|
]
|
||||||
c.env = [
|
c.env = [
|
||||||
{
|
{
|
||||||
name: 'GIT_TOKEN',
|
name: 'GIT_TOKEN',
|
||||||
@@ -196,13 +206,18 @@ export function kanikoPod(
|
|||||||
]
|
]
|
||||||
c.args = [
|
c.args = [
|
||||||
'--dockerfile=Dockerfile',
|
'--dockerfile=Dockerfile',
|
||||||
`--context=${workingDirectory}`,
|
`--context=dir:///mnt/kan`,
|
||||||
`--destination=docker-registry.default.svc.cluster.local:5000/${imagePath}`
|
`--destination=docker-registry.default.svc.cluster.local:5000/${imagePath}`
|
||||||
]
|
]
|
||||||
spec.containers = [c]
|
spec.containers = [c]
|
||||||
spec.dnsPolicy = 'ClusterFirst'
|
spec.dnsPolicy = 'ClusterFirst'
|
||||||
spec.restartPolicy = 'Never'
|
spec.restartPolicy = 'Never'
|
||||||
pod.spec = spec
|
pod.spec = spec
|
||||||
|
const claimName:string = getVolumeClaimName()
|
||||||
|
pod.spec.volumes = [
|
||||||
|
{
|
||||||
|
name: POD_VOLUME_NAME,
|
||||||
|
persistentVolumeClaim: { claimName },
|
||||||
|
}]
|
||||||
return pod
|
return pod
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user