January 6, 2020

Continuous Delivery with Pivotal Cloud Foundry (CF)

Table of Contents

Key takeaway

We learned in part one of this PasS series about Platforms-as-a-Service andthe competition thas PaaS solutions face within the Kubernetes ecosystem. Leveraging Harness with a PaaS can certainly supercharge you and your organization with benefits of Continuous Delivery and efficient application infrastructure deployment. In part three of our blog series, we will be leveraging a Pivotal Stack with Harness. Get ready to dive in!

Dive on In

If you don’t have access to PaaS infrastructure, don’t worry. OpenShift and Pivotal Cloud Foundry have online platforms that you can learn on for free. In the following example, we will leverage Pivotal Web Services [formally Pivotal Cloud Foundry Foundations] and an Amazon EC2 Centos instance for the Harness Delegate. Like always can following along with the blog and/or watch the video to get your learn on.

Harness Continuous Delivery - Pivotal Cloud Foundry

The first step is to sign up for a Pivotal Web Services account. The signup process is easy just to provide an e-mail address and mobile number for two-factor authentication. You’ll create an Organization [here I called ours CaptainCanary] and can use the default Space [development] if desired.

Pivotal Web Services - Harness Continuous Delivery

Once that is set up, we can start to set up wiring between your PCF Cluster and the Harness Platform. The Harness Delegate is the worker node in the Harness Platform that runs your commands for you.Setting up a delegate is pretty simple. Log into your Harness Account or sign up for a Harness Account.

Harness Continuous Delivery Dashboard - Product Shot

I typically run my Delegate on an Amazon EC2 instance. Having just spun up a fresh Centos EC2 instance, we first need to get the Harness Delegate installed. The easiest way is to log into a Harness Account, then go to Setup -> Harness Delegates -> Download Delegate. Click on the Copy icon for the Shell Delegate Download.

Download Delegate - Harness Continuous Delivery - Shell Script

With copying that command (a curl), we can simply paste that command into an awaiting Centos instance.

Command Centos Instance - Harness Continuous Delivery

Can untar the Harness Delegate download with tar -xvf harness-delegate.tar.gz

Harness Delegate - Harness Continuous Delivery

Lastly, CD into the harness-delegate folder and run ./start.sh and soon the Harness Delegate will be installed. For this example on an EC2 Centos Instance, we don’t need to modify ulimit since it’s just us.

Harness Delegate - Harness Continuous Delivery

Sweet, success! After the install, we can validate in the Harness Web UI that our Delegate is there.

Harness Web UI - Harness Continuous Delivery

Time for the Cloud Foundry Command Line Interface [CF CLI]. There are a few ways to go about installing the Cloud Foundry CLI. You will need to get the Harness Delegate EC2 instance wired to the CF CLI. For quick testing of wiring, you can also install the CF CLI on your local machine.On my Mac (local machine), I leverage Homebrew. Installing the CF CLI on my Mac is as simple as running brew install cloudfoundry/tap/cf-cli

Cloudfoundry - Bash - Harness Continuous Delivery

Can validate that the installation was successful with cf -help.

Bash - Harness Continuous Delivery

Next, you will need to log-in with the CF CLI.cf login -a API_URL -u USERNAME -p PASSWORD -o ORG -s SPACENavigate to Tools at the bottom navigation bar in the Pivotal Web Services Console to see what the API endpoint is for your instance.

Pivotal Web Service Dashboard - Harness Continuous Delivery

In the Pivotal Web Services Case run in a terminal on your local machine:cf login -a https://donotuseapi.run.pivotal.io -u USERNAME -p PASSWORD -o “CaptainCanary” -s developmentSuccess!

API endpoint - Harness Continuous Delivery

Next let’s get the CF CLI (remote) installed as part of our Delegate Profile. The Delegate Profile is a great place to have the Harness Delegate installed needed packages for us which runs on the Delegate infrastructure.Back in our Delegate Setup [Setup -> Harness Delegates] can click on Manage Delegate Profiles +Add Delegate Profile

Manage Delegate Profiles - Harness Continuous Delivery

Can leverage the script we have in our documentation to install the CF CLI via a Delegate Profile. Create a Delegate Profile called “CF CLI Install”. The Centos Amazon Machine Image I used to spin up did not come with Wget so can install that easily.

Manage Delegate Profile - Harness Continuous Delivery

#Install CF CLI#Install WGet since AMI does not come withecho "installing wget"sudo yum install wgetecho "adding repo"sudo wget -O /etc/yum.repos.d/cloudfoundry-cli.repo https://packages.cloudfoundry.org/fedora/cloudfoundry-cli.repoecho "installing"sudo yum -y install cf-cliOnce you click submit, can go and run the Profile by hovering over the Profile section of the Delegate Information and selecting “CF CLI Install”.

CF CLI Install - Harness Continuous Delivery

Once applied, you can take a look at the Delegate Profile log output right from the Harness UI by clicking on “View Logs”.

Delegate Profile Execution - Harness Continuous Delivery

Looks good, you can also verify on your Centos (Delegate) instance by running the same command to verify that you used on your local machine with cf -help.

Harness Delegate - Harness Continuous Delivery

You have the infrastructure you need in place now. Next, let’s wire up your Pivotal Web Services account as a Cloud Provider. Navigate to Setup -> Cloud Providers + Add Cloud Provider

Cloud Providers - Harness Continuous Delivery

Add a type “Pivotal Cloud Foundry” with your credentials with a name of “pcf”. Omit the HTTP(S) piece from the endpoint URL.

Pivotal Cloud Foundry - Harness Continuous Delivery

Click test to validate then submit. You now will have “pcf” as a PCF Cloud Provider.

Cloud Providers - Harness Continuous Delivery

Next you will need some sort of application to deploy. An excellent application to test a deployment and see the Pivotal Buildpacks in action is the Tomcat Sample Application from the Tomcat Project. The best way to access the WAR is to download the Sample WAR and publish it to an Artifact Repository of your liking.I am leveraging JFrog Artifactory. If you do not have access to an artifact repository, you can spin one up in a Cloud Provider or leverage your Harness Delegate as an installation location. We can run the Centos installation steps back in a Harness Delegate Profile.Back in our Delegate Setup [Setup -> Harness Delegates] can click on Manage Delegate Profiles +Add Delegate Profile

Manage Delegate Profile - Harness Continuous Delivery

Create a Profile called “Install Artifactory”

Manage Delegate Profile - Harness Continuous Delivery

#Install OpenJDK and Artifactoryecho "installing JDK"sudo yum install java-1.8.0-openjdk-develecho "Installing Artifactory"wget https://bintray.com/jfrog/artifactory-rpms/rpm -O bintray-jfrog-artifactory-rpms.reposudo mv bintray-jfrog-artifactory-rpms.repo /etc/yum.repos.d/sudo yum install jfrog-artifactory-ossecho "Starting Artifactory"sudo service artifactory startOnce saved, you can run the Harness Delegate Profile by going over to Profile and select “Install Artifactory” from the drop-down.

Install Artifactory - Harness Continuous Delivery
Delegate Profile Execution - Harness Continuous Delivery

Once the Delegate Profile has ran, head to the Web UI [usually https://publichostIP:8081/artifactory]. If you are installing on your EC2 Delegate, the IP address is the Public IP of your EC2 instance.The default user is admin and the default password is password.

jFrog Artifactory - Harness Continuous Delivery

Once logged in, can navigate to Admin -> Repositories -> Local. Here you can create a Local Generic Repository.

jFrog Artifactory - Harness Continuous Delivery

Select Generic as the Package Type and name the Repository. I named mine “ravi-generic”.

jFrog Local Repository - Harness Continuous Delivery

Once you hit Submit, the Repository is ready.

New Local Repository - Harness Continuous Delivery

We can now upload the example WAR to Artifactory.Navigate back to Artifacts -> “your-generic-repository” and click Deploy on the right.

Artifact Repository Browser - Harness Continuous Delivery

Upload the sample.war that you have downloaded.

Deploy - Harness Continuous Delivery

Once you click Deploy, you are all set with your artifact.

Repository Path - Harness Continuous Delivery

Next you will need to wire your Artifactory instance to Harness. You will need to get your external IP address to wire this.Navigate to Setup -> Connectors -> Artifact Servers + Add Artifact Server.

Artifact Servers - Harness Continuous Delivery

Add an Artifact Server with type Artifactory and Display Name of “My Artifactory”. For example, my public IP is and the URL for the Artifactory Server in my case will be If you did not modify the user and password, will be the defaults [admin/password].

Artifactory - Harness Continuous Delivery

Click Test and Submit. Once that is successful you will have “My Artifactory” available to you.

Artifactory - Harness Continuous Delivery

PCF Continuous Delivery O’Clock

With the Harness and PCF wiring out of the way, now it is time for us to make some magic with a Harness Deployment.First, let’s create a new Harness Application by going to Setup -> Applications + Add Application. We can call the Application “PCF_Perfection”.

Application - Harness Continuous Delivery

Net let’s add a Harness Service which will represent a deployable. In the PCF_Perfection Application, navigate to Services then + Add Service.

Application - Harness Continuous Delivery

Add a Service as type “Pivotal Cloud Foundry” with the name of “My_PCF”.

PCF Setup - Harness Continuous Delivery

Once you hit Submit, Next you will wire the sample.war as an Artifact Source in the Service.

Add Service - Harness Continuous Delivery

+Add Artifact Source. Add an Artifactory Source from "My Artifactory". In our case, we will wire sample.war which is on the root of the "ravi-generic" repository.

Service Overview - Harness Continuous Delivery

Click submit and the Artifact Source will be there.

Artifact Source - Artifactory - Harness Continuous Delivery

You will need to set up a Harness Environment. Setup -> PCF_Perfection - Environments + Add Environment.

Service Overview - Harness Continuous Delivery

Give the Name “Staging” and set the Environment Type as Non-Production.

Harness Environment Setup - Harness Continuous Delivery

Next in the Staging Environment, you will need to configure an Infrastructure Definition by going to + Add Infrastructure Definition.

Staging - Harness Continuous Delivery

In the Infrastructure Definition, name the Definition “Pivotal Web Services”. Select the Cloud Provider Type as Pivotal Cloud Foundry and the Deployment Type as Pivotal Cloud Foundry. Select the PCF Cloud Provider that was wired before and select/add in your Cloud Foundry Organization and Space details.

Infrastructure Definition - Harness Continuous Delivery

Next, you will add a Harness Workflow. Setup -> PCF_Perfection -> Workflows +Add Workflow

Harness Workflow - Harness Continuous Delivery

Add a Workflow with Name “Basic PCF” and a Workflow Type as Basic Deployment. Match the Environment, Service, and Infrastructure Definition to what was created.

Workflow - Harness Continuous Delivery

Once you hit Submit, modify the App Resize step under Deploy. Will aim for 100% desired instances.

Deploy - Harness Continuous Delivery
App Resize - Harness Continuous Delivery

Once you hit Submit, your Workflow will look like below.

Basic PCF - Harness Continuous Delivery

Next, you will add a Harness Pipeline by going to Setup -> PCF_Perfection -> Pipelines + Add Pipeline

Harness Pipeline - Harness Continuous Delivery

Add a Harness Pipeline called “Simple PCF”.

Add Pipeline - Harness Continuous Delivery

Add Pipeline Stage named “Go for Gold”. Execute your PCF Workflow you created.

Pipeline Stages - Harness Continuous Delivery
Execution Step - Harness Continuous Delivery

Once you hit Submit, you will have a one stage Pipeline.

Stage Pipeline - Harness Continuous Delivery

Now for where the rubber meets the road, time to run your Pipeline! Navigate to Continuous Deployment -> Start New Deployment

Deployment - Harness Continuous Delivery

Select the PCF_Perfection Application and appropriate Build / Version [if using sample.war, just sample.war].

Start New Deployment - Harness Continuous Delivery

Click Submit and watch the magic happen!

Deployment - Harness Continuous Delivery - Product Shot

Once the magic happens, can navigate back to the Pivotal Web Services Console and click on the Route.

Pivotal Web Services Product Shot

After clicking on the route, sit back and enjoy the app.

Success - Harness Continuous Delivery

Congratulations on wiring a very modern Continuous Delivery pipeline!

Harness and PaaS’s, Better Together

Over the first and second part of the blog series, we learned a good deal about PaaS’s. The PaaS market continues to evolve as technology moves forward. There is a convergence towards Kubernetes in the PaaS vendor landscape. A PaaS can provide great value to your organization and coupled with the power of Harness, engineering efficiency can be taken to the next level. As always feel free to sign up for Harness and take this example for a spin.Cheers!-Ravi

You might also like
No items found.

Similar Blogs

No items found.
Continuous Delivery & GitOps