Deploying Apps to K8s From CircleCI With Cloud Foundry

Deploying applications to Kubernetes has been known to stress out software development teams because of the complexity of Kubernetes and its steep learning curve.

Cloud Foundry has solved this problem with the open source Cloud Foundry for Kubernetes ( project that allows developers to deploy their applications to a Kubernetes cluster without having to use Kubernetes directly. All a developer/team needs to deploy their applications to Kubernetes with Cloud Foundry is to deploy on whatever infrastructure they want, and then with the power of cf push, developers can easily deploy their applications with a single command.

DevOps Dozen 2023

Consistent with modern software development practices, an ideal software development team makes use of CI/CD platforms to ensure that their software development life cycle is in check and monitored at all times. This is easy for Cloud Foundry, as it is so flexible that it can integrate with most CI/CD platforms very easily.

In this tutorial, we will use as an example how one popular open source CI/CD platform, CircleCI, works with Cloud Foundry to empower software development teams to provide the best possible developer experience both during CI/CD and deployment to Kubernetes. How is this possible? You can maximize the performance of CircleCI and then use Cloud Foundry to deploy your application from CircleCI to Kubernetes with ease. The combination of Cloud Foundry and CircleCI gives developers more time to focus on building the actual product rather than spending so much time on platform operations.


To be successful with this tutorial you need to have:

  • A running Kubernetes cluster on any infrastructure of your choice
  • Cloud Foundry for Kubernetes installed and available in that cluster
  • Your application code available in a GitHub repository.

Getting started

In this tutorial, we will use CircleCI and Cloud Foundry for Kubernetes by writing a pipeline job in our CircleCI config.yml file, and we’ll also make use of the Cloud Foundry Orb, created by the CircleCI team, to make the process even easier. This process will help us deploy our application to the Kubernetes clusters we have created.

Before getting started, we need to connect our GitHub account to CircleCI by signing up. You can do that by following these steps.

  • Go to the CircleCI website
  • Click on Signup and authenticate with the GitHub account where your project code resides
  • Select the organization or account where the code resides
  • Click on the Set up Project button in the CircleCI dashboard.

You’ll then be shown an editor, which is where we’ll write our CircleCI configuration.

You can find the sample application for this tutorial here.

Getting CircleCI Ready for the Deployment

We will need to set up a bunch of environmental variables in our project for CircleCI to connect and deploy our applications with Cloud Foundry through the jobs we’ll write or use the Cloud Foundry orb. You can define these environmental variables by going to your project settings page, clicking Environment Variables in the column on the left, and then Add Variable.

The Environmental variables we’ll be making use of for the purpose of this tutorial include:

  • CF_API – This is the API endpoint that connects to the Cloud Foundry instance we’ve installed on a Kubernetes cluster.
  • CF_USERNAME – This is the username we set for the Cluster we have Cloud Foundry running on.
  • CF_PASSWORD – This is the password we set for the Cluster we have Cloud Foundry running on.
  • CF_ORG – This holds the organization in our Cloud Foundry instance.
  • API_KEY – This is specific to the sample application we are using.
  • CONVERTER_API_KEY – This is specific to the sample application we are using.
  • SYMBOLS – This is specific to the sample application we are using.

Setting up the CircleCI pipeline

For CircleCI and Cloud Foundry to work, we need to define the pipeline structure inside the config.yml file that was created when we set up CircleCI on our project.

This configuration will help us:

  • Checkout our application code
  • Install and login to our Cloud Foundry cluster
  • Deploy the application through Cloud Foundry to Kubernetes

Here is the config.yml we are using:

kubernetes k82 CircleCI

Deploying With Cloud Foundry

Now, to deploy to Kubernetes with Cloud Foundry, we need to commit the changes we’ve made, and CircleCI will automatically run the deployment job we’ve written.

When the pipeline has finished executing successfully, we can see that our application has been successfully deployed, and we can also access the application in our terminal by running:

kubernetes k8s CircleCI

With the Cloud Foundry CLI, developers and teams have access to various commands that can give us more information about the app we have deployed, including:

  • Logs
  • Application routes
  • Managed services
  • Scaling options etc.

To view the application deployed by Cloud Foundry, apart from using the Cloud Foundry CLI in your terminal, all you need to do is to go into the jobs UI and find the route that was generated.

kubernetes k8s CircleCI

Deploying with CirceCI Cloud Foundry Orb

If you’re looking for a method that allows you to deploy to Cloud Foundry with less lines of Configuration, you can use the Cloud Foundry Orb that automates a number of steps. To do that:

  • Checkout our application code
  • Set up Cloud Foundry
  • Deploy the application through Cloud Foundry.

Here is what the config.yml looks like:

Now, to deploy to Kubernetes with Cloud Foundry, we need to commit the changes we’ve made and CircleCI will automatically run the deployment job we’ve written with the Cloud Foundry Orb.

We’ve just seen how powerful Cloud Foundry is when it comes to delivering application code on Kubernetes from any CI/CD platform — using the example of CircleCI. This tutorial provides an introduction to deploying applications to Kubernetes with Cloud Foundry from CircleCI. The result is a highly efficient and modern means of cloud-native application delivery over Kubernetes-based infrastructure.

For more information, please visit The best way to connect with the Cloud Foundry community is to join our Slack Workspace at Those in the Slack community will help you get answers to any queries you may have about using Cloud Foundry.

Shedrack Akintayo

Shedrack Akintayo is a Developer Advocate and software developer from Lagos, Nigeria, who has a love for community building, open source, creating content, and software for the next billion users. As a technical writer and speaker, he shares his knowledge about JavaScript, React, and building APIs. Shedrack is passionate about learning, growing and helping local developer communities to plan and organize events. In his free time he loves music, Bollywood movies and playing football (known as soccer in the U.S.).

Shedrack Akintayo has 2 posts and counting. See all posts by Shedrack Akintayo