# Kubernetes CRDs for index templates / datastreams with ECK?

**URL:** <https://discuss.elastic.co/t/kubernetes-crds-for-index-templates-datastreams-with-eck/384085>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Created:** [December 15, 2025, 4:14pm UTC](https://discuss.elastic.co/t/kubernetes-crds-for-index-templates-datastreams-with-eck/384085 "2025-12-15T16:14:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gueguet57](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gueguet57/32/143903_2.png) [@gueguet57](https://discuss.elastic.co/u/gueguet57)\
**Post date:** [December 15, 2025, 4:14pm UTC](https://discuss.elastic.co/t/kubernetes-crds-for-index-templates-datastreams-with-eck/384085/1 "2025-12-15T16:14:03Z")

</div>

Hi all,

I’m deploying Elastic via **ECK** and want to manage **index templates / datastreams as code** in Kubernetes manifests (Helm / GitOps).

I checked the [ECK API docs](https://www.elastic.co/docs/reference/cloud-on-k8s/api-reference/3_2_0) but didn’t see any CRDs for this (or I missed it).

**Question:** Are there CRDs for index templates/datastreams ?

Thanks!

---

<div class="post-metadata">

**Author:** ![pebrc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pebrc/32/101790_2.png) [@pebrc](https://discuss.elastic.co/u/pebrc)\
**Post date:** [December 31, 2025, 3:19pm UTC](https://discuss.elastic.co/t/kubernetes-crds-for-index-templates-datastreams-with-eck/384085/2 "2025-12-31T15:19:59Z")

</div>

### Yes! ECK Has CRDs for Index Templates

ECK provides the **`StackConfigPolicy`** CRD (available since ECK 2.6) that allows you to manage Elasticsearch settings declaratively as Kubernetes resources. This includes index templates.

### Example: Managing Index Templates with StackConfigPolicy

```yaml
apiVersion: stackconfigpolicy.k8s.elastic.co/v1alpha1
kind: StackConfigPolicy
metadata:
  name: my-stack-config
  namespace: elastic-system
spec:
  # Select which Elasticsearch clusters this policy applies to
  resourceSelector:
    matchLabels:
      environment: production
  
  elasticsearch:
    # Index Templates
    indexTemplates:
      # Component Templates (reusable building blocks)
      componentTemplates:
        my-mappings:
          template:
            mappings:
              properties:
                '@timestamp':
                  type: date
                message:
                  type: text
        my-settings:
          template:
            settings:
              number_of_shards: 2
              number_of_replicas: 1
      
      # Composable Index Templates (combine component templates)
      composableIndexTemplates:
        my-logs-template:
          index_patterns:
            - "logs-*"
            - "app-logs-*"
          composed_of:
            - my-mappings
            - my-settings
          priority: 500
          template:
            aliases:
              logs: {}
          _meta:
            description: "Template for application logs"
    
    # ILM Policies
    indexLifecyclePolicies:
      logs-policy:
        phases:
          hot:
            actions:
              rollover:
                max_size: 50gb
                max_age: 1d
          warm:
            min_age: 7d
            actions:
              shrink:
                number_of_shards: 1
          delete:
            min_age: 30d
            actions:
              delete: {}
    
    # Ingest Pipelines
    ingestPipelines:
      my-pipeline:
        description: "Add timestamp to documents"
        processors:
          - set:
              field: ingested_at
              value: "{{_ingest.timestamp}}"

```

### Important Notes

1. **License Required** : StackConfigPolicy requires an **Enterprise license** (or trial license)

2. **Elasticsearch Version** : Requires Elasticsearch 8.6.1+ (uses the file-based settings feature internally)

3. **GitOps Compatible** : The CRD works perfectly with Helm, Kustomize, ArgoCD, Flux, etc.

4. **Label Selector** : Use `resourceSelector` to target specific Elasticsearch clusters

5. **No Datastream CRD** : There's no dedicated CRD for datastreams, but datastreams are automatically created when you index data that matches an index template with `data_stream: {}` enabled

### Documentation

- [StackConfigPolicy Documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-stack-config-policy.html)
- [API Reference](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-api-stackconfigpolicy.html)
