- How to build a runtime using buildpack
- 0. Common steps
- 1. Pack client
- 2. Pod running the lifecycle creator
- 3. Tekton and Pipeline as a Code
- Deprecated
The goal of this project is to test/experiment different approaches to build a runtime using:
- pack build client
- pod build
- Tekton & Pipeline As a Code
To play with the different scenarios, a sample runtime project is available and can be cloned
git clone https://github.com/snowdrop/quarkus-tap-petclinic.git quarkus-petclinic && cd quarkus-petclinic
To use the builder image (packaging the build
and run
stacks) able to build a Quarkus project, then it is needed to use the quarkus-buildpacks
project.
git clone https://github.com/quarkusio/quarkus-buildpacks.git && cd quarkus-buildpacks
# Generate the buildpack quarkus images (build, run and builder)
./create-buildpacks.sh
NOTE: If you plan to use a private container registry, then the images generated should be tagged/pushed to the registry (e.g. local.registry:5000
)
# Tag and push the images to the private docker registry
export REGISTRY_HOST="registry.local:5000"
docker tag redhat/buildpacks-builder-quarkus-jvm:latest ${REGISTRY_HOST}/redhat-builder/quarkus:latest
docker tag redhat/buildpacks-stack-quarkus-run:jvm ${REGISTRY_HOST}/redhat-buildpacks/quarkus:run
docker tag redhat/buildpacks-stack-quarkus-build:jvm ${REGISTRY_HOST}/redhat-buildpacks/quarkus:build
docker push ${REGISTRY_HOST}/redhat-builder/quarkus:latest
docker push ${REGISTRY_HOST}/redhat-buildpacks/quarkus:build
docker push ${REGISTRY_HOST}/redhat-buildpacks/quarkus:run
You can create a kubernetes cluster locally using docker desktop
and kind client and the following script
able to run a k8s cluster, a TLS/secured registry
git clone https://github.com/snowdrop/k8s-infra.git && cd k8s-infra/kind
./k8s/kind-tls-secured-reg.sh
NOTE: The certificate generated is copied within the file $HOME/local-registry.crt
and the user, password to be used to be authenticated
with the registry are respectively admin
and snowdrop
The easiest way to build a runtime
sample is to use the pack client with the builder runtime image
NOTE: The command should be executed within the sample runtime project or path should be calculated to point to the runtime sample project
REGISTRY_HOST="registry.local:5000"
pack build ${REGISTRY_HOST}/quarkus-petclinic \
--path ./ \
--builder ${REGISTRY_HOST}/buildpacks-builder-quarkus-jvm
If you plan to use a different version of the lifecycle, append then the following parameter with the image to be used:
--lifecycle-image buildpacksio/lifecycle:919b8ad-linux-arm64
WARNING: Take care that the lifecycle-image parameter will only be used for analyze/restore/export
and you would need to update the lifecycle in the builder image for it to be used for detect/build
NOTE: The builder.toml
can include or not a section containing the version and/or uri of the lifecycle to be used (e.g version: 0.12.4 or uri: ).
If both are omitted, lifecycle defaults to the version that was last released at the time of pack’s release. In other words, for a particular version of pack
, this default will not change despite new lifecycle versions being released.
First, create a configMap containing the selfsigned certificate of the docker registry under the namespace demo
kubectl create ns demo
kubectl create -n demo cm local-registry-cert --from-file $HOME/local-registry.crt
Create a secret containing the docker json cfg
file with auths
export REGISTRY_HOST="registry.local:5000"
kubectl create secret docker-registry registry-creds -n demo \
--docker-server="${REGISTRY_HOST}" \
--docker-username="admin" \
--docker-password="snowdrop"
Next deploy the deployment resource able to perform a build using a runtime example (e.g. )
kubectl apply -f k8s/build-pod/manifest.yml
kubectl delete -f k8s/build-pod/manifest.yml
Watch the progression of the build
kubectl -n demo logs -lapp=quarkus-petclinic-image-build -c build -f
TODO
See project doc for more information - https://github.com/shipwright-io/build
WARNING: This scenario will not work for the moment due to several issues:
To use shipwright, it is needed to have a k8s cluster, tekton installed
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.25.0/release.
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.28.1/release.yaml
Next, deploy the latest release of shipwright
kubectl apply -f https://github.com/shipwright-io/build/releases/download/v0.5.1/release.yaml
When done, we can create a secret, used by the serviceAccount of the build's pod to access the container registry
REGISTRY_HOST="registry.local:5000" REGISTRY_USER=admin REGISTRY_PASSWORD=snowdrop
kubectl create secret docker-registry registry-creds -n demo \
--docker-server="${REGISTRY_HOST}" \
--docker-username="${REGISTRY_USER}" \
--docker-password="${REGISTRY_PASSWORD}"
Install the serviceAccount that the build's pod will use (as we need to use an imagePullSecret consumming the registry secret):
kubectl apply -f k8s/shipwright/sa.yml
kubectl delete -f k8s/shipwright/sa.yml
Next, deploy the Buildpack strategy using the following CR
kubectl apply -f k8s/shipwright/buildstrategy-runtime.yml
kubectl delete -f k8s/shipwright/buildstrategy-runtime.yml
Create a Build object:
kubectl apply -f k8s/shipwright/build.yml
kubectl delete -f k8s/shipwright/build.yml
To view the Build which you just created:
kubectl get build -n demo
NAME REGISTERED REASON BUILDSTRATEGYKIND BUILDSTRATEGYNAME CREATIONTIME
buildpack-quarkus-build False BuildStrategyNotFound BuildStrategy quarkus-buildpacks 174m
Submit your BuildRun:
kubectl apply -f k8s/shipwright/build-run.yml
kubectl delete -f k8s/shipwright/build-run.yml
Wait until your BuildRun is completed, and then you can view it as follows:
kubectl get buildruns -n demo
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
buildpack-quarkus-buildrun-1 Unknown Pending 11s
kubectl apply -f k8s/shipwright/sa.yml
kubectl apply -f k8s/shipwright/buildstrategy-runtime.yml
kubectl apply -f k8s/shipwright/build.yml
kubectl apply -f k8s/shipwright/build-run.yml
kubectl delete -f k8s/shipwright/sa.yml
kubectl delete -f k8s/shipwright/buildstrategy-runtime.yml
kubectl delete -f k8s/shipwright/build.yml
kubectl delete -f k8s/shipwright/build-run.yml