Giter VIP home page Giter VIP logo

cnb-demo's Introduction

A quick demo of Cloud Native Buildpacks โ€“ https://buildpacks.io/

Including pack and kpack.

What you'll need

  • pack, docker, and dive CLI tools
    • brew install buildpacks/tap/pack docker dive
  • kubectl and kp CLI tools
    • brew install kubernetes-cli vmware-tanzu/kpack-cli/kp
  • Docker
  • A Kubernetes cluster with at least 4GB memory
    • If using Colima, start it with colima start -k -m4 -ax86_64
    • You may also need to export the location of the Docker daemon: export DOCKER_HOST=unix://$HOME/.colima/default/docker.sock

0. Prepare the environment

Initial setup

  1. Clone the Paketo Buildpacks sample apps, paketo-buildpacks/samples, to a local directory
    • git clone https://github.com/paketo-buildpacks/samples.git
  2. Install kpack into the Kubernetes cluster as described here
    • kubectl apply -f https://github.com/pivotal/kpack/releases/download/v0.9.2/release-0.9.2.yaml
  3. In your GitHub and Docker Hub account settings, create personal access tokens for each and set them in creds.yml
  4. Create the secrets for GitHub and Docker Hub
    • kubectl apply -f creds.yml
  5. Create the stack, store and builder
    • kubectl apply -f builder.yml

Resetting after a previous run

  1. Delete any images previously created by pack
    • docker rmi my-nodejs-app
  2. Delete the kpack resources for the stack, store, builder and image
    • kubectl delete -f builder.yml -f image.yml
  3. Delete builder and app image from Docker Hub (wait for deletion to finish)
  4. Re-create the stack, store and builder
    • kubectl apply -f builder.yml

1. Demo pack

  1. Get into one of the subdirectories containing a sample app
    • cd samples/nodejs/npm/
  2. Examine the contents (note lack of Dockerfile or any other build config)
    • ls -la
  3. Make sure pack is installed
    • pack --help
  4. See what builders pack suggests
    • pack builder suggest
  5. Build the app into an image using the Paketo base builder
    • pack build my-nodejs-app --builder paketobuildpacks/builder:base
  6. Check that the image was built and is available locally
    • docker images
  7. Examine how the layers are composed in the image
    • dive my-nodejs-app
  8. Download the SBOM from the image
    • pack sbom download my-nodejs-app
    • docker inspect my-nodejs-app

2. Demo kpack

Check the setup

  1. If you ran pack in a sample app above, get back to the directory containing the kpack resources
    • cd ../../..
  2. Check that kp is installed
    • kp --help
  3. Make sure the kpack CRDs are present in the cluster
    • kubectl api-resources | grep kpack
  4. Check the readiness of the stack, store and builder
    • kubectl get clusterstack,clusterstore,builder
  5. Check the builder image on Docker Hub

Create the Image and watch a build

  1. Apply the Image manifest
    • kubectl apply -f image.yml
  2. Check that the Image spawned a Build and a build pod
    • kubectl get image,build,po
  3. Look into the composition of the build pod, in particular the init containers
    • kubectl describe pod/my-nodejs-app-build-1-build-pod
  4. Stream the build logs using kp
    • kp builds logs my-nodejs-app
  5. Check that a new app image was published to Docker Hub

Simulate a buildpack/store update

  1. Edit the store configuration, changing the nodejs image version from 1.0.0 to 1.1.0
    • kubectl edit clusterstore nodejs
  2. After a short pause, check that the builder has been updated (spot "Observed Store Generation" and buildpack version)
    • kubectl describe builder my-nodejs-builder
  3. Check that a new builder image was published to Docker Hub
  4. Find the new Build and the new build pod
    • kubectl get image,build,po
  5. Stream the build logs using kp
    • kp builds logs my-nodejs-app
  6. Check that a new app image was published to Docker Hub

cnb-demo's People

Contributors

djmcaleese avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.