|
| 1 | +--- |
| 2 | +description: Translate Docker Compose files into Kubernetes Helm Charts with DeployStack docker-to-iac module |
| 3 | +menuTitle: Helm |
| 4 | +--- |
| 5 | + |
| 6 | +# Helm - Parser Full Documentation |
| 7 | + |
| 8 | +The parser for Helm translates Docker configurations into Kubernetes Helm Charts. The parser logic can be found in GitHub inside the [docker-to-iac repo](https://github.com/deploystackio/docker-to-iac/blob/main/src/parsers/helm.ts). |
| 9 | + |
| 10 | +## Parser language abbreviation for API |
| 11 | + |
| 12 | +- `languageAbbreviation`: `HELM`. |
| 13 | + |
| 14 | +## Prerequisite to deploy Helm Charts |
| 15 | + |
| 16 | +To deploy the generated Helm Charts, you need: |
| 17 | + |
| 18 | +- A Kubernetes cluster (local or cloud-based) |
| 19 | +- Helm CLI installed (version 3.x recommended) |
| 20 | +- Appropriate RBAC permissions to deploy resources in your target namespace |
| 21 | + |
| 22 | +### Kubernetes Resources |
| 23 | + |
| 24 | +The generated Helm Chart creates the following Kubernetes resources for each service in your Docker configuration: |
| 25 | + |
| 26 | +- **Deployments**: Container specifications, replica count, resource limits |
| 27 | +- **Services**: Network access to your pods with appropriate ports |
| 28 | +- **ConfigMaps**: Non-sensitive environment variables |
| 29 | +- **Secrets**: Sensitive environment variables (passwords, tokens, etc.) |
| 30 | + |
| 31 | +### Database Support |
| 32 | + |
| 33 | +For database services, the parser leverages Helm's dependency management to incorporate official Bitnami charts: |
| 34 | + |
| 35 | +- **MySQL/MariaDB**: Uses Bitnami's MySQL/MariaDB chart |
| 36 | +- **PostgreSQL**: Uses Bitnami's PostgreSQL chart |
| 37 | +- **Redis**: Uses Bitnami's Redis chart |
| 38 | +- **MongoDB**: Uses Bitnami's MongoDB chart |
| 39 | + |
| 40 | +Each database dependency is configured with appropriate defaults and includes persistent storage for data. |
| 41 | + |
| 42 | +## Default output format |
| 43 | + |
| 44 | +- The default output format for this parser: `YAML`. |
| 45 | + |
| 46 | +## File Configuration |
| 47 | + |
| 48 | +The Helm parser generates a complete Helm Chart directory structure: |
| 49 | + |
| 50 | +- `Chart.yaml` - The main chart definition with metadata and dependencies |
| 51 | +- `values.yaml` - Configuration values that can be customized at deployment time |
| 52 | +- `templates/` - Directory containing Kubernetes YAML templates: |
| 53 | + - `deployment.yaml` - Deployment specifications for each service |
| 54 | + - `service.yaml` - Service definitions for network access |
| 55 | + - `configmap.yaml` - ConfigMap for non-sensitive environment variables |
| 56 | + - `secret.yaml` - Secret for sensitive environment variables |
| 57 | + - `_helpers.tpl` - Helper functions for template generation |
| 58 | + - `NOTES.txt` - Usage instructions displayed after installation |
| 59 | + |
| 60 | +This multi-file approach follows the standard Helm Chart structure and allows for maximum flexibility when deploying to Kubernetes. |
| 61 | + |
| 62 | +## Supported Docker Compose Variables |
| 63 | + |
| 64 | +This parser supports the following Docker Compose variables: |
| 65 | + |
| 66 | +- `image` |
| 67 | +- `environment` |
| 68 | +- `ports` |
| 69 | +- `command` |
| 70 | +- `volumes` |
| 71 | + |
| 72 | +::content-alert{type="note"} |
| 73 | +The parser automatically detects sensitive environment variables (containing keywords like "password", "secret", "key", "token", or "auth") and places them in Kubernetes Secrets instead of ConfigMaps. |
| 74 | +:: |
| 75 | + |
| 76 | +## Volume Support |
| 77 | + |
| 78 | +The parser supports Docker volume mappings by converting them to Kubernetes volume mounts: |
| 79 | + |
| 80 | +- Each volume is converted to a hostPath volume by default |
| 81 | +- Volume names are sanitized to conform to Kubernetes naming conventions |
| 82 | +- For production use, you should modify the generated templates to use more appropriate volume types (PersistentVolumeClaims, etc.) |
| 83 | + |
| 84 | +## Database Integration |
| 85 | + |
| 86 | +When a database service is detected (MySQL, PostgreSQL, Redis, MongoDB), the parser: |
| 87 | + |
| 88 | +1. Adds the corresponding Bitnami Helm chart as a dependency in `Chart.yaml` |
| 89 | +2. Configures database settings in `values.yaml` |
| 90 | +3. Maps environment variables to the expected format for the database chart |
| 91 | +4. Sets up appropriate persistence configurations |
| 92 | + |
| 93 | +### Example Database Configuration |
| 94 | + |
| 95 | +For a PostgreSQL database in your Docker Compose file: |
| 96 | + |
| 97 | +```yaml |
| 98 | +services: |
| 99 | + db: |
| 100 | + image: postgres:13 |
| 101 | + environment: |
| 102 | + POSTGRES_USER: myuser |
| 103 | + POSTGRES_PASSWORD: mypassword |
| 104 | + POSTGRES_DB: myapp |
| 105 | +``` |
| 106 | +
|
| 107 | +The parser will create: |
| 108 | +
|
| 109 | +```yaml |
| 110 | +# In Chart.yaml |
| 111 | +dependencies: |
| 112 | + - name: db |
| 113 | + repository: https://charts.bitnami.com/bitnami |
| 114 | + version: ^12.0.0 |
| 115 | + condition: dependencies.db.enabled |
| 116 | + |
| 117 | +# In values.yaml |
| 118 | +dependencies: |
| 119 | + db: |
| 120 | + enabled: true |
| 121 | + auth: |
| 122 | + postgres: |
| 123 | + password: mypassword |
| 124 | + database: myapp |
| 125 | + username: myuser |
| 126 | + password: mypassword |
| 127 | + primary: |
| 128 | + service: |
| 129 | + ports: |
| 130 | + postgresql: 5432 |
| 131 | + persistence: |
| 132 | + enabled: true |
| 133 | + size: 8Gi |
| 134 | +``` |
| 135 | +
|
| 136 | +## Service Connections |
| 137 | +
|
| 138 | +The parser supports service-to-service connections by leveraging Kubernetes DNS for service discovery. When a service refers to another service in an environment variable, the parser automatically configures the appropriate DNS references. |
| 139 | +
|
| 140 | +For example, if your `app` service connects to a `db` service: |
| 141 | + |
| 142 | +```yaml |
| 143 | +# Docker Compose |
| 144 | +services: |
| 145 | + app: |
| 146 | + image: myapp |
| 147 | + environment: |
| 148 | + DATABASE_URL: postgresql://postgres:password@db:5432/mydb |
| 149 | + |
| 150 | + db: |
| 151 | + image: postgres |
| 152 | + environment: |
| 153 | + POSTGRES_PASSWORD: password |
| 154 | + POSTGRES_DB: mydb |
| 155 | +``` |
| 156 | + |
| 157 | +The parser will create: |
| 158 | + |
| 159 | +```yaml |
| 160 | +# In ConfigMap template |
| 161 | +data: |
| 162 | + DATABASE_URL: {{ include "deploystack.serviceReference" (dict "service" (index $.Values.services "db") "serviceKey" "db") }} |
| 163 | +``` |
| 164 | + |
| 165 | +Which resolves to the Kubernetes DNS name: `db.{{ .Release.Namespace }}.svc.cluster.local:5432` |
| 166 | + |
| 167 | +## Multi Services Support |
| 168 | + |
| 169 | +Multi `services` support for Helm: **yes** |
| 170 | + |
| 171 | +Helm Charts are designed to handle multiple services and dependencies in a single deployment, making them ideal for complex applications. The parser transforms all services from your Docker Compose file into corresponding Kubernetes resources. |
| 172 | + |
| 173 | +Please read more about [multi service support here](/docs/docker-to-iac/multi-services-support.md). |
| 174 | + |
| 175 | +## Deployment Instructions |
| 176 | + |
| 177 | +To deploy the generated Helm Chart: |
| 178 | + |
| 179 | +1. Navigate to the directory containing the generated chart |
| 180 | +2. Install dependencies: |
| 181 | + |
| 182 | + ```bash |
| 183 | + helm dependency update |
| 184 | + ``` |
| 185 | + |
| 186 | +3. Install the chart: |
| 187 | + |
| 188 | + ```bash |
| 189 | + helm install my-release . |
| 190 | + ``` |
| 191 | + |
| 192 | +4. For custom configurations: |
| 193 | + |
| 194 | + ```bash |
| 195 | + helm install my-release . --set services.app.replicaCount=2 |
| 196 | + ``` |
| 197 | + |
| 198 | +## Production Considerations |
| 199 | + |
| 200 | +For production deployments, consider the following modifications to the generated chart: |
| 201 | + |
| 202 | +1. Replace hostPath volumes with appropriate persistent volume claims |
| 203 | +2. Adjust resource limits in `values.yaml` |
| 204 | +3. Configure proper ingress settings for external access |
| 205 | +4. Enable and configure horizontal pod autoscaling |
| 206 | +5. Set up proper liveness and readiness probes |
| 207 | + |
| 208 | +::content-alert{type="important"} |
| 209 | +The generated Helm Chart is a starting point that you should review and customize to match your production requirements and security best practices. |
| 210 | +:: |
0 commit comments