By following three easy steps, you'll learn how to migrate your Cloud Foundry applications to Docker containers on IBM Cloud Kubernetes Service.
The IBM Cloud Kubernetes Service delivers powerful tools by combining Docker containers, the Kubernetes technology, an intuitive user experience, and built-in security and isolation to automate the deployment, operation, scaling, and monitoring of containerized apps in a cluster of compute hosts.
If you have any Cloud Foundry applications, you can migrate them to Docker containers on the IBM Cloud Kubernetes Service. There are many ways to do this, but I'm going to show you the simplest way by using the IBM Cloud Continuous Delivery service.
- IBM Cloud account
- IBM Cloud Container Registry service to store your Docker images
- IBM Cloud Continuous Delivery, which includes open toolchains
- IBM Cloud Kubernetes Service
- Prepare the source code for a Cloud Foundry application.
- Create a new toolchain for deploying a Kubernetes app.
- Configure the Delivery Pipeline for deploying a Kubernetes app.
1. Prepare the source code for a Cloud Foundry application
When you have your source code, it should look like this:
- GitHub repository URL: https://github.com/(account)/(project)
- GitLab repository URL: https://us-south.git.cloud.ibm.com/(account)/(project)
2. Create a new toolchain for deploying a Kubernetes app
The IBM Cloud Continuous Delivery service includes open toolchains that automate the building and deployment of applications. You will need to create a new toolchain to deploy a Kubernetes app with the source code.
- From the IBM Cloud console, click the Menu icon and select DevOps.
- On the DevOps dashboard, on the Toolchains page, click Create a Toolchain.
- On the Create a Toolchain page, click the toolchain template Develop a Kubernetes app.
- On the Develop a Kubernetes app page, type in the Toolchain Name.
- In the Tool Integrations section, select the Repository type (Clone), enter the Source repository URL (https://cloud.ibm.com/conapi/template/nodejsHelloWorld/download/starter_code), and type a new Repository Name. This indicates the source repository is cloned into your source repository. If you want, you can type the source repository URL for your Cloud Foundry app.
- In the Tool Integrations section, click Delivery Pipeline, put in the App name, and type the existing IBM Cloud API key or click the New button to create a new key.
- Enter the Container registry region and Container registry namespace where the Docker image is stored.
- Select the Cluster region, Resource Group, Cluster name, and Cluster namespace where the app is deployed.
- Confirm your updates by clicking Create.
Several steps will run automatically to set up your toolchain.
- The toolchain is created.
- The source repository is cloned into your source repository.
- The delivery pipelines are created and triggered.
3. Configure the delivery pipeline for deploying a Kubernetes app
- Once the toolchain is created, your toolchain Overview is displayed. Click the Delivery Pipeline panel to access the delivery pipeline stages (BUILD, CONTAINERIZE, and DEPLOY). Let's see if a Kubernetes app deployed.
- Wait a sec! You see that the Check dockerfile job failed in the CONTAINERIZE stage. Click the job to see the log.
- This is because a file named Dockerfile was not found in the source repository. Dockerfile is the instruction to build a Docker image automatically, and you just need to add a Dockerfile by following the instructions here.
- Go back to the Toolchain page and click the Git panel to access your source code in the repository.
- Add a new file named Dockerfile, copy the following code, and paste it into the file. Then click Commit.
- Go back to the Toolchain page, click the Delivery Pipeline panel to access the delivery pipeline stages.
- Because you committed the change in the source repository, it triggered to run the Delivery Pipeline. After about 10 minutes, you will see that all pipeline stages (BUILD, CONTAINERIZE, and DEPLOY) passed. Click the Deploy to Kubernetes job in the DEPLOY stage to see the Stage History.
- As you can see from the Stage History for the Deploy to Kubernetes Job in the DEPLOY stage, the initial deployment.yaml is automatically created because there is no deployment.yaml in the source repository. You can create a deployment.yaml file in the source repository to define how you deploy apps to containers on the Kubernetes cluster and add it in the repository for your requirement. See more details here.
- You will see the message Finished: SUCCESS in the DEPLOY stage. Click the VIEW THE APPLICATION AT: http://188.8.131.52:30001/. The app is exposed with a NodePort service in the format http://<IP_address>:<nodeport>.
- The application is successfully deployed as a Kubernetes app. You're now able to access the application running on the Kubernetes service.
By following these steps, you're now able to migrate Cloud Foundry applications to Docker containers on IBM Cloud Kubernetes Service. In doing so, you expose the app with a NodePort service in the format http://<IP_address>:<nodeport>.
If you use a standard cluster, you can create the ingress resource to route traffic to your app service so that you can expose apps with the IBM-provided domain or a custom domain—also HTTPS and TLS/SSL authentication in the format https://<yourcustom.domain.net>. Learn more about the ingress resource.