Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:
helm lint complex -f complex/testing-values/values-targetgroups.yaml
helm lint complex -f complex/testing-values/values-configmap.yaml
helm lint complex -f complex/testing-values/values-volume-mounts.yaml
helm lint complex -f complex/testing-values/values-initcontainers.yaml

template-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -119,6 +120,7 @@ jobs:
helm template test ./complex --debug -f complex/testing-values/values-security-context.yaml
helm template test ./complex --debug -f complex/testing-values/values-rolling-update.yaml
helm template test ./complex --debug -f complex/testing-values/values-pod-disruption-budget.yaml
helm template test ./complex --debug -f complex/testing-values/values-initcontainers.yaml

# Test infrastructure configurations
helm template test ./complex --debug -f complex/testing-values/values-ingress.yaml
Expand Down
2 changes: 1 addition & 1 deletion complex/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: complex
description: For deploying applications with consumers and cronjobs
type: application
version: 1.5.1
version: 1.5.2
kubeVersion: ">= 1.25.0-0 < 2.0.0-0"

dependencies:
Expand Down
61 changes: 60 additions & 1 deletion complex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# complex

![Version: 1.5.0](https://img.shields.io/badge/Version-1.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 1.5.2](https://img.shields.io/badge/Version-1.5.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

For deploying applications, consumers and cronjobs

Expand Down Expand Up @@ -163,6 +163,65 @@ components:
- `<name>` - Component middleware (e.g., `strip-prefix`)
- `<name>@<provider>` - External reference (e.g., `auth@file`, `other-middleware@kubernetescrd`)

## Init Containers

The chart supports defining init containers that run before the main container starts. Init containers are useful for:

- Running setup scripts or database migrations
- Waiting for dependent services to be ready
- Downloading configuration files or secrets
- Setting up volumes with proper permissions

### Defining Init Containers

Init containers are defined at the component level using `initContainers`:

```yaml
components:
api:
type: http
ports:
- port: 3000
initContainers:
wait-for-db:
image:
repository: busybox
tag: "1.36"
command:
- sh
- -c
- |
until nc -z postgres-service 5432; do
echo "Waiting for database..."
sleep 2
done
resources:
requests:
cpu: "50m"
memory: "64M"
limits:
cpu: "100m"
memory: "128M"
```

### Init Container Properties

Each init container supports the same properties as regular containers:

| Property | Description | Required |
|----------|-------------|----------|
| `image.repository` | Container image repository | Yes |
| `image.tag` | Container image tag | Yes |
| `image.pullPolicy` | Image pull policy (IfNotPresent, Always, Never) | No |
| `command` | Override container entrypoint | No |
| `args` | Arguments to the entrypoint | No |
| `envs.values` | Environment variables as key-value pairs | No |
| `envs.from.configMaps` | Load env vars from ConfigMaps | No |
| `envs.from.secrets` | Load env vars from Secrets | No |
| `resources` | CPU/memory requests and limits | No |
| `volumeMounts` | Mount ConfigMaps or Secrets as files | No |


## Configuration Structure

### Global vs Component-Specific Configuration
Expand Down
58 changes: 58 additions & 0 deletions complex/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,64 @@ components:
- `<name>` - Component middleware (e.g., `strip-prefix`)
- `<name>@<provider>` - External reference (e.g., `auth@file`, `other-middleware@kubernetescrd`)

## Init Containers

The chart supports defining init containers that run before the main container starts. Init containers are useful for:

- Running setup scripts or database migrations
- Waiting for dependent services to be ready
- Downloading configuration files or secrets
- Setting up volumes with proper permissions

### Defining Init Containers

Init containers are defined at the component level using `initContainers`:

```yaml
components:
api:
type: http
ports:
- port: 3000
initContainers:
wait-for-db:
image:
repository: busybox
tag: "1.36"
command:
- sh
- -c
- |
until nc -z postgres-service 5432; do
echo "Waiting for database..."
sleep 2
done
resources:
requests:
cpu: "50m"
memory: "64M"
limits:
cpu: "100m"
memory: "128M"
```

### Init Container Properties

Each init container supports the same properties as regular containers:

| Property | Description | Required |
|----------|-------------|----------|
| `image.repository` | Container image repository | Yes |
| `image.tag` | Container image tag | Yes |
| `image.pullPolicy` | Image pull policy (IfNotPresent, Always, Never) | No |
| `command` | Override container entrypoint | No |
| `args` | Arguments to the entrypoint | No |
| `envs.values` | Environment variables as key-value pairs | No |
| `envs.from.configMaps` | Load env vars from ConfigMaps | No |
| `envs.from.secrets` | Load env vars from Secrets | No |
| `resources` | CPU/memory requests and limits | No |
| `volumeMounts` | Mount ConfigMaps or Secrets as files | No |

## Configuration Structure

### Global vs Component-Specific Configuration
Expand Down
2 changes: 1 addition & 1 deletion complex/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ spec:
{{ $.Values.global.metadata.annotations | toYaml | nindent 8 }}
{{- end }}
spec:
{{ include "pod.spec" (dict "containers" (dict "application" $component) "global" $.Values.global "metadata" $.Values.global.metadata "nodeSelector" $component.nodeSelector "kubeLabels" $kubeLabels "enableServiceLinks" $component.enableServiceLinks "serviceAccountName" $component.serviceAccountName "tolerations" $component.tolerations "imagePullSecrets" $component.imagePullSecrets "volumeMounts" $component.volumeMounts "volumes" $component.volumes "persistentVolumeClaim" $component.persistentVolumeClaim "componentName" (include "component.name" (dict "name" $componentName "Release" $.Release)) "root" $) | indent 6 | trim }}
{{ include "pod.spec" (dict "containers" (dict "application" $component) "initContainers" $component.initContainers "global" $.Values.global "metadata" $.Values.global.metadata "nodeSelector" $component.nodeSelector "kubeLabels" $kubeLabels "enableServiceLinks" $component.enableServiceLinks "serviceAccountName" $component.serviceAccountName "tolerations" $component.tolerations "imagePullSecrets" $component.imagePullSecrets "volumeMounts" $component.volumeMounts "volumes" $component.volumes "persistentVolumeClaim" $component.persistentVolumeClaim "componentName" (include "component.name" (dict "name" $componentName "Release" $.Release)) "root" $) | indent 6 | trim }}
{{ end -}}
{{- end -}}
49 changes: 49 additions & 0 deletions complex/testing-values/values-initcontainers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
global:
container:
image:
repository: cookielab/deployer
tag: 1.0.0-rc2

components:
api:
type: http
replicas: 2
ports:
- port: 3000
probes:
readinessProbe:
httpGet:
port: 8080
path: /health-check
periodSeconds: 30
timeoutSeconds: 15
livenessProbe:
httpGet:
port: 8080
path: /health-check
targetGroup:
arn: 'arn:fake'
securityGroupIds:
- sg-fake
initContainers:
wait-for-db:
image:
repository: busybox
tag: "1.36"
command:
- sh
- -c
- |
until nc -z postgres-service 5432; do
echo "Waiting for database..."
sleep 2
done
resources:
requests:
cpu: "50m"
memory: "64M"
ephemeralStorage: "128Mi"
limits:
cpu: "100m"
memory: "128M"
ephemeralStorage: "128Mi"
16 changes: 15 additions & 1 deletion complex/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,13 @@
"type": "string"
}
},
"initContainers": {
"description": "InitContainers defines containers to run before the main container starts.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/container"
}
},
"traefikMiddlewares": {
"$ref": "#/definitions/traefikMiddlewares"
}
Expand Down Expand Up @@ -2839,6 +2846,13 @@
}
}
},
"initContainers": {
"description": "InitContainers defines containers to run before the main container starts.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/container"
}
},
"traefikMiddlewares": {
"$ref": "#/definitions/traefikMiddlewares"
},
Expand Down Expand Up @@ -3529,4 +3543,4 @@
}
},
"additionalProperties": false
}
}