> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cnap.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Learn how templates power your products and deployments

Templates are reusable configurations that define how your software is deployed. They serve as the foundation for both **products** (with pricing) and **direct installs** (standalone deployments).

## What Are Templates?

Templates store <Tooltip headline="Helm" tip="Helm is a package manager for Kubernetes that simplifies deploying and managing applications. Helm charts package Kubernetes resources into reusable, versioned units.">Helm</Tooltip> source configurations that describe your application's deployment. When you create a product, CNAP automatically creates a template from your Helm sources, then generates a versioned package that can be deployed to your clusters.

<Tip>
  Templates are created automatically when you create a product or direct install. You don't need to manage them separately - CNAP handles everything for you.
</Tip>

## How Templates Work

### Template Lifecycle

1. **Create** - Template is created from Helm sources (automatically when creating a product)
2. **Package Generation** - CNAP generates a versioned package from the template
3. **Deployment** - Package is deployed to your clusters

<Card title="Learn More" icon="book" href="/charts/chart-generation">
  Understand how packages are automatically generated from templates
</Card>

## Template Sources

Templates can include multiple types of sources:

### Helm Charts

* Standard Helm charts from repositories (HTTP, OCI, or Git)
* Examples: PostgreSQL, Redis, NGINX from Artifact Hub
* Values are nested under the chart name or alias

### Custom Kubernetes Manifests

* Raw Kubernetes resources (<Tooltip headline="ConfigMap" tip="A ConfigMap is a Kubernetes resource that stores configuration data as key-value pairs. It allows you to separate configuration from application code, making it easy to update settings without rebuilding containers.">ConfigMap</Tooltip>, <Tooltip headline="Secret" tip="A Secret is a Kubernetes resource that stores sensitive data like passwords, API keys, or certificates. Secrets are encrypted at rest and only accessible to authorized pods.">Secret</Tooltip>, <Tooltip headline="HTTPRoute" tip="An HTTPRoute is a Kubernetes resource that defines routing rules for HTTP traffic. It allows you to configure how incoming requests are routed to different services based on hostname, path, or headers.">HTTPRoute</Tooltip>, custom CRDs)
* Placed directly in the chart's `templates/` directory
* Values merge at the root level

### Mixed Sources

* Combine Helm charts and custom <Tooltip headline="Kubernetes Manifest" tip="A Kubernetes manifest is a YAML or JSON file that describes the desired state of Kubernetes resources like Pods, Services, or ConfigMaps. Manifests define what resources should exist and how they should be configured.">manifests</Tooltip> in a single template
* All sources are composed into one unified Helm chart
* Dependencies are automatically bundled

## Templates and Products

When you create a product:

1. **Template Creation** - A template is automatically created from your Helm sources
2. **Package Generation** - CNAP generates a versioned package (e.g., `0.1.0`)
3. **Product Association** - The product references the template and adds pricing
4. **Customer Deployment** - When customers purchase, the package is deployed to your clusters

<Tip>
  One template can power multiple products, or be deployed directly without pricing as a standalone install.
</Tip>

## Direct Installs

Templates can also be deployed directly without creating a product:

* **No Pricing** - Deploy applications without Stripe integration
* **Internal Tools** - Perfect for internal services, monitoring, or development tools
* **Same Package Generation** - Still benefits from automatic package generation and versioning

## Why Templates Are Powerful

Templates solve the complexity of managing multiple deployment sources:

### One Template, Many Uses

* **Reusability** - One template can power multiple products or direct installs
* **Consistency** - Same configuration deployed the same way every time
* **Efficiency** - Define once, deploy everywhere

### Automatic Package Generation

When you create a template, CNAP automatically:

* **Generates a Versioned Package** - Creates a self-contained Helm package
* **Bundles Dependencies** - All Helm charts and manifests combined into one package
* **Locks Versions** - No "latest" references, everything is pinned
* **Validates** - Runs `helm lint` to ensure package quality

### Self-Contained & Reliable

* **Works Offline** - All dependencies bundled, no external fetches needed
* **Source Independent** - Package works even if original sources become unavailable
* **Single Download** - One package contains everything

### Standard & Portable

* **Standard Helm Format** - Works with all Helm tools and <Tooltip headline="GitOps" tip="GitOps is a methodology for managing infrastructure and application deployments using Git as the single source of truth. Changes are tracked in Git and automatically applied to your infrastructure.">GitOps</Tooltip> workflows
* **Portable** - Generated packages can be used outside CNAP
* **Tool Compatible** - Use `helm template`, `helm lint`, and all Helm plugins

## Template Benefits

* **Reusability** - One template can power multiple products or direct installs
* **Versioning** - Automatic semantic versioning (e.g., `0.1.0`, `0.1.1`)
* **Self-Contained** - All dependencies bundled in the generated package
* **Standard Helm** - Works with all Helm tooling and GitOps workflows
* **Automatic Updates** - Packages regenerate when templates are updated

## Template Structure

A template consists of:

* **Name** - Display name for the template
* **Helm Sources** - Array of Helm charts and/or custom manifests
* **Values** - Configuration values for each source
* **Metadata** - Additional information (GitHub workflow runs, Artifact Hub data, and more)

## When Templates Are Created

Templates are automatically created in these scenarios:

1. **Product Creation** - When you create a product with Helm sources
2. **Product Update** - When you update a product's sources (template is updated)
3. **Direct Install** - When you create a standalone install with Helm sources

## Package Generation

When a template is created or updated, CNAP automatically:

1. Generates a standard Helm package structure
2. Packages all dependencies into a single package
3. Creates a versioned release following semantic versioning
4. Stores the package for deployment

<Card title="Package Generation Details" icon="box" href="/charts/chart-generation">
  Learn how CNAP generates packages from templates
</Card>

## Next Steps

<CardGroup cols={2}>
  <Card title="Create a Product" icon="rocket" href="/products">
    Create your first product and see templates in action
  </Card>

  <Card title="Learn About Package Generation" icon="box" href="/charts/chart-generation">
    Understand how packages are automatically generated
  </Card>

  <Card title="Application Sources" icon="code" href="/app-sources">
    Learn about the different source types you can use
  </Card>

  <Card title="Package Versioning" icon="tag" href="/charts/versioning">
    Understand how versioning works for your packages
  </Card>
</CardGroup>
