Skip to content

Instantly share code, notes, and snippets.

@royalgarter
Forked from alexellis/job.yaml
Created March 15, 2023 16:33
Show Gist options
  • Save royalgarter/2308280d50ec52199714d57744f90737 to your computer and use it in GitHub Desktop.
Save royalgarter/2308280d50ec52199714d57744f90737 to your computer and use it in GitHub Desktop.

Revisions

  1. @alexellis alexellis revised this gist Jul 19, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions job.yaml
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,10 @@
    # Pre-steps:
    # kubectl create secret generic docker-config --from-file $HOME/.docker/config.json

    # Other potential optimizations (suggested by @errordeveloper)
    # - Store "templates" in a permanent volume
    # - Download source via "tar" instead of git clone

    apiVersion: batch/v1
    kind: Job
    metadata:
  2. @alexellis alexellis revised this gist Jul 19, 2018. No changes.
  3. @alexellis alexellis revised this gist Jul 19, 2018. No changes.
  4. @alexellis alexellis revised this gist Jul 19, 2018. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions job.yaml
    Original file line number Diff line number Diff line change
    @@ -23,8 +23,6 @@ spec:
    volumeMounts:
    - name: build-context
    mountPath: /workspace
    - name: result
    mountPath: /result
    - name: docker-config
    mountPath: "/kaniko/secrets"
    readOnly: true
    @@ -48,8 +46,6 @@ spec:
    volumes:
    - name: build-context
    emptyDir: {}
    - name: result
    emptyDir: {}
    - name: docker-config
    secret:
    secretName: docker-config
  5. @alexellis alexellis revised this gist Jul 19, 2018. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion job.yaml
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    # Alex Ellis 2018
    # Example from: https://blog.alexellis.io/quick-look-at-google-kaniko/

    # Pre-steps:
    # kubectl create secret generic docker-config --from-file $HOME/.docker/config.json

    apiVersion: batch/v1
    kind: Job
    metadata:
    @@ -48,4 +54,3 @@ spec:
    secret:
    secretName: docker-config

    # kubectl create secret generic docker-config --from-file $HOME/.docker/config.json
  6. @alexellis alexellis created this gist Jul 19, 2018.
    51 changes: 51 additions & 0 deletions job.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    apiVersion: batch/v1
    kind: Job
    metadata:
    name: build-job
    labels:
    app: kaniko-example
    spec:
    template:
    spec:
    containers:
    - name: build
    image: gcr.io/kaniko-project/executor:latest
    args: ["-c", "/workspace/build/hello-world/", "-d", "alexellis2/hello-world-auto:kaniko"]
    env:
    - name: DOCKER_CONFIG
    value: "/kaniko/secrets"
    volumeMounts:
    - name: build-context
    mountPath: /workspace
    - name: result
    mountPath: /result
    - name: docker-config
    mountPath: "/kaniko/secrets"
    readOnly: true
    initContainers:
    - name: clone
    image: alpine:3.7
    command: ["/bin/sh","-c"]
    args: ['apk add --no-cache git && git clone https://github.com/alexellis/hello-world-kaniko /workspace/ && git clone https://github.com/openfaas/templates /workspace/templates']
    volumeMounts:
    - name: build-context
    mountPath: /workspace
    - name: shrinkwrap
    image: openfaas/faas-cli:0.6.14
    command: ["/bin/sh","-c"]
    args: ["cp -r ./templates/template . && faas-cli build --shrinkwrap -f stack.yml"]
    workingDir: /workspace
    volumeMounts:
    - name: build-context
    mountPath: /workspace
    restartPolicy: Never
    volumes:
    - name: build-context
    emptyDir: {}
    - name: result
    emptyDir: {}
    - name: docker-config
    secret:
    secretName: docker-config

    # kubectl create secret generic docker-config --from-file $HOME/.docker/config.json