Skip to main content

Getting Started with Harness AI

Last updated on

Harness AI lets you generate Harness platform resources like pipelines, services, environments, connectors, and Cloud Cost Management (CCM) perspectives using natural language prompts. Use these example prompts to quickly create configurations inside Harness by copying and adjusting values for your environment.


What will you learn in this topic?

By the end of this topic, you will be able to:


Before you begin

Before you use these example prompts, ensure you have the following:

  • Harness AI enabled: Harness AI must be active for your account. Go to Overview for more information on activating Harness AI.
  • Project access: Permission to create and manage resources (pipelines, services, environments, connectors) in your Harness project.
  • Connector names: Know the names of your configured connectors (Git, Docker, Kubernetes, cloud providers) to reference in prompts.

Use prompts

Learn how to customize and use these example prompts effectively.

For DevOps, pipeline, and platform automation use cases

  1. Navigate to your Harness project and open Harness AI.
  2. Copy an example prompt from this page and adjust values such as connector names, namespaces, repository names, and deployment strategies.
  3. Review the generated YAML configuration, save it, and run your pipeline.
Recommendation

Be specific in your prompt. Include details like deployment strategy, connector names, namespaces, and image tags for best results.

For Cloud Cost Management use cases

  1. Navigate to Harness AI in CCM.
  2. Copy an example prompt and adjust parameters for your cloud environment.
  3. Review the generated configuration before creating the perspective.

Example prompts for DevOps

Use these example prompts to create pipelines, services, environments, connectors, and other DevOps resources.

Create pipelines

Pipelines define how you build, test, and deploy applications. Harness AI can generate CI pipelines, CD pipelines, or hybrid flows with approvals and rollouts.

Use case: Combine security scanning into the CI/CD process for Python applications.

Generate a Harness CI to CD pipeline that builds a Docker image and pushes to Dockerhub. Add a CD stage to deploy a Kubernetes service to namespace dev on cluster connector k8s-dev. Include variables for IMAGE_TAG and REPLICA_COUNT, and output only valid YAML

Use case: Enable GitHub PR validation and continuous delivery on merge events.

Create a pipeline that runs unit tests for python, builds with Dockerfile, scans image with semgrep and deploys to staging using a Rolling strategy. Use GitHub connector rohan-git, Docker connector harness docker hub, and K8s connector k8s-dev.

Use case: Generate a PR-triggered pipeline with conditional deployment.

Generate a PR-triggered pipeline: on pull_request to main, run a pylint command plus python test command, post summary to GitHub Checks, and skip CD. On merge to main, promote image harness:latest and deploy to dev. Use runtime inputs for tag.

Use case: Create a standard enterprise promotion pipeline with manual approvals and safer canary rollout.

Create a multi-environment pipeline with a single CI stage and two CD stages: staging to production with a manual approval gate and canary rollout in prod. Parameterize SERVICE_NAME, IMAGE, REPLICAS.

Use case: Enable parallel testing across multiple Python versions plus Helm-based deployment.

Create a pipeline that uses cache, parallel matrix builds for python versions 2, 3, 3.2, publishes artifacts to harness:docker, and then deploys a Helm chart with values file values-dev.yaml.

Create services

Services define what you deploy, including application configuration, runtime, and artifacts. Harness AI can generate service definitions for Kubernetes, ECS, Lambda, and more.

Use case: Standardize Kubernetes services using Helm.

Generate a Kubernetes service definition named portal using Helm with chart path /cd/chart/portal. Expose variables: IMAGE, TAG, REPLICA_COUNT. Include artifact reference to <+input> and config files section.

Use case: Build serverless microservices with runtime and configuration.

Create a serverless (AWS Lambda) service named router with runtime nodejs18.x, artifact from <+input>, and environment variables LOG_LEVEL, STAGE.

Use case: Create an ECS-based deployment with resource settings and logging integrations.

Define an ECS service named payments using task def family prod-payment, container harness/payment, CPU 0.25/MEM 2GB, and image harness/payment:latest. Configure logging to CloudWatch group prod_log.

Create environments

Environments represent where applications run, such as dev, staging, and prod. Harness AI can generate environment definitions for you.

Use case: Create a non-prod environment to test services.

Generate an Environment named staging (type: PreProduction)

Use case: Create a production environment to deploy services.

Create a Production environment named prod

Create secrets

Create secrets to store sensitive information like credentials and tokens.

Important security notes

  • When creating secrets, Harness creates the secret object without a value.
  • You must navigate to the created secret in the listing page to provide the value.
  • Harness does not send secret values to the AI model. Sensitive data is stripped before any AI request.

Use case: Create a reusable DockerHub token secret for image pulls.

Create a Secret Text named docker-hub-token. Store in default Secret Manager.

Create connectors

Connectors integrate Harness with external systems such as Git, Docker, AWS, and Vault. Harness AI can help generate connector definitions.

Use case: Automate DockerHub connector creation tied to secrets.

Generate a Docker Registry connector named canary-docker pointing to harness/canary with credentials from secret refs usernameRef: canary and passwordRef: docker-hub-token.

Use case: Simplify Vault integration for secret management.

Create a HashiCorp Vault connector, called dev-vault and default the rest of the values

Use case: Enable IRSA-based AWS authentication via Harness delegate.

Produce an AWS connector using IRSA with role ARN and delegate selectors.

Create IaCM pipelines

Harness AI DevOps Agent can create Infrastructure as Code Management (IaCM) pipelines for provisioning and managing infrastructure using Terraform and other IaC tools.

Use case: Provision cloud infrastructure with Terraform via an IaCM pipeline.

Create an IACM Pipeline that provisions AWS Infrastructure with the IACM Steps.

Use case: Manage a Terraform workspace through a pipeline.

Build a pipeline with an IACM stage to manage my Terraform workspace.

Use case: Create a Terraform plan and apply workflow.

Create a pipeline that runs Terraform plan and apply for my cloud infrastructure.

Create multi-module pipelines

Harness AI supports creating pipelines with stages from multiple Harness modules, including CI, CD, IaCM, IDP, SCS, STO, DB DevOps, and Chaos Engineering.

Use case: Create an end-to-end pipeline with security scanning.

Create a pipeline with a CI stage to build my app, an STO stage to scan for vulnerabilities, and a CD stage to deploy to production.

Use case: Create a pipeline with chaos engineering validation.

Build a pipeline that deploys to staging, runs a Chaos Engineering experiment to validate resilience, then promotes to production with an approval gate.

Use case: Create a database migration pipeline.

Create a pipeline with a DB DevOps stage to run database migrations before deploying the application with a CD stage.

Use case: Create a supply chain security pipeline.

Create a pipeline with an SCS stage to generate SBOM and attestation, followed by a CD stage to deploy to production.

Reference pipeline templates

Templates allow you to standardize steps and stages across multiple pipelines. Harness AI can reference existing templates by name.

Referencing a stage template:

Create a Pipeline with the Deploy to K8s Stage Template.

Referencing a pipeline template:

Create a Pipeline with the Golden K8s Pipeline Template

GitOps operations

Harness AI can manage 13 GitOps resource types, including agents, applications, clusters, repositories, ApplicationSets, and more. You can query status, trigger syncs, create and update resources, inspect events and logs, and generate pipeline snippets. Go to GitOps operations for more information on all supported resource types and operations.

Use case: List agents and check their health.

List all healthy GitOps agents at account level

Use case: Check application sync status across your environment.

What applications are out of sync? How long have they been out of sync? Which project are the out-of-sync applications in?

Use case: Create a new GitOps application.

Create a new app called guestbook pointing at the argocd-example-apps repo on cluster incluster

Use case: Sync an application with pruning.

Sync the app my-app with pruning enabled

Use case: Bulk sync multiple applications.

Bulk sync apps app1 and app2 on agent account.myagent

Use case: Create an ApplicationSet with a list generator.

Create an ApplicationSet using a list generator with dev, staging, and prod environments

Use case: Inspect events and troubleshoot.

Show recent events for app my-app on agent account.myagent

Use case: View pod logs for a workload.

Get the last 100 lines of logs from pod web-abc123 in app my-app

Use case: Discover and run Kubernetes resource actions.

What actions can I run on the web Deployment in app my-app?

Use case: View the GitOps dashboard summary.

How many GitOps apps are healthy vs degraded?

Use case: Link a cluster to an environment.

Link cluster incluster to environment staging via agent myagent at account scope

Limitations

Harness AI does not currently support generating the following DevOps resources:

  • Template creation and update

Example prompts for efficiency and cost

Use these example prompts to create Cloud Cost Management perspectives.

Create cloud cost perspectives

You can use Harness AI to create Cloud Cost Management perspectives to visualize and analyze cloud spending.

Use case: Create a perspective for application costs.

Could you create a Cost Perspective rules based on Application costs?

Use case: Create a perspective for environment costs.

Could you create a Cost Perspective rules based on Environment costs (dev/staging/prod)?

Use case: Create a service or component cost perspective.

Could you create a Cost Perspective rules based on a service/component?

Use case: Create a team or department cost perspective to manage team spending.

Could you create a Cost Perspective rules based on Team/Department costs?

Next steps