IBM Cloud Global

Cloud Global

Our mission is to provide clients with an online user community of industry peers and IBM experts, to exchange tips and tricks, best practices, and product knowledge. We hope the information you find here helps you maximize the value of your IBM Cloud solutions.

 View Only

Deploying a Sample App on IBM Cloud Code Engine with CI/CD Toolchain

By Parinitha M posted Thu December 19, 2024 03:58 AM

  

                   
Deploying a Sample App on IBM Cloud Code Engine with CI/CD Toolchain

Discover how to create an open toolchain with IBM Cloud® Continuous Delivery and deploy your app on Code Engine. Explore how toolchains are implemented within the Continuous Delivery service and learn to develop and deploy a simple web application using these toolchains.

Prerequisites:

  • IBM Cloud Code Engine: Code Engine Project and an API Key. You can create these resources by using either the UI or the CLI. For more information about Code Engine Projects, see Code Engine Projects.
  • Secrets Manager : With Secrets Manager, you can create, lease, and centrally manage secrets that are used in IBM Cloud services or your custom-built applications. Secrets are stored in a dedicated Secrets Manager instance, built on open source HashiCorp Vault 
  • Create a namespace on the Container Registry
  • Provision the Continuous Delivery in the specified region and proceed with creating the instance.

This above diagram illustrates a CI/CD pipeline workflow integrated with Code Engine to deploy applications

CI/CD pipeline workflow integrated with Code Engine 

  • Issue Tracker → Developers begin by resolving tasks or defects.
  • App Repo → The app repository is where code modifications are done.
  • PR Pipeline → Pull Requests undergo review through testing and analysis.
  • Code Risk Analyzer → Code Risk Analyser evaluates code for risks and quality issues.
  • CI Pipeline (Continuous Integration Pipeline)→ Once validated, code is built, tested, and packaged.
  • Code Engine → The final verified app is deployed to Code Engine.

Steps to Create an Open Toolchain and Deploy the Code Engine App:
Step 1: Create the Toolchain 



  • On the Welcome page, review the default toolchain settings. Ensure the toolchain name is unique within the same region and resource group in IBM Cloud.


Step 2: Configure the application and the Secret Manager.

  • In the Application step, the recommended options for the application source code repo are displayed by default. To view all of the available options for the underlying Git integration, click Advanced Options. By default, the toolchain uses the default sample that clones the sample app as an IBM-hosted Git Repos and Issue Tracking repo.
  • Optional. The toolchain template provides a Sample Hello World Application app. If you want to link an existing Application repo for the toolchain, select Bring your own app and specify the URL for the repo. The toolchain supports linking only to existing Git Repos and Issue Tracking repos.

  • Here you can change the name of the app repo. The region of the repo remains the same as the region of the toolchain.

  • IBM Secrets Manager securely stores and manages secrets like API keys, image signatures, and HashiCorp credentials, which are integral to your toolchain.
  • If you have already created the Secrets Manager instance, the Toolchain will be automatically populated with preconfigured secrets. You don't need to manually select secrets from the vault integrations attached to the toolchain.




Step 3: Select your application build strategy and deployment type

Step 4: Configure the deployment target

  • Set up the target Code Engine project for app deployment. After the app completes the build, test, and scan phases, the pipeline deploys the app image to the specified project, making it ready for acceptance or integration testing.
  • If the API key has the required access, fields like Container registry region, namespace, Cluster region, name, and Resource group are automatically populated. You can update these fields as needed to match your configuration.
    • App name: The name of the app. The default app name is the same as your toolchain name.
    • IBM Cloud API Key: The API key that is used to interact with the ibm cloud CLI tool in several tasks. Use one of the following methods to specify the API key that you want to use
    • Click the key icon to import an existing API key from a secrets vault of your choice.
    • Copy and paste an existing API key.
    • Click New to create an API key.
    • Generate a new api-key if you don’t have an existing API key.
    • Container registry region: The Container Registry region in which your container namespace is located.

    • Container registry namespace: Select from the list of container namespaces in the associated Container Registry region.

    • Code Engine region: The region in which your Code Engine project is located.

    • Code Engine Resource Group: The Resource Group where your Code Engine project was created.

    • Code Engine project: The name of the project that was created in Code Engine. Your app is deployed to this project.

  • Optional tools can be added to the toolchain. For example, DevOps Insights offers detailed analytics from popular CI/CD tools, helping to enhance the speed and control of your application delivery.

                                      

Step 5: Complete the toolchain setup

  • On the Summary page, click Create toolchain. Several steps run automatically to set up your toolchain.

    Step 6:
    Set Up the Toolchain and  discovering the pipelines
    • Continuous Integration Pipeline(CI-Pipeline): Runs Unit Tests, Code Coverage, Static Scans, CIS, and BOM checks when changes are merged into the master branch. It also builds and uploads artifacts to IBM Cloud Kubernetes Service and stores metadata in the Inventory repo.

    • Continuous Deployment Pipeline(CD-Pipeline): Deploys Code Engine component images built by the CI pipeline to a different project.

    • Pull Request Pipeline(PR-Pipeline): Runs Unit Tests and Static Scans when changes are merged into any branch.

  • On the Toolchain Overview page, initiate the Continuous Integration pipeline by selecting the card labeled Delivery Pipeline

  • On the Next Page, navigate to the section where you can trigger the manual-run for the CI pipeline



  • During the run process, the application repository will remain in a pending state, progressing through each stage, until all stages of the CI pipeline successfully complete. Click the Logs tab, and scroll to the end of the log. You can check the repository associated with your application for updates.

  • On the Toolchain Overview page,Now proceed with the continuous delivery/deployment pipelines(cd pipeline) . Then run pipeline to start the cd-manual-run trigger.

  • Once the Continuous Deployment pipeline run is successful, you can click on the pipeline run to review the completed steps.. Click the Parameters tab, Click the link to your deployed Code Engine app to view the running app.
  • You can also verify this by navigating to the container project and reviewing the application.


Conclusion:
In this blog post, we looked at how to create an open toolchain with IBM Cloud Continuous Delivery and publish an app on Code Engine. The development process is streamlined by including automated pipelines for build, test, scan, and deployment, resulting in efficient and dependable application delivery. This solution takes advantage of serverless computing to enable scalable and smooth deployments.


0 comments
37 views

Permalink