mirror of
https://github.com/morten-olsen/homelab-apps.git
synced 2026-02-08 01:36:28 +01:00
support all in one template
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
{{ include "common.oidc" . }}
|
|
||||||
1
apps/charts/homarr/templates/common.yaml
Normal file
1
apps/charts/homarr/templates/common.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{{ include "common.all" . }}
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.deployment" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.pvc" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.externalSecrets.externalSecrets" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.externalSecrets.passwordGenerators" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.service" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.virtualService" . }}
|
|
||||||
1
apps/charts/komga/templates/common.yaml
Normal file
1
apps/charts/komga/templates/common.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{{ include "common.all" . }}
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.deployment" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.pvc" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.service" . }}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ include "common.virtualService" . }}
|
|
||||||
@@ -30,9 +30,20 @@ Run `helm dependency build` to download the dependency.
|
|||||||
|
|
||||||
Create `values.yaml` with the standardized structure (see [Values Structure](#values-structure) below).
|
Create `values.yaml` with the standardized structure (see [Values Structure](#values-structure) below).
|
||||||
|
|
||||||
### 4. Create Template Files
|
### 4. Create Template File
|
||||||
|
|
||||||
Replace complex templates with simple includes:
|
Use a single template file that includes all resources:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# templates/common.yaml
|
||||||
|
{{ include "common.all" . }}
|
||||||
|
```
|
||||||
|
|
||||||
|
The `common.all` helper automatically includes all standard resources based on your `values.yaml` configuration. Resources are only rendered if their corresponding values are defined and enabled.
|
||||||
|
|
||||||
|
**Alternative: Individual Templates**
|
||||||
|
|
||||||
|
If you need more control, you can use individual template files instead:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# templates/deployment.yaml
|
# templates/deployment.yaml
|
||||||
@@ -239,9 +250,29 @@ env:
|
|||||||
|
|
||||||
## Template Files
|
## Template Files
|
||||||
|
|
||||||
### Basic Application
|
### Recommended: Single Template with `common.all`
|
||||||
|
|
||||||
For a simple application with persistent storage:
|
The simplest approach is to use a single template file:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# templates/common.yaml
|
||||||
|
{{ include "common.all" . }}
|
||||||
|
```
|
||||||
|
|
||||||
|
This automatically renders all resources based on your `values.yaml`:
|
||||||
|
- **Deployment** - always rendered if `deployment` is defined
|
||||||
|
- **Service** - always rendered if `service` is defined
|
||||||
|
- **ServiceAccount** - rendered if `serviceAccount` is defined
|
||||||
|
- **PVC** - rendered if `persistentVolumeClaims` is defined
|
||||||
|
- **VirtualService** - rendered if `virtualService.enabled: true`
|
||||||
|
- **DNS** - rendered if `dns.enabled: true`
|
||||||
|
- **OIDC** - rendered if `oidc.enabled: true`
|
||||||
|
- **Database** - rendered if `database.enabled: true`
|
||||||
|
- **ExternalSecrets** - rendered if `externalSecrets` is defined
|
||||||
|
|
||||||
|
### Alternative: Individual Templates
|
||||||
|
|
||||||
|
For more control or custom resources, use individual template files:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# templates/deployment.yaml
|
# templates/deployment.yaml
|
||||||
@@ -255,31 +286,13 @@ For a simple application with persistent storage:
|
|||||||
|
|
||||||
# templates/virtual-service.yaml
|
# templates/virtual-service.yaml
|
||||||
{{ include "common.virtualService" . }}
|
{{ include "common.virtualService" . }}
|
||||||
```
|
|
||||||
|
|
||||||
### With OIDC Authentication
|
# templates/client.yaml (OIDC)
|
||||||
|
|
||||||
Add OIDC client template:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# templates/client.yaml (or oidc.yaml)
|
|
||||||
{{ include "common.oidc" . }}
|
{{ include "common.oidc" . }}
|
||||||
```
|
|
||||||
|
|
||||||
### With Database
|
|
||||||
|
|
||||||
Add database template:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# templates/database.yaml
|
# templates/database.yaml
|
||||||
{{ include "common.database" . }}
|
{{ include "common.database" . }}
|
||||||
```
|
|
||||||
|
|
||||||
### With External Secrets
|
|
||||||
|
|
||||||
Add secret generation templates:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# templates/secret-password-generators.yaml
|
# templates/secret-password-generators.yaml
|
||||||
{{ include "common.externalSecrets.passwordGenerators" . }}
|
{{ include "common.externalSecrets.passwordGenerators" . }}
|
||||||
|
|
||||||
@@ -328,14 +341,8 @@ env:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# templates/deployment.yaml
|
# templates/common.yaml
|
||||||
{{ include "common.deployment" . }}
|
{{ include "common.all" . }}
|
||||||
|
|
||||||
# templates/service.yaml
|
|
||||||
{{ include "common.service" . }}
|
|
||||||
|
|
||||||
# templates/virtual-service.yaml
|
|
||||||
{{ include "common.virtualService" . }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example 2: Application with OIDC and Database
|
### Example 2: Application with OIDC and Database
|
||||||
@@ -415,23 +422,8 @@ env:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# templates/deployment.yaml
|
# templates/common.yaml
|
||||||
{{ include "common.deployment" . }}
|
{{ include "common.all" . }}
|
||||||
|
|
||||||
# templates/service.yaml
|
|
||||||
{{ include "common.service" . }}
|
|
||||||
|
|
||||||
# templates/pvc.yaml
|
|
||||||
{{ include "common.pvc" . }}
|
|
||||||
|
|
||||||
# templates/virtual-service.yaml
|
|
||||||
{{ include "common.virtualService" . }}
|
|
||||||
|
|
||||||
# templates/client.yaml
|
|
||||||
{{ include "common.oidc" . }}
|
|
||||||
|
|
||||||
# templates/database.yaml
|
|
||||||
{{ include "common.database" . }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example 3: Application with Generated Secrets
|
### Example 3: Application with Generated Secrets
|
||||||
@@ -470,25 +462,26 @@ env:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# templates/secret-password-generators.yaml
|
# templates/common.yaml
|
||||||
{{ include "common.externalSecrets.passwordGenerators" . }}
|
{{ include "common.all" . }}
|
||||||
|
|
||||||
# templates/secret-external-secrets.yaml
|
|
||||||
{{ include "common.externalSecrets.externalSecrets" . }}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Available Templates
|
## Available Templates
|
||||||
|
|
||||||
The library provides full resource templates that can be included directly:
|
The library provides full resource templates that can be included directly:
|
||||||
|
|
||||||
|
- **`common.all`** - All-in-one template that renders all resources based on values (recommended)
|
||||||
- `common.deployment` - Full Deployment resource with all standard configurations (supports custom command/args)
|
- `common.deployment` - Full Deployment resource with all standard configurations (supports custom command/args)
|
||||||
- `common.service` - Full Service resource(s) - supports multiple services
|
- `common.service` - Full Service resource(s) - supports multiple services
|
||||||
|
- `common.serviceAccount` - Full ServiceAccount resource
|
||||||
- `common.pvc` - Full PVC resources - supports multiple PVCs
|
- `common.pvc` - Full PVC resources - supports multiple PVCs
|
||||||
- `common.virtualService` - Full VirtualService resources (public + private gateways)
|
- `common.virtualService` - Full VirtualService resources (public + private gateways)
|
||||||
|
- `common.dns` - Full DNSRecord resource
|
||||||
- `common.oidc` - Full AuthentikClient resource for OIDC authentication
|
- `common.oidc` - Full AuthentikClient resource for OIDC authentication
|
||||||
- `common.database` - Full PostgresDatabase resource for database provisioning
|
- `common.database` - Full PostgresDatabase resource for database provisioning
|
||||||
- `common.externalSecrets.passwordGenerators` - Password generator resources
|
- `common.externalSecrets` - Combined Password generators + ExternalSecret resources
|
||||||
- `common.externalSecrets.externalSecrets` - ExternalSecret resources
|
- `common.externalSecrets.passwordGenerators` - Password generator resources only
|
||||||
|
- `common.externalSecrets.externalSecrets` - ExternalSecret resources only
|
||||||
|
|
||||||
## Secret References
|
## Secret References
|
||||||
|
|
||||||
@@ -697,7 +690,7 @@ After creating your chart:
|
|||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
See migrated charts for real-world examples:
|
See migrated charts for real-world examples:
|
||||||
- `apps/charts/readeck` - Simple application
|
- `apps/charts/komga` - Simple application using `common.all`
|
||||||
- `apps/charts/miniflux` - Application with OIDC and database
|
- `apps/charts/homarr` - Application with OIDC and external secrets using `common.all`
|
||||||
- `apps/charts/n8n` - Complex application with multiple services
|
- `apps/charts/n8n` - Complex application with multiple services
|
||||||
- `apps/charts/home-assistant` - Application with host networking and privileged containers
|
- `apps/charts/home-assistant` - Application with host networking and privileged containers
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ Full Deployment resource
|
|||||||
*/}}
|
*/}}
|
||||||
{{- define "common.deployment" -}}
|
{{- define "common.deployment" -}}
|
||||||
{{- if .Values.deployment }}
|
{{- if .Values.deployment }}
|
||||||
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@@ -390,6 +391,7 @@ Full ServiceAccount resource
|
|||||||
*/}}
|
*/}}
|
||||||
{{- define "common.serviceAccount" -}}
|
{{- define "common.serviceAccount" -}}
|
||||||
{{- if .Values.serviceAccount }}
|
{{- if .Values.serviceAccount }}
|
||||||
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ServiceAccount
|
kind: ServiceAccount
|
||||||
metadata:
|
metadata:
|
||||||
@@ -430,6 +432,7 @@ spec:
|
|||||||
{{- include "common.selectorLabels" $ | nindent 4 }}
|
{{- include "common.selectorLabels" $ | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
@@ -483,6 +486,7 @@ Full VirtualService resources
|
|||||||
{{- define "common.virtualService" -}}
|
{{- define "common.virtualService" -}}
|
||||||
{{- if and .Values.virtualService.enabled .Values.subdomain (hasKey .Values.globals "domain") (ne .Values.globals.domain "") }}
|
{{- if and .Values.virtualService.enabled .Values.subdomain (hasKey .Values.globals "domain") (ne .Values.globals.domain "") }}
|
||||||
{{- if and .Values.virtualService.gateways.public (hasKey .Values.globals "istio") (hasKey .Values.globals.istio "gateways") (hasKey .Values.globals.istio.gateways "public") (ne .Values.globals.istio.gateways.public "") }}
|
{{- if and .Values.virtualService.gateways.public (hasKey .Values.globals "istio") (hasKey .Values.globals.istio "gateways") (hasKey .Values.globals.istio.gateways "public") (ne .Values.globals.istio.gateways.public "") }}
|
||||||
|
---
|
||||||
apiVersion: networking.istio.io/v1
|
apiVersion: networking.istio.io/v1
|
||||||
kind: VirtualService
|
kind: VirtualService
|
||||||
metadata:
|
metadata:
|
||||||
@@ -510,9 +514,9 @@ spec:
|
|||||||
number: {{ include "common.servicePort" . }}
|
number: {{ include "common.servicePort" . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
---
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if and .Values.virtualService.gateways.private (hasKey .Values.globals "istio") (hasKey .Values.globals.istio "gateways") (hasKey .Values.globals.istio.gateways "private") (ne .Values.globals.istio.gateways.private "") }}
|
{{- if and .Values.virtualService.gateways.private (hasKey .Values.globals "istio") (hasKey .Values.globals.istio "gateways") (hasKey .Values.globals.istio.gateways "private") (ne .Values.globals.istio.gateways.private "") }}
|
||||||
|
---
|
||||||
apiVersion: networking.istio.io/v1
|
apiVersion: networking.istio.io/v1
|
||||||
kind: VirtualService
|
kind: VirtualService
|
||||||
metadata:
|
metadata:
|
||||||
@@ -547,7 +551,8 @@ spec:
|
|||||||
Full DNS resource
|
Full DNS resource
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.dns" -}}
|
{{- define "common.dns" -}}
|
||||||
{{- if and .Values.dns.enabled (hasKey .Values.globals "networking") (hasKey .Values.globals.networking "private") (hasKey .Values.globals.networking.private "ip") (ne .Values.globals.networking.private.ip "") }}
|
{{- if and .Values.dns .Values.dns.enabled (hasKey .Values.globals "networking") (hasKey .Values.globals.networking "private") (hasKey .Values.globals.networking.private "ip") (ne .Values.globals.networking.private.ip "") }}
|
||||||
|
---
|
||||||
apiVersion: dns.homelab.mortenolsen.pro/v1alpha1
|
apiVersion: dns.homelab.mortenolsen.pro/v1alpha1
|
||||||
kind: DNSRecord
|
kind: DNSRecord
|
||||||
metadata:
|
metadata:
|
||||||
@@ -572,7 +577,8 @@ spec:
|
|||||||
Full OIDC/AuthentikClient resource
|
Full OIDC/AuthentikClient resource
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.oidc" -}}
|
{{- define "common.oidc" -}}
|
||||||
{{- if and .Values.oidc.enabled (hasKey .Values.globals "authentik") (hasKey .Values.globals.authentik "ref") (hasKey .Values.globals.authentik.ref "name") (hasKey .Values.globals.authentik.ref "namespace") (ne .Values.globals.authentik.ref.name "") (ne .Values.globals.authentik.ref.namespace "") }}
|
{{- if and .Values.oidc .Values.oidc.enabled (hasKey .Values.globals "authentik") (hasKey .Values.globals.authentik "ref") (hasKey .Values.globals.authentik.ref "name") (hasKey .Values.globals.authentik.ref "namespace") (ne .Values.globals.authentik.ref.name "") (ne .Values.globals.authentik.ref.namespace "") }}
|
||||||
|
---
|
||||||
apiVersion: authentik.homelab.mortenolsen.pro/v1alpha1
|
apiVersion: authentik.homelab.mortenolsen.pro/v1alpha1
|
||||||
kind: AuthentikClient
|
kind: AuthentikClient
|
||||||
metadata:
|
metadata:
|
||||||
@@ -597,7 +603,8 @@ spec:
|
|||||||
Full PostgreSQL Database resource
|
Full PostgreSQL Database resource
|
||||||
*/}}
|
*/}}
|
||||||
{{- define "common.database" -}}
|
{{- define "common.database" -}}
|
||||||
{{- if and .Values.database.enabled (hasKey .Values.globals "database") (hasKey .Values.globals.database "ref") (hasKey .Values.globals.database.ref "name") (hasKey .Values.globals.database.ref "namespace") (ne .Values.globals.database.ref.name "") (ne .Values.globals.database.ref.namespace "") }}
|
{{- if and .Values.database .Values.database.enabled (hasKey .Values.globals "database") (hasKey .Values.globals.database "ref") (hasKey .Values.globals.database.ref "name") (hasKey .Values.globals.database.ref "namespace") (ne .Values.globals.database.ref.name "") (ne .Values.globals.database.ref.namespace "") }}
|
||||||
|
---
|
||||||
apiVersion: postgres.homelab.mortenolsen.pro/v1
|
apiVersion: postgres.homelab.mortenolsen.pro/v1
|
||||||
kind: PostgresDatabase
|
kind: PostgresDatabase
|
||||||
metadata:
|
metadata:
|
||||||
@@ -689,3 +696,19 @@ Combined helper that outputs generators first, then ExternalSecrets
|
|||||||
{{- include "common.externalSecrets.passwordGenerators" . }}
|
{{- include "common.externalSecrets.passwordGenerators" . }}
|
||||||
{{- include "common.externalSecrets.externalSecrets" . }}
|
{{- include "common.externalSecrets.externalSecrets" . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Full All-in-One resource
|
||||||
|
Includes all standard resources based on values.yaml configuration
|
||||||
|
*/}}
|
||||||
|
{{- define "common.all" -}}
|
||||||
|
{{- include "common.deployment" . }}
|
||||||
|
{{- include "common.serviceAccount" . }}
|
||||||
|
{{- include "common.service" . }}
|
||||||
|
{{- include "common.pvc" . }}
|
||||||
|
{{- include "common.virtualService" . }}
|
||||||
|
{{- include "common.dns" . }}
|
||||||
|
{{- include "common.oidc" . }}
|
||||||
|
{{- include "common.database" . }}
|
||||||
|
{{- include "common.externalSecrets" . }}
|
||||||
|
{{- end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user