Launch Darkly and Harness: Feature Flags and Continuous Delivery

Hi there, community!

I thought it’d be helpful to discuss feature flag management here and how it relates to software delivery.

At Harness, we’re in the business of empowering developers to move fast without breaking things allowing them to focus on development work that matters.

Part of that development work involves not only the development of code but also the testing and integration of those features into the products and services that we ship today. There are many challenges that long-running feature work face when it comes to delivering fast. Merge conflicts arise for long-lived development branches, and often, features require manual testing. Continuous Delivery allows us to deploy artifacts into testing environments repeatedly and reliability, feature flags avoids having to redeploy in order to enable a feature for testing.

Here’s a short guide to how to use LaunchDarkly for Feature Flag management with Harness.

Getting Started with LaunchDarkly

To get started add the LaunchDarkly SDK to your codebase. This will give us feature flag management capabilities. I used the Launch Darkly quickstart to add an SDK to a simple tic-tac-toe web application.

Here is what is required for my simple web application.

  1. Add the following snippet to the <head> element:
    <script src=""></script>
  2. Add a script element in the body element, and add some code to call LaunchDarkly:
  var user = {
    firstName: 'Bob',
    lastName: 'Loblaw',
    custom: {
      groups: 'beta_testers'

  var div = document.createElement('div');


  var ldclient = LDClient.initialize('YOUR_CLIENT_ID_HERE', user);

  function render() {
    var shouldShow = ldclient.variation('replace_me_with_ff_key', false);
    var label = (shouldShow ? 'Showing' : 'Not showing') + ' your feature to ' + user.key;
    div.replaceChild(document.createTextNode(label), div.firstChild);

  ldclient.on('ready', render);
  ldclient.on('change', render);

You may use the SDK how you see fit. The shouldShow variable here evaluates True or False given the feature flag toggle.

Now we are ready to test and deploy our application.

Harness streamlines the feature flag management process

Testing in production or even in a QA environment can be difficult if the deployment is not consistent. I enjoyed setting up a deployment pipeline, which would automatically deploy to my minikube environment which was running locally on my machine. Alternatively, I can use my Harness pipeline to deploy to any environment or cloud provider and platform.

Harness Prerequisites:

  1. Setup a cloud provider. Ensure you have a Harness Delegating running in your environment.
  2. Under Connectors → Artifact Servers ensure you have added an artifact server with valid credentials. Here I have added my public Docker registry. I also set up a build process using GitHub Actions for CI to build a Docker image and push the artifact into the Docker registry. You may create this docker image manually or leverage Drone, Jenkins, or any other CI tool to produce the deployable artifact.

Now that we have entered valid credentials for setup, let’s create a Harness deployment.

Here is how I did this:

  1. Under Setup, create a new application. Here I called my tictactoe. We will use this tictactoe application to specify the services to be deployed. Alongside the target environment and the steps need to define the workflow.

  1. Select Services and create a new service. Here I am adding the details for my Kubernetes based service, which is a docker image living in my docker registry.

  1. Now create an environment for the tictactoe application. Here I am creating a production environment for my application, which will deploy to my minikube cluster the tictactoe service.

  2. Create a Kubernetes deployment workflow to capture these steps and deploy the deployable artifact.

  3. Hit the deploy button to trigger the deployment. You will be prompted to select the artifact version before deploying the application.

  4. Review the deployment details.

If the deployment succeeds access your application to test your application.

I have my application feature flag turned off here, but I turn it on through the LD dashboard.

Alternatively, you may configure the Harness workflow to call the LD API and trigger the feature toggle: This works alongside any other API capabilities exposed by LaunchDarkly.

The flexible workflows are great because you can easily set up additional functionalities to your deployments, such as a trigger mechanism based on a code commit or new artifact. Your feature flag testers can get to testing faster.

Feature Flags require deployments

This was a short guide to how to use LaunchDarkly and Harness. In summary, use feature flags to do the following:

  • Enable Long-running feature work
  • Avoid merging long-lived development branches
  • Manually test a feature

Harness’s CI/CD platform enables developers to do the work that matters to them. I hope this post serves as a reference for those doing feature development. Code on. :slight_smile:

Launch Darkly Documentation for triggering a feature toggle--

1 Like