Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

feat: add a TaskRun to build a function runtime image #11

Merged
merged 2 commits into from
Aug 26, 2019
Merged

Conversation

lance
Copy link
Member

@lance lance commented Aug 20, 2019

DO NOT MERGE

Update 22-08-2019

The build is defined as a tekton Task with the following steps.

  • Step 1 - copy-source
    • Mount a Volume for the ConfigMap containing the user's index.js and package.json at /fn-source
    • Mount a Volume that is an emptyDir at /home/node/usr
    • Copy /fn-source/index.js and /fn-source/package.json to /home/node/usr
  • Step 2 - generate
    • Mount the copied source Volume at /home/node/usr
    • Mount an emptyDir Volume at /home/node/build
    • Run an s2i build to generate a Dockerfile at /home/node/build
  • *Step 3 - build
    • Mount /home/node/usr, /home/node/build and another emptyDir Volume at /var/lib/containers
    • Use buildah to generate a container image using the Dockerfile generated in the previous step
  • Step 4 - push
    • Mount /var/lib/containers and use buildah to push the image to the internal repository.

The operator, meanwhile, creates a knative Service which uses the resulting image pushed to the internal repository in the final build step.

All of this mostly works. However there seems to be a problem with the s2i build step wherein dependencies added to the /home/node/usr directory during the assemble phase do not appear in the resulting runtime image. At this point, I am a bit stumped. I have shared this with @bbrowning on Slack, and he is also unsure about what might be happening with the image. I have confirmed that the image being run for the Service is the same sha as the one being generated in the build.

This is now working as expected. @openshift-cloud-functions/contributors please have a look.

Original text

This is a work in progress. Currently, when deploying a function the TaskRun is created as expected, but does not succeed, generating this error:

status:
  conditions:
    - lastTransitionTime: '2019-08-20T22:03:39Z'
      message: >-
        Missing or invalid Task js-faas/js-function-build-runtime: pods
        "testfunc-build-pod-459eed" is forbidden: unable to validate against any
        security context constraint:
        [spec.containers[0].securityContext.privileged: Invalid value: true:
        Privileged containers are not allowed
        spec.containers[2].securityContext.privileged: Invalid value: true:
        Privileged containers are not allowed
        spec.containers[4].securityContext.privileged: Invalid value: true:
        Privileged containers are not allowed]
      reason: CouldntGetTask
      status: 'False'
      type: Succeeded

Fixes: #10

@lance lance added enhancement New feature or request experiment Tasks that help with the R&P process. labels Aug 20, 2019
@lance lance requested a review from rhuss August 20, 2019 22:22
Because now we are running a tekton task to build a runtime
image, we just need to specify the runtime image name.
@lance lance self-assigned this Aug 24, 2019
@lance lance marked this pull request as ready for review August 24, 2019 17:45
@lance lance removed the experiment Tasks that help with the R&P process. label Aug 24, 2019
Copy link
Contributor

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We might want to install (create) the Task automatically by the operator?

@lance lance changed the title src: add a TaskRun to build a function runtime image feat: add a TaskRun to build a function runtime image Aug 26, 2019
@lance
Copy link
Member Author

lance commented Aug 26, 2019

@zroubalik thanks for the review. I opened an issue to create the Task when the operator is installed.

@lance lance merged commit 55b7f42 into master Aug 26, 2019
@lance lance deleted the 10-add-build branch August 26, 2019 15:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use pipelines to build a runtime image
2 participants