Deploy a public nginx container to a Kubernetes Dev environment using Harness CD with the Rolling strategy. This is the starting point for Harness CD: wire up a service, an environment, and an infrastructure definition, then run a Deploy stage that rolls out pods with zero downtime and rolls back automatically on failure.
Harness CD has three building blocks before you can deploy anything:
| Building block | What it answers | This example |
|---|---|---|
| Service | What are you deploying? | nginx image + K8s manifests |
| Environment | Where are you deploying? | Dev (PreProduction) |
| Infrastructure | Which cluster/namespace? | KubernetesDirect → tidbit-0044 |
The pipeline wires these together in a single Deploy stage:
Pipeline: tidbit_cd_basic_deployment
└── Stage: Deploy to Dev
├── Service: svc_tid0044 → nginx:stable + k8s manifests
├── Environment: env_dev_tid0044 → PreProduction (Dev)
├── Infrastructure: infra_k8s_tid0044 → namespace tidbit-0044
└── Execution:
├── K8sRollingDeploy ← applies manifests, waits for pods Ready
└── K8sRollingRollback ← runs automatically on any failure
Rolling strategy means Harness replaces pods incrementally — old pods stay up until new ones are healthy, so there's no downtime. If anything goes wrong, the failure strategy triggers K8sRollingRollback (kubectl rollout undo) automatically.
.harness/
pipeline.yaml # 1 Deploy stage, Rolling strategy
service.yaml # nginx artifact + K8s manifest source
environment.yaml # PreProduction (Dev) environment
infrastructure.yaml # KubernetesDirect: connector + namespace
k8s/
namespace.yaml # creates the target namespace (must be applied first)
deployment.yaml # nginx Deployment (Go-templated)
service.yaml # ClusterIP Service (Go-templated)
values.yaml # image, namespace, replicas — rendered at deploy time
- Harness account with Continuous Delivery enabled.
- Kubernetes Cluster connector pointing at a real cluster (delegate-backed). The delegate needs RBAC to create a namespace and a Deployment/Service. Confirm it tests green before running.
- DockerHub connector — anonymous auth is fine because nginx is a public image.
- Manifests uploaded to Harness. Two options:
- File Store (easiest): Project Setup → File Store → upload the four files from
k8s/into a folder. - Git: fork this repo and point the service's manifest store at your fork's
k8s/folder.
- File Store (easiest): Project Setup → File Store → upload the four files from
- Fork or clone this repo.
- Upload manifests to the Harness File Store (or use Git as described above).
- Create connectors if you don't have them yet. Update every
# REPLACE:line in the.harness/*.yamlfiles. - Import entities in this order — Deployments > New > YAML, paste each file:
service.yaml→environment.yaml→infrastructure.yaml→pipeline.yaml
- Run the pipeline
tidbit_cd_basic_deployment. No runtime inputs needed — the tag is pinned tostable. - Watch the Rollout Deployment step: Harness renders the manifests, runs a dry run, applies them, and waits for steady state.
kubectl get ns tidbit-0044
kubectl -n tidbit-0044 get deploy,po,svc
kubectl -n tidbit-0044 rollout status deploy/basic-deployment-deployment
# Expected: deployment "basic-deployment-deployment" successfully rolled outIn the Harness UI, the Rollout Deployment step turns green and its Output tab shows the deployed image digest.
| Symptom | Likely cause | Fix |
|---|---|---|
namespaces "tidbit-0044" not found |
Harness doesn't auto-create namespaces | Make sure namespace.yaml is listed first in the service manifest files and createNamespace: true in values.yaml |
There are no eligible delegates available |
Connector can't reach a delegate | Install or health-check a delegate; test the connector — it must be green |
ImagePullBackOff |
Cluster can't pull the image | Official images need the library/ prefix (library/nginx); check cluster egress to DockerHub |
| Rollout hangs then rolls back | Pods can't schedule or fail readiness | Lower replicas / resources.requests in values.yaml; inspect with kubectl -n tidbit-0044 describe po |
| Governance / OPA blocks the run | A policy set is denying the pipeline | Review Project Settings > Governance; a Deployment-type stage is unaffected by CI-only policies |
kubectl delete ns tidbit-0044