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. Refer Install and Configure Harness CLI doc to setup and configure Harness CLI.

  2. Clone the Forked harnesscd-example-apps repo and change directory.

    git clone https://github.com/GITHUB_ACCOUNTNAME/harnesscd-example-apps.git
    cd harnesscd-example-apps/deploy-own-app/gitops
    note

    Replace GITHUB_ACCOUNTNAME with your GitHub Account name.

  3. 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 you 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.

  1. Before proceeding, store the Agent Identifier value as an environment variable for use in the subsequent commands:

    export AGENT_NAME=GITOPS_AGENT_IDENTIFIER

    Note: Replace GITOPS_AGENT_IDENTIFIER with GitOps Agent Identifier.

  2. Create a GitOps Repository.

    harness gitops-repository --file deploy-own-app/gitops/repository.yml apply --agent-identifier $AGENT_NAME

    If you intend to use a private Git repository that hosts your manifest files, create a Harness secret containing the Git personal access token (PAT). Subsequently, create a new GitOps Repository pointing to your private repo.

  3. Create a GitOps Cluster.

    harness gitops-cluster --file deploy-own-app/gitops/cluster.yml apply --agent-identifier $AGENT_NAME
  4. Create a GitOps Application.

    harness gitops-application --file deploy-own-app/gitops/application.yml apply --agent-identifier $AGENT_NAME

    To deploy your own app, modify repoURL and path in the application.yml.

  5. At last, it's time to synchronize the application with your Kubernetes setup.

  • Navigate to Harness UI > Default Project > GitOps > Applications, then click on gitops-application. Choose Sync, followed by Synchronize to kick off the application deployment.

    • Observe the Sync state as Harness synchronizes the workload under Resource View tab.

    • 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.

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.