Add Kubernetes Manifests

Updated 2 months ago by Michael Cretzman

Harness provides a simple and flexible way to use Kubernetes manifests.

You can simply link to your remote files in a Git repo. At deployment runtime, Harness fetches and applies your files.

You can use Go templating in your files. Multiple values.yaml files can contain specific deployment settings, such as QA and Production values, and then you can template and reuse your manifest files.

This topics provides a quick overview or some options and steps when using Kubernetes manifest, with links to more details.

In this topic:

Before You Begin

Review: Artifacts and Manifests in Harness

If a public Docker image location is hardcoded in your Kubernetes manifest (for example, image: nginx:1.14.2) then you can simply add the manifest to Harness and the Harness Delegate will pull the image during deployment.

Alternatively, you can also add the image location to Harness as an Artifact in the Service Definition. This allows you to reference the image in your manifests and elsewhere using a Harness expression.

When you deploy, Harness connects to your repo and you select which image and version/tag to deploy.

With a Harness Artifact, you can template your manifests, detaching them from a hardcoded location. This makes your manifests reusable and dynamic.

To add a container image to Harness as an Artifact, you add a Harness Connector for your repository and then add the container image as an Artifact source. In your manifests (or values.yaml), you simply add a Harness expression where you would normally hardcode the location.

See Add Container Images as Artifacts for Kubernetes Deployments.

Step 1: Start a Pipeline

This topic assumes you have a Harness Project set up. If not, see Create Organizations and Projects.

You can create a Pipeline from any module in your Project, or in the Project Overview, and then add stages for any module.

Enter a name for the Pipeline and click Start. Now you're ready to add a stage.

Step 2: Add Deploy Stage

For steps on adding a stage, see Add a Stage.

When you add a stage, select Deploy.

Name the stage, and select what you'd like to deploy. For example, select Service.

Click Set Up Stage.

The new stage's settings appear.

Click Next or Service.

Step 3: Create the Harness Service

In Service, you can define/select the Service and Service Definition.

Let's take a moment and review Harness Services and Service Definitions (which are explained below). Harness Services represent your microservices/apps logically.

You can add the same Service to as many stages are you need. Service Definitions represent your artifacts, manifests, and variables physically. They are the actual files and variable values.

By separating Services and Service Definitions, you can propagate the same Service across stages and change artifacts, manifests, and variables with each stage.

Select or create the Service.

To add your manifests, go to Manifests in the Service Definition.

Step 4: Add Kubernetes Manifests

You can use your Git repo for the configuration files in Manifests and Harness will use them at runtime.

If you are adding the image location to Harness as an Artifact in the Service Definition, see Add Container Images as Artifacts for Kubernetes Deployments.

In Manifests, click Add Manifest.

In Specify Manifest Type, select K8s Manifest, and then click Next.

In Specify K8s Manifest Store, select the Git provider. In this example, click GitHub, and then select or create a new GitHub Connector. See Connect to Code Repo.

Click Continue. Manifest Details appears.

In Manifest Identifier, enter an Id for the manifest. It must be unique. It can be used in Harness expressions to reference this manifests settings.

For example, if the Pipeline is named MyPipeline and Manifest Identifier were myapp, you could reference the Branch setting using this expression:

<+pipeline.stages.MyPipeline.spec.serviceConfig.serviceDefinition.spec.manifests.myapp.spec.store.spec.branch>

In Git Fetch Type, select Latest from Branch of Specific Commit ID, and then enter the branch or commit ID for the repo.

For Specific Commit ID, you can also use a Git commit tag.

In File/Folder Path, enter the path to the manifest file or folder in the repo. The Connector you selected already has the repo name, so you simply need to add the path from the root of the repo.

Click Submit. The manifest is added to Manifests.

Other options:

  • Helm chart from Git or HTTP Helm repository: a Helm chart repository is an HTTP server that houses an index.yaml file and, if needed, packaged charts. For details, see  The Chart Repository Guide from Helm.
    See Helm CD Quickstart.

Option: Skip Resource Versioning

By default, Harness versions ConfigMaps and Secrets deployed into Kubernetes clusters. In some cases, you might want to skip versioning.

When you enable Skip Resource Versioning, Harness won't perform versioning of ConfigMaps and Secrets for the deployment.

If you've enabled Skip Resource Versioning for a few deployments and then disable it, Harness will start versioning ConfigMaps and Secrets.

Step 5: Add Values YAML Files

You add values.yaml files in the same way you added you manifests. You simply select Values YAML in Specify Manifest Type.

In Manifest Details, you enter the path to each values.yaml file.

Your values.yaml file can use Go templating and Harness built-in variables in combination in your Manifests files.

See Example Kubernetes Manifests using Go Templating.


Please Provide Feedback