Mount volume with ahrdcoded path

This commit is contained in:
Ferenc Hammerl
2022-09-26 11:50:02 +00:00
parent 4de51ee6a5
commit 3d102fd372
6 changed files with 2251 additions and 18199 deletions

3278
package-lock.json generated

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -114,7 +114,7 @@ function createPodSpec(
}
function generateBuildTag(): string {
return `${generateRandomString()}:${uuidv4().substring(0, 6)}`
return `${generateRandomString()}:${generateRandomString(6)}`
}
function generateBuildHandle(): string {
@@ -123,7 +123,7 @@ function generateBuildHandle(): string {
function generateRandomString(length = 10): string {
let v = ''
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
const chars = 'abcdefghijklmnopqrstuvwxyz'
for (let i = 0; i < length; i++) {
v += chars.charAt(Math.floor(Math.random() * length))
}

View File

@@ -1,4 +1,6 @@
import * as k8s from '@kubernetes/client-node'
import { getVolumeClaimName } from '../hooks/constants'
import { POD_VOLUME_NAME } from '.'
const REGISTRY_CONFIG_MAP_YAML = `
storage:
@@ -188,6 +190,14 @@ export function kanikoPod(
c.image = 'gcr.io/kaniko-project/executor:latest'
c.name = 'kaniko'
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 = [
{
name: 'GIT_TOKEN',
@@ -196,13 +206,18 @@ export function kanikoPod(
]
c.args = [
'--dockerfile=Dockerfile',
`--context=${workingDirectory}`,
`--context=dir:///mnt/kan`,
`--destination=docker-registry.default.svc.cluster.local:5000/${imagePath}`
]
spec.containers = [c]
spec.dnsPolicy = 'ClusterFirst'
spec.restartPolicy = 'Never'
pod.spec = spec
const claimName:string = getVolumeClaimName()
pod.spec.volumes = [
{
name: POD_VOLUME_NAME,
persistentVolumeClaim: { claimName },
}]
return pod
}