Create projects
A Project is a collection of a Build, a Workload and a Service. The benefit of using Projects is that you can create a Build, a Workload and a Service in one run. Projects are ideal for developers to run multiple code branches next to each other and automatically update the deployment based on a push. In this lab we are going to create a Project and see how everything now comes together is one simple form.
Create a new Git repository
-
Create a new repo called
nodejs-helloworld
in Gitea. -
Set the Default Branch to
master
. -
Clone the Hello World Sample Application:
git clone https://github.com/linode/apl-nodejs-helloworld
cd apl-nodejs-helloworld
- Mirror the Hello World Sample Application to your
nodejs-helloworld
repo:
git push --mirror https://gitea.<your-domain>/<your-user-name>/nodejs-helloworld.git
Create a Project
-
Go to
Project
and clickCreate Project
. -
Fill in a name for the Project. This name is used for the Build (the name of the image) and the Workload. The Service will automatically select the ClusterIP service name based on the Workload name.
-
Click
Create build from source
. -
Click
Next
. -
Choose
Docker
and fill in the repository URL of thenodejs-helloworld
repository. -
Enable
Trigger
. -
Click
Next
. -
Select the
Digest
strategy for theAuto image updater
. -
The
imageRepository
is already filled in. Make sure thetag
is identical to the tag used for the Build. -
Use the default Chart values.
-
Click
Next
. -
Under
Exposure
selectExternal
. -
Click
Submit
. -
Click
Deploy Changes
.
Get the webhook URL
Before we can configure the webhook for the nodejs-helloworld
repo in Gitea, we will need the webhook URL. You can find this webhook URL for your build in the list of Builds. Add the webhook URL to your clipboard.
Also notice that the status of the Build shows an exclamation mark. This is because the Tekton Pipeline is created, but the PipelineRun is not yet created because it was not triggered yet.
Create a Webhook
-
In the Console, click on
apps
the left menu and then openGitea
. -
In the top menu of Gitea, click on
Explore
and then on thenodejs-helloworld
repo. -
Go to
Settings
(top right) and then toWebhooks
. -
Click
Add Webhook
and selectGitea
. -
In the
Target URL
, paste the webhook URL from your clipboard. -
Click
Add Webhook
.
Trigger the build
You can now trigger the Build by doing a commit in the nodejs-helloworld
repo, or by testing the webhook. Let's test the webhook:
-
In Gitea, go to the
Settings
(top right) of thenodejs-helloworld
repo and then toWebhooks
. -
Click on the webhook we just created.
-
In the bottom, click on
Test Delivery
.
Check the status of the Workload
Go to Workloads and click on the Argo CD application
link of the Workload created by the Project. What do you see? The Argo CD application is still in a Degraded
state because the image build has not completed yet. When the build in finished and the image can be pulled, the status of the application will automatically become Healthy
.
Check the status of the Service
When the state of the Workload becomes Healthy
, the URL of the Service created by the Project will show the following page:
Change the code and push the commit
-
Go to the
hello-world
repository. -
Edit the
package.json
and set theVersion
to1.4.0
. -
Commit the changes.
Check the URL again. After a couple of minutes you will see the following page: