Code deployment

The Code deployment tool helps you to deploy application source code to IBM® Code Engine, which simplifies the deployment process and reduces manual effort.

The Code deployment tool provides a streamlined and automated deployment process. It supports two types of deployments, IBM-managed and user-managed, and offers features such as retrieving the status of the deployment process, retrieving logs of the deploy application, and deletion of the specified application.

Supported services and deployment types

IBM-managed deployment
Deploys application code to an IBM-managed Code Engine environment, which provides a temporary and self-cleaning setup. The following key features are included:
Temporary resources
The application and related resources are automatically cleaned up after a defined period targeted toward developer persona.
Validating
The developer persona users receive the application URL endpoint and application name for convenient validating.
API Connect SaaS exclusive
This feature is designed for API Connect SaaS, streamlining deployment and validating processes.
User-managed deployment
Easily deploy application code that uses the Agent interface to a user-specified IBM Code Engine service, which offers flexibility and control. The following key features are included:
User-controlled resources
You can retain full control over the lifecycle and configuration of deployed resources.
Deployment details
The tool provides the application URL endpoint and application name upon successful deployment.

Features

The Code deployment tool provides two ways to deploy application code:
  • Deploy application code by uploading a .zip file to a user-managed Code Engine environment.
  • Deploy application code directly from a GitHub repository using SSH-based authentication. This method eliminates the need to manually create and upload a .zip file.
In addition to deploying application code by uploading a .zip file, the Code deployment tool supports retrieving source code directly from a GitHub repository using SSH-based authentication. This feature simplifies deployment by eliminating the need to manually create and upload a .zip file, allowing you to deploy applications directly from your source repository.
GitHub-based deployment prerequisites
  • A GitHub repository that contains the application source code.
  • You can specify the feature branch and context directory in the prompt. If you do not provide these details, the API Agent uses the main branch and the root directory as defaults.
  • The SSH URL of the repository. For example, git@github.com:<org>/<repo>.git.
  • Set up the SSH-based authentication:
    • Provide a valid SSH private key that has access to the repository.
    • Configure the SSH key in API Agent settings as an optional parameter. For details, see API Agent settings.
Zip file-based deployment prerequisites
Deploy application code by uploading a .zip file to a user-managed Code Engine environment.
Note:
  • Only .zip files are supported for deployment. Other formats are not accepted.
  • The file size must be less than 1 MB.
  • For information about basic predeployment validation checks, see Predeployment checks for IBM-managed Code Engine.
  • The tool determines the resource allocation for the deployed application as follows:
    • 0.125 CPU
    • 0.5 GB of memory
Check deployment status
Retrieve the deployment status of application by specifying the .zip file name, the GitHub repository name, or the generated application name.
  • After the deployment is completed, the tool displays the deployment status and the application name and URL endpoint.
  • For more information about the deployment statuses, see Deployment status.
Fetch logs of the application
Retrieve the logs of the application that is deployed in Code Engine.
  • The fetched logs are packaged as a .log file and provided for download and debugging.
Delete application
Delete the application and its related resources.

Predeployment checks for IBM-managed Code Engine

IBM-managed code engine does the checks that are performed before deploying the application and its associated resources.
IBM-managed
For IBM-managed environments, all the following conditions must be met before initiating a deployment.
Table 1. Requirements
Check Requirements
Project limit
  • If the project for the provider organization exists in the IBM Code Engine, the Code deployment tool uses the existing project.
  • If the project does not exists for the provider organization, the Code deployment tool creates a new project in IBM Code Engine if the number of available projects is less than 20.
Project state The project must not be in the creating state.
Existing application The system prevents a different user from deploying an application with the same source code .zip file
Multiple applications Only one application is allowed per project.
Registry secret A registry secret with the same name must not exist.

Naming conventions for deployment of resources

To ensure consistency and traceability, the Code deployment tool follows standardized naming patterns when it creates resources.
IBM Code Engine
Use the following naming conventions when you create deployment resources in the IBM Code Engine services:

The following table shows how resources are created for an application with code file name app-code, which is deployed by user 123 under the provider organization abc.

Table 2. Naming conventions
Resource type Format Naming convention
Project aa-<provider_organization>-project
Note: Projects in IBM Code Engine are scoped to the provider organization within API Connect.
aa-abc-project
Registry secret <project_name>-registry-secret aa-abc-project-registry-secret
Image build <project_name>-<application_code_file_name>-<user_id>-<resource_name> aa-abc-project-app-code-123-image-build
Image builds run <project_name>-<application_code_file_name>-<user_id>-<resource_name> aa-abc-project-app-code-123-image-build-run
Configmap <project_name>-<application_code_file_name>-<user_id>-<resource_name> aa-abc-project-app-code-123-cm
Secret <project_name>-<application_code_file_name>-<user_id>-<resource_name> aa-abc-project-app-code-123-secret
Application <project_name>-<application_code_file_name>-<user_id>-<resource_name> aa-abc-project-app-code-123-app

Deployment status

When you start the deployment status operation, different status are returned by the Code deployment tool to identify the progress or outcome of the deployment.
IBM Code Engine deployment status
The following statuses represent the stages of deployment within IBM Code Engine:
Table 3. Statuses
Stage Description Statuses
Project creation Project and secret setup PENDING, IN_PROGRESS, COMPLETED, FAILED
Image building Image build and push PENDING, IN_PROGRESS, COMPLETED, FAILED
Application deployment Application, configmap, and secret creation PENDING, IN_PROGRESS, COMPLETED, FAILED
Note:
  • All three stages are displayed to indicate which stages are completed, which one is in progress, and which are still pending.
  • If any part of the process fails, the failed stage displays the FAILED status and a reason for the failure.
  • If all stages display the COMPLETED status, the tool provides the Application URL and Application name.
  • Ensure that the source OpenAPI document that the deployed application was generated from is now updated to use the IBM Code Engine Application URL as the value of the servers[0].url. This is essential if the next planned action is to create a draft API and publish it in API Connect with the API Connect Task tool.