# Scaffolding with helm create — Helm

Source: https://www.skillbyai.com/en/helm/c-create

> Generate a starter chart and understand the Deployment template it produces.

## A starter chart to learn from

`helm create NAME` generates a working chart for a generic web app: a Deployment, Service, ServiceAccount, optional Ingress and HorizontalPodAutoscaler, a `NOTES.txt`, a connection test under `templates/tests/`, and `_helpers.tpl` with named templates for names and labels. It is a good learning tool and a reasonable starting point, but trim what you do not need: unused templates and values become confusing configuration surface. Read the generated Deployment closely; it shows most templating patterns you will use: values lookups (`.Values.replicaCount`), helpers (`include "shop-api.fullname" .`), defaults (`default .Chart.AppVersion`), conditional blocks (`if not .Values.autoscaling.enabled`) and YAML embedding with `toYaml` and `nindent`.

## Excerpt of the generated deployment.yaml

Replicas are omitted when the HPA manages scaling; the image tag falls back to appVersion.

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "shop-api.fullname" . }}
  labels:
    {{- include "shop-api.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "shop-api.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "shop-api.selectorLabels" . | nindent 8 }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          ports:
            - containerPort: {{ .Values.service.port }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
```

## A furnished show flat

`helm create` hands you a furnished show flat. It is useful for seeing how rooms fit together, but you will move out the furniture you never use rather than dust it for years.

**Quiz:** Why does the generated template wrap `replicas` in `if not .Values.autoscaling.enabled`?

- [ ] Replicas are not allowed in Deployments
- [ ] To speed up rendering
- [ ] Because Helm cannot set integers
- [x] So the HorizontalPodAutoscaler, not Helm, controls the replica count when autoscaling is on

*Answer:* So the HorizontalPodAutoscaler, not Helm, controls the replica count when autoscaling is on. If Helm kept setting replicas, every upgrade would fight the HPA's chosen count.
