Create an Image Builder Using Source Code
This section describes how to build source code into container images (S2I).
After the image builder starts running, it will automatically perform the following operations:
-
Connect to the user-specified source code repository and retrieve the source code for the application.
-
Use the image builder to build the source code into a container image.
-
Push the container image to the user-specified image service.
Prerequisites
-
You need to join a project and have the Application Workload Management permission in the project. For more information, see Project Members and Project Roles.
-
You need to have an available code repository. KubeSphere supports Git repositories and Java, Node.js, and Python source code by default.
-
If you use a private code repository, you need to create a Secret in advance in the project to store the code repository credentials. For more information, see Create a Secret.
-
You need to have an available container image service to store the container images generated from the build. For more information, refer to the Docker official documentation.
-
You need to create a secret in the project in advance to store the image service information. For more information, refer to Create a Secret.
Steps
-
Log in to the KubeSphere web console with a user who has Application Workload Management permissions and enter your workspace.
-
Click Image Builders in the left navigation pane.
-
Select a project from the drop-down list in the upper left corner of the page.
-
Click Create on the page.
-
On the Build Mode tab, select Java, Node.js, or Python based on the source code language, then click Next.
-
On the Build Settings tab, configure the build environment, code repository information, and image service information, then click Create.
Parameter Description Build Environment
The build environment for the container image. Please select the build environment based on the language and version of the source code.
Code Repository URL
The address of the source code repository. Currently, only Git repositories are supported.
Code Repository Branch
The branch of the source code repository.
Code Repository Secret
If your code repository requires authentication, select the Secret containing the code repository credentials.
Image Name
The name of the target container image to be built. The name can only contain lowercase letters, numbers, hyphens (-), periods (.), forward slashes (/), and colons (:), and must start and end with a lowercase letter or number.
The image name should include the image namespace, for example, <DOCKERHUB_USERNAME>/<IMAGE NAME>. If no namespace is entered, the system will automatically add the namespace library, resulting in an actual image name of library/<IMAGE NAME>.
Image Tag
The tag of the target container image to be built.
Target Image Service
The image service used to store the target image. Select the Secret containing the image service information.
Trigger Token
The authentication token used by a client to trigger a KubeSphere image build via webhook. If a token is set, requests must provide the correct token to trigger the image build. The token can only contain uppercase letters, lowercase letters, and numbers.
After the service is created, KubeSphere will create an image builder and provide a URL that can be used by third-party applications to trigger the image build. You can obtain the URL on the details page of the image builder.
Code Relative Path
The path of the source code in the code repository.
Environment Variables
Environment variables for the image runtime, used to control the behavior of the image during runtime.
-
For more information about Java build environment variables, please visit the s2i-java-container repository.
-
For more information about Node.js build environment variables, please refer to the s2i-nodejs-container repository.
-
For more information about Python build environment variables, please refer to the s2i-python-container repository.
After the image builder is created, it will be displayed in the image builder list.
-