app

by Dysnix

Helm chartv0.99.23Verified publisher

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

NameDescriptionValue
app.nameSpecifies the chart/application name (app.kubernetes.io/name), since this is a generic chartapp
app.workload.enabledSpecifies whether the default workload resource is generated (Deployment/StatefulSet etc)true
app.workload.typeSpecifies type of the main workload resource ("deployment" or "statefulset/sts")deployment
app.componentsSpecifies list of components to enable used in direct mode (it respectively expects .Values.[component] to be present)[]
selector.matchLabelsSpecifies additional selector labels for the workload resources and services{}
reuseEnables reuse/merge of the upper-level component values (applicable for containers/initContainers)false
enableServiceLinksCan be disabled to remove information about services from pod's environment variablestrue
persistentVolumeClaimRetentionPolicyDescribes the lifecycle of PVCs created from volumeClaimTemplates (only "statefulset" workload type){}
containersSpecify a map of additional pod containers{}
initContainersSpecifies initContainers (use, values map for order and data){}
envName Map of environment variables for the main container{}
envFromConfigures of envFrom to include into the main container[]
volumesSpecify volumes for the main pod{}
volumeMountsSpecify volumeMounts for the main container{}
configMapsCreates application сonfigMaps (note the name is prefixed with the app name){}
secretsCreates application secrets (note the name is prefixed with the app name){}
templateChecksumsSpecifies list of template files to add as an annotation checksum into the pod.[]

Global parameters

NameDescriptionValue
global.imageRegistryGlobal Docker image registry""
global.imagePullSecretsGlobal Docker registry secret names as an array[]
global.storageClassGlobal StorageClass for Persistent Volume(s)""

Common parameters

NameDescriptionValue
kubeVersionOverride Kubernetes version""
nameOverrideString to partially override common.names.name""
fullnameOverrideString to fully override common.names.fullname""
namespaceOverrideString to fully override common.names.namespace""
commonLabelsLabels to add to all deployed objects{}
commonAnnotationsAnnotations to add to all deployed objects{}
clusterDomainKubernetes cluster domain namecluster.local
extraDeployArray of extra objects to deploy with the release[]
diagnosticMode.enabledEnable diagnostic mode (all probes will be disabled and the command will be overridden)false
diagnosticMode.commandCommand to override all containers in the deployment["sleep"]
diagnosticMode.argsArgs to override all containers in the deployment["infinity"]

Main pod Parameters

NameDescriptionValue
image.registryimage registry""
image.repositoryimage repository""
image.tagimage tag (immutable tags are recommended)""
image.digestimage digest in the way sha256:aa.... Please note this parameter, if set, will override the tag image tag (immutable tags are recommended)""
image.pullPolicyimage 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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartapp is pinned at v0.99.23 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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