Build images from application source
Harbor needs to be activated for this lab.
When your team is using Harbor for private image registries, you can build images from source using pre-configured Tekton pipelines using the paketo (used by Buildpacks mode) task or the Kaniko task (used by the Docker mode) to build images from application source.
Build the blue image
-
In the left menu, click on
Builds
. -
Click on
Create Build
. -
Fill in the name
blue
for your build and a tag (default tag is latest). -
Choose
Docker
and fill in the repo URL for theblue
repo created in the previous lab:https://gitea.<your-domain>/<gitea-username>/blue
. -
Click
Submit
. -
Click
Deploy changes
.
Now a Tekton Pipeline and PipelineRun resource to build the image will be created. This will take around 30 seconds. Then the PipelineRun will start building the image. During this time the status will show in progress
:
When the build is finished, the status will show healthy
:
To see the full PipelineRun of the build, go to the list of Builds and click on PipelineRun
of the blue
build. This will open the Tekton Dashboard and show the status of the PipelineRun of the build:
When the build is ready you can see the image in Harbor:
-
Open Harbor.
-
Click on the project of your team. Here you will see all the registries of the team, including the registry of the new build image.
Re-run the build (optional)
For this step you need to have the Tekton cli installed. If you don't have the Tekton cli installed, you can install it from this page: https://tekton.dev/docs/cli/
To run the build again using the Console, follow these steps:
-
Change the tag of the build for example to
v1.0.0
. -
Click
Submit
. -
Click
Deploy changes
.
To re-build the image using the same tag, restart the build pipeline using the Tekton cli in the Shell:
-
Start a shell in the Console
-
Get the name of the pipeline
kubectl get pipelines
NAME AGE
docker-build-blue 41h
- Get the name of the pipelinerun:
kubectl get pipelineruns
NAME SUCCEEDED REASON STARTTIME COMPLETIONTIME
docker-build-blue-latest True Succeeded 41h 41h
- Start the pipeline using the pipelinerun:
tkn pipeline start docker-build-blue --use-pipelinerun docker-build-blue-latest
PipelineRun started: docker-build-blue-latest-j5mmt
- In order to track the PipelineRun progress run:
tkn pipelinerun logs docker-build-blue-latest-j5mmt -f
But it's easier to just open the Tekton dashboard and Click on PipelineRuns
.