app
by Dysnix
Generic application Helm chart
About this chart
Generic application Helm chart
Generic application Helm chart
This chart provides a generic interface to deploy an application straight away without necessity to create your own chart, i.e. eliminates "helm create & make a new chart again and again" cycle. Extensive value interface is tightgtly based on bitnami/template as well as its foundation this chart also relies on bitnami/common. Though unlike bitnami/template which requires generation and the development of a specific chart for your needs (totally viable approach), this chart brings a simplified approach which might be better suited for small teams - "define everything via helm values".
Introduction
The app chart basically generates a generic application based on the provided helm values input. Just specify app.name and the image.repository and the deployment along with a couple of other resources (ServiceAccount namely) will be deployed straight away. Evidently such an installation might bring insufficient value to an enduser, thus this chart is charged with other resources (PR and add yours into the list :)).
As of now dysnix/app chart ships the following resources:
- Deployment
- Service
- Secrets
- ConfigMaps
- Ingress
- HorizontalPodAutoscaler
- PersistentVolumeClaim
- ServiceAccount
- Role & RoleBinding
- PodDisruptionBudget
TL;DR
$ helm repo add dysnix https://dysnix.github.io/charts
$ helm install my-release dysnix/app
Examples
Tip: For broader usage examples please refer to dysnix/app/tests values and tests.
Full app example
## Application name
##
app:
name: app-name
templateChecksums:
- configmaps.yaml
- secrets.yaml
## An arbitary configMap can be deployed
## Note: the configMap name is prefixed with the "release name"
##
configMaps:
default:
## Many keys support interpolation!
##
sample.txt: |-
some text file for release "{{ .Release.Name }}".
interpolation works.
env:
FOUR: 4
## Note: the last-leaf rendered data is always string, since
## there's no way to dect it's. RENDER_FOURED will be "4"
##
RENDERED_FOUR: '{{ mul 2 2 }}'
## Additional application containers spawned together with the main one
##
containers:
additional:
env:
FOO: BAR
YET: ANOTHER
envFrom:
- configMapRef:
name: foo
- secretRef:
name: bar
extraEnvVars:
- name: ADDED_AFTER
value: .env
image:
pullPolicy: IfNotPresent
repository: hello-world
lifecycleHooks:
postStart:
exec:
command:
- /bin/sh
- '-c'
- echo sample hook
livenessProbe:
enabled: true
readinessProbe:
enabled: true
startupProbe:
enabled: true
volumeMounts:
ebs:
mountPath: /ebs
## Environment variables (main container)
##
env:
VARIABLE: DEFAULT_CONTAINER
## Environment variables mounted from configMaps and secrets (main container)
##
envFrom:
- configMapRef:
name: '{{ template "common.names.fullname" . }}-foo'
optional: false
- secretRef:
name: '{{ template "common.names.fullname" . }}-bar'
## extra* parameters are the most low-level parameters they are rendered as-is (though not always).
## More likely they originate from bitnami template parameter
##
extraEnvVars:
- name: ADDED_AFTER
value: .env
## Image parameters
##
image:
registry: docker.io
repository: alpine
tag: latest
## Ingress parameters
##
ingress:
enabled: true
## The bellow is not required for a single port service (this not our example case)
##
servicePort: http
extraPaths:
- path: /foo
## Feel free to provide extra configuration (even with a custom backend)
##
- backend:
serviceName: another-service
servicePort: its-port
path: /custom
hostname: host.fqdn
selfSigned: true
tls: true
## initContainers (main Pod) consist of two keys:
## use - list which defines the order of init containers
## values - the actual data for init containers
##
## Approach is used to separate definition and inclusion, which gives
## an evident flexibility when extending the configuration.
##
initContainers:
use:
- first
- second
values:
first:
image:
pullPolicy: IfNotPresent
repository: goes-first
volumeMounts:
ebs:
mountPath: /ebs
second:
env:
FOO: BAR
YET: ANOTHER
envFrom:
- configMapRef:
name: foo
- secretRef:
name: bar
extraEnvVars:
- name: ADDED_AFTER
value: .env
image:
pullPolicy: IfNotPresent
repository: goes-second
## LifeCycle hooks (main container)
##
lifecycleHooks:
postStart:
exec:
command:
- /bin/sh
- '-c'
- echo sample hook
## Don't enable probes without defining actual body (main container)
##
livenessProbe:
enabled: false
readinessProbe:
enabled: false
startupProbe:
enabled: false
## Creates a PVC
##
persistence:
enabled: true
size: 10Gi
storageClass: custom
## An arbitary secret can be deployed
## Note: the secret name is prefixed with the "release name"
##
secrets:
b64:
data:
sample.txt: ZW5jb2RlZA==
default:
stringData:
sample.txt: |-
some text file for release "{{ .Release.Name }}".
interpolation works.
## Ports map is flexible
##
service:
ports:
http: 8080
custom:
name: overrides-custom
nodePort: null
port: 6000
## Manage persistence
##
volumeMounts:
ebs:
mountPath: /ebs
volumes:
ebs:
awsElasticBlockStore:
fsType: ext4
volumeID: <volume id>
Reuse mode
Reuse mode enables reuse (merge) of the component level values into a specific entity. Entities supporting reuse:
- Container, applicable in containers and initContainers
app:
name: app
image:
repository: alpine
command:
- /bin/sh
- -c
args:
- sleep 10
env:
FOO: REUSED
configMaps:
env:
HELLO: WORLD
envFrom:
- configMapRef:
name: '{{ template "app.fullname" . }}-env'
resources:
limits:
memory: 128Mi
containers:
worker:
reuse: true
args:
- Hello the command and other parameters are reused!
Note: reuse uses only specific container keys such as image, command, env and others (i.e. not everything is reused)
Source Code
Parameters
App chart parameters
| Name | Description | Value |
|---|---|---|
app.name | Specifies the chart/application name (app.kubernetes.io/name), since this is a generic chart | app |
app.workload.enabled | Specifies whether the default workload resource is generated (Deployment/StatefulSet etc) | true |
app.workload.type | Specifies type of the main workload resource ("deployment" or "statefulset/sts") | deployment |
app.components | Specifies list of components to enable used in direct mode (it respectively expects .Values.[component] to be present) | [] |
selector.matchLabels | Specifies additional selector labels for the workload resources and services | {} |
reuse | Enables reuse/merge of the upper-level component values (applicable for containers/initContainers) | false |
enableServiceLinks | Can be disabled to remove information about services from pod's environment variables | true |
persistentVolumeClaimRetentionPolicy | Describes the lifecycle of PVCs created from volumeClaimTemplates (only "statefulset" workload type) | {} |
containers | Specify a map of additional pod containers | {} |
initContainers | Specifies initContainers (use, values map for order and data) | {} |
env | Name Map of environment variables for the main container | {} |
envFrom | Configures of envFrom to include into the main container | [] |
volumes | Specify volumes for the main pod | {} |
volumeMounts | Specify volumeMounts for the main container | {} |
configMaps | Creates application сonfigMaps (note the name is prefixed with the app name) | {} |
secrets | Creates application secrets (note the name is prefixed with the app name) | {} |
templateChecksums | Specifies list of template files to add as an annotation checksum into the pod. | [] |
Global parameters
| Name | Description | Value |
|---|---|---|
global.imageRegistry | Global Docker image registry | "" |
global.imagePullSecrets | Global Docker registry secret names as an array | [] |
global.storageClass | Global StorageClass for Persistent Volume(s) | "" |
Common parameters
| Name | Description | Value |
|---|---|---|
kubeVersion | Override Kubernetes version | "" |
nameOverride | String to partially override common.names.name | "" |
fullnameOverride | String to fully override common.names.fullname | "" |
namespaceOverride | String to fully override common.names.namespace | "" |
commonLabels | Labels to add to all deployed objects | {} |
commonAnnotations | Annotations to add to all deployed objects | {} |
clusterDomain | Kubernetes cluster domain name | cluster.local |
extraDeploy | Array of extra objects to deploy with the release | [] |
diagnosticMode.enabled | Enable diagnostic mode (all probes will be disabled and the command will be overridden) | false |
diagnosticMode.command | Command to override all containers in the deployment | ["sleep"] |
diagnosticMode.args | Args to override all containers in the deployment | ["infinity"] |
Main pod Parameters
| Name | Description | Value |
|---|---|---|
image.registry | image registry | "" |
image.repository | image repository | "" |
image.tag | image tag (immutable tags are recommended) | "" |
image.digest | image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag image tag (immutable tags are recommended) | "" |
image.pullPolicy | image pull policy |
Deploy app with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has app on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartapp is pinned at v0.99.23 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply