Skip to main content

Deploy your own microservice application

This tutorial is a continuation of the Kubernetes Manifest tutorial. In that tutorial, we guided you through creating a sample pipeline using the Guestbook sample app. In this tutorial, we'll walk you through deploying your own microservice app with the Harness CD pipeline or GitOps workflow.

Sock Shop, developed by Weaveworks, serves as a polyglot architectural pattern to showcase microservices-based deployments. This application suite integrates a range of technologies, such as SpringBoot, Go, REDIS, MYSQL, MongoDB, among others. We've chosen the Sock Shop as our demonstration app for the deployment process in Harness.

You can use the same steps to integrate and deploy your own microservice app.

You can choose to proceed with the tutorial either by using the command-line interface (Harness CLI) or the user interface (Harness UI).

Before you begin

Verify that you have the following:

  1. A Kubernetes cluster. We recommend K3D for installing the Harness GitOps Agent and deploying a sample application in a local development environment.
  2. Fork the harnesscd-example-apps repository using the GitHub web interface to utilize the Harness resource YAMLs.

Getting Started with Harness GitOps

  1. Login to Harness.
  2. Select Projects, and then select Default Project.
  3. Select Deployments, and then select GitOps.

GitOps Agent

  1. You have the option to use the same agent that you deployed during the Manifest tutorial or to deploy a new agent by following the steps below. However, remember to use a newly created agent identifier when creating repositories and clusters.
    • Select Settings, and then select GitOps Agents.
    • Select New GitOps Agent.
    • When are prompted with Do you have any existing Argo CD instances?, select Yes if you already have a Argo CD Instance, or else choose No to install the Harness GitOps Agent.
  • Select No, and then select Start.

  • In Name, enter the name for the new Agent ownappagent

  • In Namespace, enter the namespace where you want to install the Harness GitOps Agent. Typically, this is the target namespace for your deployment.

    • For this tutorial, let's use the default namespace to install the Agent and deploy applications.
  • Select Continue. The Review YAML settings appear.

  • This is the manifest YAML for the Harness GitOps Agent. You will download this YAML file and run it in your Harness GitOps Agent cluster.

    kubectl apply -f gitops-agent.yml -n default
  • Select Continue and verify the Agent is successfully installed and can connect to Harness Manager.

Repositories

  1. Select Settings, and then select Repositories.
    • Select New Repository.
    • Choose Git.
      • Enter a name in Repository: ownapp_repo.
      • In GitOps Agent, select the Agent that you installed in your cluster and select Apply.
      • In Git Repository URL, paste https://github.com/microservices-demo/microservices-demo.
      • Select Continue and choose Specify Credentials For Repository.
        • Select HTTPS as the Connection Type.
        • Select Anonymous (no credentials required) as the Authentication method.
        • Select Save & Continue and wait for Harness to verify the connection.
        • Finally, select Finish.

Clusters

  1. Select Settings, and then select Clusters.
    • Select New Cluster.
      • In Name, enter a name for the cluster: ownnapp_cluster.
      • In GitOps Agent, select the Agent you installed in your cluster, and then select Apply.
      • Select Continue and select Use the credentials of a specific Harness GitOps Agent.
      • Select Save & Continue and wait for the Harness to verify the connection.
      • Finally, select Finish.

Applications

  1. Select Applications.

    • Select New Application.

      • Enter the Application Name: sockshop.
      • In GitOps Agent, select the Agent that you installed in your cluster and select Apply.
      • Select New Service, and then toggle to YAML to use the YAML editor.
      • Select Edit YAML, paste in the YAML below, and then select Save.
      service:
      name: ownapp_service
      identifier: ownappservice
      serviceDefinition:
      type: Kubernetes
      spec: {}
      gitOpsEnabled: true
      • Select New Environment, and the toggle to YAML to use the YAML editor.
      • Select Edit YAML, paste in the YAML below, and then select Save.
      environment:
      name: ownapp_env
      identifier: ownappenv
      description: ""
      tags: {}
      type: PreProduction
      orgIdentifier: default
      projectIdentifier: default_project
      variables: []
      • Next, select Continue, keep the Sync Policy settings as is, and select Continue.
      • In Repository URL, select the Repository you created earlier, and then select Apply.
      • Select master as the Target Revision, type deploy/kubernetes in the Path, and then select Enter.
      • Select Continue and select the Cluster created in the above steps.
      • In Namespace, enter the target namespace for Harness GitOps to sync the application.
      • Enter default and select Finish.
  2. Finally, it's time to Synchronize the GitOps Application state. Select Sync, check the Application details, and then select Synchronize to initiate the deployment.

    • After a successful execution, you can check the deployment on your Kubernetes cluster using the following command:

      kubectl get pods -n sock-shop
    • Sock Shop is accessible via the master and any of the node urls on port 30001.

A successful Application sync will display the following status tree under Resource View.

Congratulations!🎉

You've just learned how to use Harness GitOps to deploy an application using a Kubernetes manifest.

Keep learning about Harness GitOps. Create a GitOps ApplicationSet and PR Pipeline in Harness GitOps by following this guide.