IBM Cloud Code Engine (serverless) Application setup with a private registry — Step by Step Guide
Alain Airom
Posted on February 29, 2024
The aim of the use case presented here is to provide a simplified step-by-step guide to deploy applications (any kind of application type eg. Batch, Job or Applications) from a private code repository (example here is using a private GitHub repo) to a private container image registry hosted on IBM Cloud.
This document assumes working with a private GitHub repository.
Create a Private Container Image Registry on IBM Cloud
The documentation: https://cloud.ibm.com/registry/start
Install, Set Up, and Log In
Podman with Docker compatibility could be used as well
Podman Desktop can replace Docker desktop with a 100% compatibility mode
Install the Container Registry plug-in (assuming IBM Cloud CLI is already installed)
ibmcloud plugin install container-registry -r 'IBM Cloud'
- Log in to your IBM Cloud account
ibmcloud login -a https://cloud.ibm.com
If you have a federated ID, use ibmcloud login --sso to log in to the IBM Cloud CLI.
ibmcloud login --sso
- Ensure that you're targeting the correct IBM Cloud Container Registry region. Hereafter the region is set to Frankfurt
ibmcloud cr region-set eu-central
'''
The region is set to 'eu-central', the registry is 'de.icr.io'.
- Choose a name for your first namespace, and create that namespace. Use this namespace for the rest of the Quick Start.
ibmcloud cr namespace-add <my_namespace>
'''
ibmcloud cr namespace-add xxx_namespace
Adding namespace 'xxx_namespace' in resource group 'default' for account XYZ's Account in registry de.icr.io...
### Push the image to your private registry (Testing the working with your registry)
- Log your local Docker daemon into the IBM Cloud Container Registry.
ibmcloud cr login
- Pull a test image from Docker Hub
docker pull hello-world
'''
Using default tag: latest
c1ec31eb5944: Download complete
d2c94e258dcb: Download complete
docker.io/library/hello-world:latest
- Choose a repository and tag by which you can identify the image. Use the same repository and tag for the rest of this Quick Start
docker tag hello-world de.icr.io/xxx_namespace/xxx_repository:my_tag
- Push the image
docker push de.icr.io/xxx_namespace/xxx_repository:1
'''
docker push de.icr.io/xxx_namespace/xxx_repository:1
The push refers to repository [de.icr.io/xxx_namespace/xxx_repository:1]
1: digest: sha256:5c2d1c82f9ecc3c3f3b3a4a50f6db9d09cdddb301f3eff37ff2116aa3a65ae10 size: 861
- Verify that your image is in your private registry
ibmcloud cr image-list
'''
Listing images...
Repository Tag Digest Namespace Created Size Security status
de.icr.io/xxx_namespace/aam_repository 1 5c2d1c82f9ec xxx_namespace 10 months ago 2.5 kB -
Create a Project in Code Engine
- Select Code Engine in the left side menu in the IBM Cloud resources dashboard (https://cloud.ibm.com/codeengine/overview)
- Select Projects in the left side menu, select the Location and Resource group, optionally set Tags and hit the Create button
- Once the project is created, enter the project
Create an application from a private GitHub repository
Inside the Project click on Application on left side menu
In the application creation settings dialog box, set the values and hit the Specily build details button
The URL of a private repository is not HTTPS but GIT! The documentation could be found at: https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories
- Specify the details as in the example below
- The Code repo URL (private repo name provided in the previous step)
- The Code repo access (How to create a SSH Key for yoru GitHub account) (or a good article on how to set-up a SSH Key for GitHub: https://leangaurav.medium.com/setup-ssh-key-with-git-github-clone-private-repo-using-ssh-d983ab7bb956)
- Hit Next
- Specify the build details and hit Next
- You see the Registry server. You can either let Code Engine generate a secret for the registry or build your own secret (refer to IAM documentation on IBM Cloud). Choose the right Namespace for your application deployment and you can let Code Engine manage the Repository (image name). Hit the Done button to start building your application.
- Once your application is deployed and running you can access it through the interface! You're done, congrats!!!
Links and helpers
- Code Engine documentation: https://cloud.ibm.com/docs/codeengine
- Install IBM Cloud Code Engine CLI: https://cloud.ibm.com/codeengine/cli
- Creating API Keys on IBM Cloud: https://cloud.ibm.com/iam/apikeys
Posted on February 29, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
February 29, 2024