Skip to content

Instantly share code, notes, and snippets.

@alexellis
Last active September 29, 2021 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexellis/b9e82390526dad5c4bc39d7f44b0a250 to your computer and use it in GitHub Desktop.
Save alexellis/b9e82390526dad5c4bc39d7f44b0a250 to your computer and use it in GitHub Desktop.
OpenFaaS Kaniko Jenkins Pipelines Gist
// this guarantees the node will use this template
def label = "mypod-${UUID.randomUUID().toString()}"
podTemplate(label: label,
containers: [
containerTemplate(privileged: false, name: 'faascli', image: 'openfaas/faas-cli:0.8.6', ttyEnabled: true, command: 'cat'),
containerTemplate(name: "kaniko", image:"gcr.io/kaniko-project/executor:debug", ttyEnabled: true, command: "/busybox/cat")
]) {
node(label) {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/alexellis/openfaas-cloud-test']]])
stage("shrinkwrap") {
container("faascli") {
sh "apk add --no-cache git"
sh "faas-cli template store pull node8-express"
sh "faas-cli build --shrinkwrap"
}
}
stage("build") {
container(name: "kaniko", shell: '/busybox/sh') {
// Remove --no-push to push to a registry
// See also: https://github.com/GoogleContainerTools/kaniko#pushing-to-different-registries
withEnv(['PATH+EXTRA=/busybox:/kaniko']) {
sh '''#!/busybox/sh
/kaniko/executor -c /home/jenkins/workspace/Kaniko/build/timezone-shift --no-push
'''
}
}
}
}
}
@antweiss
Copy link

antweiss commented Mar 28, 2019

Looks like an issue with kaniko:debug container:
`docker run -it --entrypoint /busybox/sh gcr.io/kaniko-project/executor:debug

/ # ls

ls: can't open '.': Value too large for defined data type`

The same happens on k8s.
Probably related to this: GoogleContainerTools/distroless#225

So the container just can't read the filesystem

@alexellis
Copy link
Author

Thank you so much for helping. I have this working now and have edited the text. How does it look at your end now?

@antweiss
Copy link

antweiss commented Mar 28, 2019

Well, I didn't really help I believe. Just stumbled on a different problem. :)
Anyway - it was a small attempt to return a favour - your tutorials have helped me quite a number of times.
Sadly still doesn't work for me because of the same issue:

ls: can't open '/home/jenkins/workspace/': Value too large for defined data type
total 0
Error: error resolving dockerfile path: please provide a valid path to a Dockerfile within the build context with --dockerfile
Usage:
  executor [flags]

@fourirakbar
Copy link

Hi just curious, how to build the image with kaniko, if we don't use --no-push? I still get confused how to build and push the image to registry (eg. Google Container Registry)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment