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 { 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))
} }

View File

@@ -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
} }