Genpack

Genpack Helm chart is designed to deploy containerized applications as easy as possible. Using the provided information, this chart automatically generates all needed kubernetes resources and keeps them in sync.

Prerequisites

  • Kubernetes 1.20+
  • Helm 3+
  • PV provisioner support in the underlying infrastructure (when using volumes)

TL;DR, How to use this chart?

Installing the Chart

Add helm repository first

helm repo add kubit-packs https://repo.sabz.dev/artifactory/kubit-packs

To install the chart with the release name my-release:

helm install -n my-namespace my-release kubit-packs/genpack -f my-values.yaml

The command deploys genpack on the Kubernetes cluster with given parameters. The Parameters section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the my-release deployment:

helm delete -n my-namespace my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Parameters

The following table lists the configurable parameters sections of the genpack chart. (Hint: the )

SectionsDescription
globalThis section contains shared configurations across all generated resources
gonbadThis section defines workloads and related resources

Global

section: global.*

This object holds shared secrets and configs as well as shared certificate and repository related variables. for example:

global:
  commonImageRegistry: docker.sabz.dev
  commonImagePullSecrets:
    - name: docker-sabz-dev-registry
  sharedConfigs:
    POSTGRES_HOST: postgresql
    POSTGRES_PORT: 5432
    psk_conf: |
      TLSConnect=psk
      TLSAccept=psk
  sharedSecrets:
    POSTGRES_USER: user
    POSTGRES_PASSWORD: encrypted-password
  #...

The available parameters:

ParameterTypeDescriptionDefault
issuerobjectIssuer to be used for certificates--
issuer.namestring(Required) Should follow ^[a-z][a-z0-9]*(-[a-z0-9]+)*$--
issuer.kindstringEither Issuer or ClusterIssuerIssuer
certificateobject--
certificate.hostslist(Required) List of hosts to issue certificate for them (at least one host is required)--
certificate.createbooleanWhether to create this certificate or notfalse
certificate.secretNamestringName of secret--
commonImageRegistrystringDefault image registry used by common.containerImage helper--
commonImagePullSecretslist of imagePullSecretlist of pull secrets added to all workloads--
sharedConfigslistA mapping of key: value used to create a ConfigMap for shared configs--
sharedSecretslistA mapping of key: value used to create a Secret for shared secrets--
sharedConfigmapNamestringName for shared ConfigMap created by global.sharedConfigs[.Release.name]-shared
sharedSecretNamestringName for shared Secret created by global.sharedConfigs[.Release.name]-shared
ingress.tlslistAdditional tls for all ingresses see ingresses--
ingress.annotationsmappingAdditional annotations for all ingresses see ingresses--
metrics.serviceMonitor.namespacestringDefines a specific namespace for serviceMonitor of metrics--

Gonbad

Section: gonbad.*

This is the main object. It contains values from which workloads and other manifests are created. It's most important sub-object is workloads. Workloads definition simplify creation and configuring most of used Kubernetes resources like Deployments, Services, ServiceMonitors and so on.

SectionsDescription
workloadsWorkloads definitions which are rendered as kubernetes Deployment, Statefulset, ..
staticFilesSimplifies mounting small configuration files into workloads
volumesVolumes definition for workloads
ingressesSimplifies creating kubernetes Ingress resources
externalServicesCreates kubernetes Service to connect to external services from within the cluster using cluster dns names
prometheusRuleSimplifies creating PrometheusRules resources
rawResourcesRaw kubernetes resources to add beside other generated resources

For example:

gonbad:
  workloads:
    server:
      kind: deployment
      replicaCount: 1
      service:
        type: NodePort
      containers:
        server:
          image:
            repository: zabbix/zabbix-server-pgsql
            tag: ubuntu-5.2.0
          ports:
            10051:
              name: server
              nodePort: 30051
            10052:
              enabled: false
              name: jmx

    web:
      kind: deployment
      replicaCount: 3
      containers:
        web:
          image:
            repository: zabbix/zabbix-web-nginx-pgsql
            tag: ubuntu-5.2.0
          ports:
            8080:
              name: http
            3040:
              name: metrics
              scrapePath: /metrics

      hostAliases:
        - ip: 1.2.3.4
          hostnames:
            - app1.local
            - app2.local

  ingresses:
    web:
      workloadName: web
      servicePort: http
      hosts:
        - host: zabbix.example.com
  #...

Gonbad Workloads

Section: gonbad.workloads.*

There are 5 types of workloads. a simple workload needs only an image and creates a simple single container deployment. On the other hand, a deployment workload, takes at least one container directive and can have as many as desired. A deployment workload, provides fine-tuning and high control over the specified workload. A statefulset, daemonset and cronjob workload are similar to deployment but with different kubernetes resources. To read more about them go to following sections

To create simple workload, set gonbad.workload.<name>.kind to simple and so on. Each workload should have a name. A workload is an object which it's key is the workload's name.

gonbad:
  workloads:
    foo:
      kind: simple
      #...
    bar:
      kind: deployment
      #...
    rex:
      kind: statefulset
      #...
    jaz:
      kind: daemonset
      #...
    baz:
      kind: cronjob
      #...

Simple Workload

A simple workload named foo looks like:

gonbad:
  workloads:
    foo:
      kind: simple
      #...

The following parameters are available for a simple workload.

ParameterTypeDescriptionDefault
kindstring(Required) simple--
enabledbooleanEnables or disable flag for this workloadtrue
replicaCountpositive numberReplica Count for this workload. 0 or greater1
imagecontainer.image(Required) Image for the single container in this workload--
strategydeployment.strategyUpdate and redeployment strategy for this workload--
usedSharedConfigslist of stringsWhile all the sharedConfigs are accessible for all workloads, only reload this workload if any ofusedSharedConfigs have changedAll sharedConfigs
usedSharedSecretslist of stringsWhile all the sharedSecrets are accessible for all workloads, only reload this workload if any ofusedSharedSecrets have changedAll sharedSecrets
commandlist of stringsCommand to run when the container is run as the entrypoint (e.g. ["de.sh", "-v", "-c"])--
argslist of stringsArguments to pass to gonbad.workload.command--
envobjectMappings of environment variables to pass to the container, see container.env for samples--
livenessProbecontainer.probeliveness prob definition for workload--
readinessProbecontainer.probeReadiness prob definition for workload--
resourcescontainer.resourcesResource definition for workload container--
portsmapping of container.portsPorts definition for workload--

Deployment Workload

A deployment workload name bar looks like:

gonbad:
  workloads:
    bar:
      kind: deployment
      #...

A deployment workload can have multiple containers.

The following parameters are available for a deployment workload.

ParameterTypeDescriptionDefault
kindstring(Required) deploymentdeployment
enabledbooleanEnables or disable flag for this workloadtrue
replicaCountpositive integerNumber of pods for this workload, minimum is 01
containersmapping of container(Required) Containers for this deployment--
initContainersmapping of containerContainers that are run once in order and must succeed before containers or the pod fails--
strategydeployment.strategyDeployment strategy definition--
usedSharedConfigslist of stringsWhile all the sharedConfigs are accessible for all workloads, only reload this workload if any ofusedSharedConfigs have changedAll sharedConfigs
usedSharedSecretslist of stringsWhile all the sharedSecrets are accessible for all workloads, only reload this workload if any ofusedSharedSecrets have changedAll sharedSecrets
serviceAccount.namestringName of serviceAccount that this deployment uses--
service.typestringeither ClusterIP or NodePort. Type of service to use for this deploymentClusterIP
service.labelsmappingExtra labels to add to related Service k8s.label regex--
service.annotationsmappingExtra annotations to add to related Service k8s.annotation regex--
securityContextpod.securityContextPod securityContext definition--
labelsmappingExtra labels to add to Deployment k8s.label regex--
annotationsmappingExtra annotations to add to Deployment k8s.annotation regex--
podLabelsmappingExtra labels to add to final Pod k8s.label regex--
podAnnotationsmappingExtra annotations to add to final Pod k8s.annotation regex--
terminationGracePeriodSecondspositive integerOptional duration in seconds the pod needs to terminate gracefully.
hostNetworkbooleanConfigure pod hostNetwork like kubernetes native notationfalse
hostAliaseslistResolve the given hostname to an IP--
hostAliases[].ipstringResolve to this ip for given hostAliases.hostnames--
hostAliases[].hostnameslist of stringsList of host names to be resolved to hostAliases.ip--
hpaworkload.hpaCreate and configure related HorizontalPodAutoscaler--
pdbworkload.pdbCreate and configure related PodDisruptionBudget--
antiAffinityModestringConfigure pod affinity if workload.affinity is not set. Valid values are preferred, required--
antiAffinityTopologyKeyslist of stringstopologyKeys for antiAffinityMode when setting workload.affinity['kubernetes.io/hostname']
affinityobjectConfigure pod affinity like kubernetes native notation--
tolerationslistConfigure pod tolerations like kubernetes native notation--
nodeSelectormappingConfigure pod nodeSelector as key
pairs like kubernetes native notation
--
dnsPolicystringdnsPolicy for this workload, one of Default,ClusterFirst,ClusterFirstWithHostNet,None--
fullnameOverridestringOverride name of workload--
minReadySecondspositive integerMinimum number of seconds for which a newly created pod should be ready without any of its container crashing--
priorityClassNamestringIf specified, indicates the pod's priority. It must be defined by creating a PriorityClass object with that name.--
imagePullSecretslist of imagePullSecretlist of pull secrets added to this workloads--
topologySpreadConstraintslistdescribes how a group of pods ought to spread across topology domains--
topologySpreadConstraints[].maxSkewpositive integer(Required)
topologySpreadConstraints[].topologyKeystring(Required)
topologySpreadConstraints[].whenUnsatisfiablestring(Required) oneOf DoNotSchedule or ScheduleAnyway
topologySpreadConstraints[].labelSelectormapping(Required)
topologySpreadConstraintsSkewpositive integerAdd simple pod topologySpreadConstraints with given skew--

StatefulSet Workload

A statefulset workload name bar looks like:

gonbad:
  workloads:
    rex:
      kind: statefulset
      #...
      volumeClaimTemplates:
        data-vol:
          size: 10Gi
        log-vol:
          size: 1Gi
    #...

A statefulset workload can have multiple containers.

The following parameters are available for a statefulset workload.

ParameterTypeDescriptionDefault
kindstring(Required) statefulsetstatefulset
enabledbooleanEnables or disable flag for this workloadtrue
replicaCountpositive integerNumber of pods for this workload, minimum is 01
containersmapping of container(Required) Containers for this statefulset--
initContainersmapping of containerContainers that are run once in order and must succeed before containers or the pod fails--
podManagementPolicystringControls how pods are created during initial scale up, valid values are OrderedReady, ParallelOrderedReady
updateStrategy.typestringStatefulset update strategy type, valid values are RollingUpdate, OnDeleteRollingUpdate
usedSharedConfigslist of stringsWhile all the sharedConfigs are accessible for all workloads, only reload this workload if any ofusedSharedConfigs have changedAll sharedConfigs
usedSharedSecretslist of stringsWhile all the sharedSecrets are accessible for all workloads, only reload this workload if any ofusedSharedSecrets have changedAll sharedSecrets
serviceAccount.namestringName of serviceAccount that this statefulset uses--
service.typestringeither ClusterIP or NodePort or Headless. Type of service to use for this statefulsetClusterIP
service.labelsmappingExtra labels to add to related Service k8s.label regex--
service.annotationsmappingExtra annotations to add to related Service k8s.annotation regex--
securityContextpod.securityContextPod securityContext definition--
labelsmappingExtra labels to add to Deployment k8s.label regex--
annotationsmappingExtra annotations to add to Deployment k8s.annotation regex--
podLabelsmappingExtra labels to add to final Pod k8s.label regex--
podAnnotationsmappingExtra annotations to add to final Pod k8s.annotation regex--
terminationGracePeriodSecondspositive integerOptional duration in seconds the pod needs to terminate gracefully.
hostNetworkbooleanConfigure pod hostNetwork like kubernetes native notationfalse
hostAliaseslistResolve the given hostname to an IP--
hostAliases[].hostnameslist of stringsList of host names to be resolved to hostAliases.ip--
hostAliases[].ipstringResolve to this ip for given hostAliases.hostnames--
volumeClaimTemplatesvolumeClaimTemplatesSimplified notation of StatefulSet.volumeClaimTemplates
hpaworkload.hpaCreate and configure related HorizontalPodAutoscaler--
pdbworkload.pdbCreate and configure related PodDisruptionBudget--
dnsPolicystringdnsPolicy for this workload, one of Default,ClusterFirst,ClusterFirstWithHostNet,None--
antiAffinityModestringConfigure pod affinity if workload.affinity is not set. Valid values are preferred, required--
antiAffinityTopologyKeyslist of stringstopologyKeys for antiAffinityMode when setting workload.affinity['kubernetes.io/hostname']
affinityobjectConfigure pod affinity like kubernetes native notation--
tolerationslistConfigure pod tolerations like kubernetes native notation--
nodeSelectormappingConfigure pod nodeSelector as key
pairs like kubernetes native notation
--
fullnameOverridestringOverride name of workload--
minReadySecondspositive integerMinimum number of seconds for which a newly created pod should be ready without any of its container crashing--
priorityClassNamestringIf specified, indicates the pod's priority. It must be defined by creating a PriorityClass object with that name.--
imagePullSecretslist of imagePullSecretlist of pull secrets added to this workloads--
topologySpreadConstraintslistdescribes how a group of pods ought to spread across topology domains--
topologySpreadConstraints[].maxSkewpositive integer(Required)
topologySpreadConstraints[].topologyKeystring(Required)
topologySpreadConstraints[].whenUnsatisfiablestring(Required) oneOf DoNotSchedule or ScheduleAnyway
topologySpreadConstraints[].labelSelectormapping(Required)
topologySpreadConstraintsSkewpositive integerAdd simple pod topologySpreadConstraints with given skew--

Daemonset Workload

A daemonset workload name jaz looks like:

gonbad:
  workloads:
    jaz:
      kind: daemonset
      #...

A cronjob workload can have multiple containers.

The following parameters are available for a cronjob workload.

ParameterTypeDescriptionDefault
kindstring(Required) daemonsetdaemonset
enabledbooleanEnables or disable flag for this workloadtrue
containersmapping of container(Required) Containers for this daemonset--
initContainersmapping of containerContainers that are run once in order and must succeed before containers or the pod fails--
updateStrategystringOneOf RollingUpdate, OnDeleteRollingUpdate
usedSharedConfigslist of stringsWhile all the sharedConfigs are accessible for all workloads, only reload this workload if any ofusedSharedConfigs have changedAll sharedConfigs
usedSharedSecretslist of stringsWhile all the sharedSecrets are accessible for all workloads, only reload this workload if any ofusedSharedSecrets have changedAll sharedSecrets
serviceAccount.namestringName of serviceAccount that this daemonset uses--
service.typestringeither ClusterIP or NodePort. Type of service to use for this daemonsetClusterIP
service.labelsmappingExtra labels to add to related Service k8s.label regex--
service.annotationsmappingExtra annotations to add to related Service k8s.annotation regex--
securityContextpod.securityContextPod securityContext definition--
labelsmappingExtra labels to add to Daemonset k8s.label regex--
annotationsmappingExtra annotations to add to Daemonset k8s.annotation regex--
podLabelsmappingExtra labels to add to final Pod k8s.label regex--
podAnnotationsmappingExtra annotations to add to final Pod k8s.annotation regex--
terminationGracePeriodSecondspositive integerOptional duration in seconds the pod needs to terminate gracefully.
hostNetworkbooleanConfigure pod hostNetwork like kubernetes native notationfalse
hostAliaseslistResolve the given hostname to an IP--
hostAliases[].ipstringResolve to this ip for given hostAliases.hostnames--
hostAliases[].hostnameslist of stringsList of host names to be resolved to hostAliases.ip--
antiAffinityModestringConfigure pod affinity if workload.affinity is not set. Valid values are preferred, required--
antiAffinityTopologyKeyslist of stringstopologyKeys for antiAffinityMode when setting workload.affinity['kubernetes.io/hostname']
affinityobjectConfigure pod affinity like kubernetes native notation--
tolerationslistConfigure pod tolerations like kubernetes native notation--
nodeSelectormappingConfigure pod nodeSelector as key
pairs like kubernetes native notation
--
dnsPolicystringdnsPolicy for this workload, one of Default,ClusterFirst,ClusterFirstWithHostNet,None--
fullnameOverridestringOverride name of workload--
priorityClassNamestringIf specified, indicates the pod's priority. It must be defined by creating a PriorityClass object with that name.--
imagePullSecretslist of imagePullSecretlist of pull secrets added to this workloads--

CronJob Workload

A cronjob workload name baz looks like:

gonbad:
  workloads:
    baz:
      kind: cronjob
      schedule: '0 */2 * * *'
      #...

A cronjob workload can have multiple containers.

The following parameters are available for a cronjob workload.

ParameterTypeDescriptionDefault
kindstring(Required) cronjobcronjob
enabledbooleanEnables or disable flag for this workloadtrue
schedulestring(Required) crontab like string eg: 0 */2 * * *--
containersmapping of container(Required) Containers for this cronjob--
initContainersmapping of containerContainers that are run once in order and must succeed before containers or the pod fails--
startingDeadlineSecondspositive integerOptional deadline in seconds for starting the job if it misses scheduled time for any reason--
concurrencyPolicystringSpecifies how to treat concurrent executions of a Job. Valid values are: Allow, Forbid, ReplaceAllow
successfulJobsHistoryLimitpositive integerThe number of successful finished jobs to retain3
failedJobsHistoryLimitpositive integerThe number of failed finished jobs to retain1
suspendbooleanThis flag tells the controller to suspend subsequent executionsfalse
restartPolicystringRestart policy for all containers within the pod. One of Always, OnFailure, NeverAlways
usedSharedConfigslist of stringsWhile all the sharedConfigs are accessible for all workloads, only reload this workload if any ofusedSharedConfigs have changedAll sharedConfigs
usedSharedSecretslist of stringsWhile all the sharedSecrets are accessible for all workloads, only reload this workload if any ofusedSharedSecrets have changedAll sharedSecrets
securityContextpod.securityContextPod securityContext definition--
serviceAccount.namestringName of serviceAccount that this cronjob uses--
hostAliaseslistResolve the given hostname to an IP--
hostAliases[].hostnameslist of stringsList of host names to be resolved to hostAliases.ip--
hostAliases[].ipstringResolve to this ip for given hostAliases.hostnames--
imagePullSecretslist of imagePullSecretlist of pull secrets added to this workloads--

Gonbad Staticfiles

Section: gonbad.staticFiles

In order to mount single staticfiles (e.g., configuration files) inside containers, they need to be defined under gonbad.staticfiles. Then it's possible to reference the staticFiles from gonbad.workloads.containers.fileMounts.

Say one would want to define 2 static files named .zshrc and sshd.config. it would look like:

gonbad:
  #...
  staticFiles:
    .zshrc: |
      alias ll="ls -alh"
      alias g="git"
    sshd.config: |
      Port: 23412
  #...

This will create related configMaps and handles the integrity and naming uniformity.

Gonbad Volumes

section: gonbad.volumes

To create PVC and use them or mount Secrets/ConfigMaps into pods, they must first defined in the volumes section and then mount in containers using containers.volumeMounts. Different types of volumes are: persistentVolumeClaim, secret, configMap, emptyDir, ephemeral and existingPVC. The parameters of each will be described below.

The following parameters are available:

ParameterTypeDescriptionDefault
typestring(Required) Valid values are persistentVolumeClaim, secret, configMap, emptyDir, ephemeral and existingPVC--

volume.type: persistentVolumeClaim

ParameterTypeDescriptionDefault
typestring(Required) persistentVolumeClaim--
sizepositive integer or string(Required) The size of PVC. (eg. 1024 or 2Gi)--
accessModestring(Required) Access Mode for this PVC; one of ReadOnlyMany, ReadWriteOnce or ReadWriteOnce--
storageClassstringstorageClass of ths PVC--

volume.type: existingPVC

ParameterTypeDescriptionDefault
typestring(Required) existingPVC--
namestring(Required) Name of existing PersistentVolumeClaim to use--
readOnlybooleanFlag to mount as readonlyfalse

volume.type: ephemeral

ParameterTypeDescriptionDefault
typestring(Required) ephemeral--
sizepositive integer or string(Required) The size of ephemeral PVC . (eg. 1024 or 2Gi)--
accessModestring(Required) Access Mode for this ephemeral PVC; one of ReadOnlyMany, ReadWriteOnce or ReadWriteOnce--
storageClassstringstorageClass of ths ephemeral PVC--

volume.type: emptyDir

ParameterTypeDescriptionDefault
typestring(Required) emptyDir--

volume.type: secret

ParameterTypeDescriptionDefault
typestring(Required) secret--
namestring(Required) Name of Secret to use--
itemslistIf set only defined keys from secret will projected into the specified mount path--
items[].keystring(Required) Key in Secret--
items[].pathstring(Required) The relative path of the file to map the key to--
items[].modeintegermode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511--

volume.type: configMap

ParameterTypeDescriptionDefault
typestring(Required) configMap--
namestring(Required) Name of ConfigMap to use--
itemslistIf set only defined keys from configMap will projected into the specified mount path--
items[].keystring(Required) Key in ConfigMap--
items[].pathstring(Required) The relative path of the file to map the key to--
items[].modeintegermode bits used to set permissions on this file. Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511--

volume.type: hostPath

ParameterTypeDescriptionDefault
typestring(Required) hostPath--
pathstring(Required) path on host to use as volume--
hostPathTypestring(Required) Oneof "DirectoryOrCreate", "Directory", "FileOrCreate", "File", "Socket", "CharDevice", "BlockDevice"--

Gonbad Ingresses

Section: gonbad.ingresses

In order to create ingress resources, one should define them under gonbad.ingresses. An ingress names ing looks like:

ingresses:
  web:
    workloadName: web
    servicePort: http
    hosts:
      - host: example.com
    annotations:
      annot: something
    tls:
      - secretName: example-com-tls
  media:
    #...
    hosts:
      paths:
        - /
            - /browse/
            - path: /serve/
            workloadName: media
            servicePort: http
ParameterTypeDescriptionDefault
enabledbooleanEnables this ingresstrue
workloadNamestring(Required) Name of workload to route traffic to its service (internally release-name will be prepend) it take precedence over serviceName--
serviceNamestring(Required) Name of backend service to route traffic to--
servicePortstring(Required) Port name of the backend service--
ingressClassNamestring
fullnameOverridestring
hostslist(Required) Hosts that are routed through this ingress definition--
hosts[].hoststring(Required) Host address to be routed (in idn format)--
hosts[].pathslistPath part of the address to be routed. The paths can be just a list of addresses or each path can have specific configurations--
hosts[].paths[].pathstring(Required) Request path to be routed--
hosts[].paths[].pathTypestring(Required) One of ImplementationSpecific, Exact or PrefixImplementationSpecific
hosts[].paths[].workloadNamestringName of workload to route traffic to its service (internally release-name will be prepend)it take precedence over serviceNameparent workloadName
hosts[].paths[].serviceNamestringName of backend service to route traffic to. default toparent serviceName
hosts[].paths[].servicePortstring or positive integerPort name of the backend serviceparent servicePort
labelsmappingLabels for this ingress--
annotationsmappingAnnotations for this ingress--
tlslisttls for this ingress--
tls[].secretNamestring(Required) Name of Secret to use--
tls[].hostslist of stringsHostnames for which secretName will be used--

Notes:

  • workloadName only prepend the release name internally. It does not check if workload is exists/enabled and not useworkload.fullnameOverride
  • In addition, global.ingress.annotations and global.ingress.tls can be configured. The two will be merged into all ingresses.

Gonbad ExternalServices

Section: gonbad.externalServices

To point to an external service, one should define them under gonbad.externalServices. The parameters are as follows. (take note that besides ports, one of externalIPs or `externalName are required)

ParameterTypeDescriptionDefault
enabledbooleanEnables this externalServices--
externalNamestring(Either this or externalIPs is required) IDN hostname of the external service--
externalIPslist of strings(Either this or externalName is required) IPv4s or IPv6s for the external service--
portscontainer.portsPorts of external services--

Gonbad PrometheusRule

Section: gonbad.prometheusRule

ParameterTypeDescriptionDefault
enabledbooleanEnables this prometheusruletrue
tplstringTreat rules as helm templatefalse
intervalpositive integerInterval between each time prometheusRule.rules are run--
grafanaDomainstringgrafana domain for connection from prometheus to grafana--
ruleslistPrometheus Rules--
rules[].exprinteger or string(Required) Rule expression to calculated in prometheus--
rules[].alertstringIf set this rule will act as alert with given name--
rules[].recordstringIf set result of expr will saved in new metric with given name--
rules[].forstringHow long to wait before raising the alert. Must match the regular expression [0-9]+(ms\s\m\h)--
rules[].labelsmappingsLabels for this rule--
rules[].annotationsmappingsAnnotations for this rule--

Gonbad rawResources

Section: gonbad.rawResources

Raw kubernetes resources to add beside other generated resources. This section is a list of raw resources with following parameters

ParameterTypeDescriptionDefault
apiVersionstring(Required) apiVersion on raw resource--
kindstring(Required) kind of raw resource--
metadata.namestring(Required) name of raw resource--
metadata.namespacestringnamespace in which the raw resource will be created--
metadata.labelsmappingLabels of raw resource k8s.label regex--
metadata.annotationsmappingAnnotations of raw resource k8s.annotation regex--
*anyAny other parameter treated as the resource parameter and not validated in this chart--

Additional Parameters

The following objects, are not used directly. They are sub-types of the above objects.


Deployment strategy

section: deployment.strategy

Deployment strategy of a workload is used when the workload is reapplied or upgraded. A strategy is defined by:

ParameterTypeDescriptionDefault
typestringDeployment strategy; either Recreate or RollingUpdate. If type is set to Recreate, no additional properties is acceptedRollingUpdate
rollingUpdate.maxSurgestring or positive integerMaximum over replicaCount pods when doing a Rolling Update (in percent or positive integer)25%
rollingUpdate.maxUnavailablestring or positive integerMaximum unavailable pods when doing a RollingUpdate (in percent or positive integer)25%

Workload ImagePullSecret

ParameterTypeDescriptionDefault
namestring(Required) Name of Secret with type kubernetes.io/dockerconfigjson to be used or created--
registrystringRegistry for created Secret--
usernamestringUsername for created Secret--
passwordstringPassword for created Secret--

Workload HPA

section: workload.hpa

Create a HorizontalPodAutoscaler resource related to workload and configure it

ParameterTypeDescriptionDefault
minReplicasintegerMinimum replica set via hpa1
maxReplicasinteger(Required) Maximum replica set via hpa--
cpuAverageUtilizationintegershortcut for resource based cpu metric--
memoryAverageUtilizationintegershortcut for resource based memory metric--
metricslistList of metrics used for autoscaling--
metrics[].typestring(Required) one of Resource, Pods, Object, External--
metrics[].namestring(Required) metric name--
metrics[].metricSelectorobjectLabel selector for metric--
metrics[].targetobjectTarget quantity or percentage on which autoscaling occure. Only one of its childs could be set for each metrics--
metrics[].target.valuequantityExact value of metric, could be set for Resource, Object, External metrics only--
metrics[].target.averageValuequantitySum of metric value devided by pods number, could be set for all metrics--
metrics[].target.averageUtilizationpositive integerAverage utilization of resource over all pods, could be set only for Resource metric--
metrics[].describedObjectobjectDescribe another object in same namespace to get metrics for. could be set only for Object metric--

Workload PDB

sectionworkload.pdb

Create a PodDisruptionBudget resource related to workload and configure it

ParameterTypeDescriptionDefault
minAvailablepercentage or positive integerMinimum available pods when kubelet evict pods. (mutually exclusive with maxUnavailable)--
maxUnavailablepercentage or positive integerMaximum unavailable pods when kubelet evict pods. (mutually exclusive with minAvailable)--

Pod securityContext

section: workload.securityContext

pod.securityContext holds pod-level security attributes and common container settings. Some fields are also present in container.securityContext. Field values of container.securityContext take precedence over field values of pod.securityContext.

ParameterTypeDescriptionDefault
runAsUserpositive integerThe UID to run the entrypoint of the container process. Uses runtime default if unset--
runAsGrouppositive integerThe GID to run the entrypoint of the container process. Uses runtime default if unset--
runAsNonRootbooleanIndicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does.--
fsGrouppositive integerA special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod--
fsGroupChangePolicystringOne of Always, OnRootMismatch. fsGroupChangePolicy defines behavior of changing ownership and permission of the volume before being exposed inside Pod. This field will only apply to volume types which support fsGroup based ownership(and permissions)--

Valid additional parameters: kubectl explain pod.spec.securityContext


Container

ParameterTypeDescriptionDefault
enabledbooleanEnable/Disable container in pod manifesttrue
imagecontainer.imageThe image that the container is build of--
commandlist of stringsCommand to run when the container is run as the entrypoint (e.g. ["de.sh", "-v", "-c"])--
argslist of stringsArguments to pass to container.command--
envobjectMappings of environment variables to pass to the container, see container.env for samples--
envFromlist of container.envFromLoad all env from ConfigMap or Secret--
livenessProbecontainer.probeliveness prob definition--
readinessProbecontainer.probeReadiness prob definition--
startupProbecontainer.probeStartup prob definition--
resourcescontainer.resourcesResource requests and limits--
portscontainer.portsPorts definition--
lifecyclecontainer.lifecycleContainer lifecycle definition--
securityContextcontainer.securityContextContainer securityContext definition--
fileMountslistSingle file mountings definition--
fileMounts[].namestringStaticFile name--
fileMounts[].mountPathstringPath to mount the file--
fileMounts[].executablebooleanMount file as executable ( 0555 )false
volumeMountslistVolume mountings definition--
volumeMounts[].namestringStaticFile name--
volumeMounts[].mountPathstringPath to mount the volume--
volumeMounts[].subPathstringSubPath of volume to mount--
volumeMounts[].readOnlybooleanFlag to mount as readonlyfalse
orderpositive integerEnsure container order when creating k8s manifest--

Container image

section: container.image

ParameterTypeDescriptionDefault
repositorystring(Required) Repository from which the image is pulled, can contain the registry as well. e.g. https://docer.sabz.dev/grafana--
tagstring(Required)--
pullPolicystringEither Always or IfNotPresentIfNotPresent
registrystringRegistry address used for pulling the image, e.g. https://docker.io--

Container Env

section: workload.container.env

each env on workload.container can be a number, a string or an object described in below table to retrieve from other places like ConfigMap, note that only one of value, secretRef, configMapRef, resourceFieldRef and fieldRef can be set.

Envs are sorted as following groups, each group will sorted alphabetically:

  1. all envs which have order by their order except order: -1
  2. all unordered secretRef, configMapRef, resourceFieldRef and fieldRef envs
  3. all simple or value envs which doesn't have $( in them
  4. all simple or value envs which have $( in them
  5. all order: -1 envs
ParameterTypeDescriptionDefault
orderintegerEnsure env order when using kubernetes internal env templating $(...), Valid values are positive integers and -1 which means last--
valuestringExact value--
secretRefobjectTo retrieve value from Secret--
secretRef.namestring(Required) secret name--
secretRef.keystring(Required) key in the given secret--
secretRef.optionalbooleanSpecify whether the Secret or its key must be defined--
configMapRefobjectTo retrieve value from ConfigMap--
configMapRef.namestring(Required) configmap name--
configMapRef.keystring(Required) key in the given configmap--
configMapRef.optionalbooleanSpecify whether the ConfigMap or its key must be defined--
resourceFieldRefobjectTo retrieve value from ConfigMap--
resourceFieldRef.resourcestring(Required) resource name to use. Valid values are limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage--
resourceFieldRef.containerNamestringContainer name of which resource read
resourceFieldRef.divisorstringDivisor to normalize resource value
fieldRefobjectTo retrieve value from Pod manifest--
fieldRef.fieldPathstring(Required) Dotted path of which field in pod manifest--

Samples:

...:
  env:
    NUMBER: 123456
    SIMPLE: 'simple env value'

    SENTRY_DSN:
      configMapKeyRef:
        name: app-configmap
        key: sentry-dsn

    POSTGRESQL_PASSWORD:
      secretKeyRef:
        name: postgresql
        key: password

    POD_MEMORY_LIMIT:
      resourceFieldRef:
        resource: limits.memory

    POD_IP:
      fieldRef:
        fieldPath: status.podIP

    SIMPLE_ORDERED:
      value: foo
      order: 1

    POD_MEMORY_LIMIT_ORDERED:
      resourceFieldRef:
        resource: limits.memory
      order: 2

    COMPLEX:
      value: foo-$(SIMPLE_ORDERED)-$(POD_MEMORY_LIMIT_ORDERED)

    ANOTHER_COMPLEX:
      value: bar-$(POD_ID)
      order: -1 # -1 means last

Container envFrom

section: container.envFrom

For each envFrom only one of secretRef and configMapRef can be set.

ParameterTypeDescriptionDefault
secretRefobjectTo retrieve all key
from Secret
--
secretRef.namestring(Required) Secret name--
configMapRefobjectTo retrieve all key
from ConfigMap
--
configMapRef.namestring(Required) ConfigMap name--
prefixstringPrefix added to keys imported--

Samples:

...:
  envFrom:
    - secretRef:
        name: postgres-secret

    - configMapRef:
        name: deploy-configmap

    - configMapRef:
        name: django-configmap
      prefix: DJANGO_

Container Probes

section: container.startupProbe, container.livenessProbe, container.readinessProbe

Each container can have, liveness, readiness and startup probes. All these probes follow the same schema:

ParameterTypeDescriptionDefault
portstring or integer(Either this or command is Required) The port name or number to scan for probing--
enabledbooleanEnables the probe--
pathstringPath for the probe--
commandarray of strings(Either this or path is Required) The command list to check the probe--
httpHeadersmapping of stringsHTTP headers for the probe--
initialDelaySecondspositive integerInitial delay in seconds for the probe--
periodSecondspositive integerProbing interval--
timeoutSecondspositive integerProbe timeout--
successThresholdpositive integerMinimum consecutive successes for the probe to be considered successful after having failed. Minimum is 1--
failureThresholdpositive integerTry failureThreshold times before giving up. Minimum is 1--

Container Resources

section: container.resources

A container can have requests and limits for CPU and Memory, if requests is set, the specified amount is reserved for the container. Having set the limits, if more CPU is used, the container will be throttled, while if the memory is overused, the container is killed, and the pod might get evicted.

ParameterTypeDescriptionDefault
requests.cpupositive integerHow much cpu is requested for each pod; either core count (a positive number) or milicore (e.g. 200m or 1000m)--
requests.memorypositive integerHow much memory is requested for each pod; in Bytes. Accepts values like 100, 750Mi or 2Gi--
limits.cpupositive integerMaximum cpu allowed for the pod. either core count (a positive number) or milicore (e.g. 200m or 1000m)--
limits.memorypositive integerMaximum memory allowed for the pod; in Bytes. Accepts values like 100, 750Mi or 2Gi--

Container Ports

section: container.ports

Mapping of ports and their configs for containers' ports as well as creating Service, ServiceMonitor, etc. resources as a single, centralized point of truth.

For each mapping, the key is the port number, optionally suffixed with tcp or udp, e.g. 8080, 1080/tcp, 16049/udp and the value can be null, string (port name) or an object with the following parameters:

ParameterTypeDescriptionDefault
enabledbooleanEnables this port--
namestringName of this port--
protocolstringEither UDP or TCP--
numberpositive integerPort numberThe key of this object
nodePortpositive integerIf set, the port nodePort will be created and related configurations will be set in resources--
servicePortpositive integerNeeded if an Ingress is to be created for this port--
scrapePathstringcreate a serviceMonitor with this path and port name for prometheus to scrape--
scrapeTimeoutpositive integerTimeout for scrapePath used by prometheus operator--
scrapeIntervalpositive integerInterval for scrapePath used by prometheus operator--
scrapeExtraPropertiesobjectExtra ServiceMonitor.endpoint configuration--

Container Lifecycle

section: container.lifecycle

Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted. For each lifecycle handlers only one of exec , httpGet or tcpSocket could be defined at once.

ParameterTypeDescriptionDefault
preStopobjectPreStop is called immediately before a container is terminated due to an API request or management event--
postStartobjectPostStart is called immediately after a container is created. inner structure is same as preStop--
preStop.execobjectExec specifies the action to take--
preStop.exec.commandlist of stringsCommand is the command line to execute inside the container, the working directory for the command is root--
preStop.httpGetobjectHTTPGet specifies the http request to perform--
preStop.httpGet.portinteger or string(Required) Name or number of the port to access on the container--
preStop.httpGet.hoststringHost name to connect to, defaults to the pod IP. You probably want to set Host in httpHeaders instead.--
preStop.httpGet.schemastringScheme to use for connecting to the hostHTTP
preStop.tcpSecketobjectTCPSocket specifies an action involving a TCP port--
preStop.tcpSecket.portinteger or string(Required) Name or number of the port to access on the container--
preStop.tcpSecket.hoststringHost name to connect to, defaults to the pod IP.--

Container securityContext

section: container.securityContext

SecurityContext holds security configuration that will be applied to a container. Some fields are present in both container.securityContext and pod.securityContext. When both are set, the values in container.securityContext take precedence.

ParameterTypeDescriptionDefault
runAsUserpositive integerThe UID to run the entrypoint of the container process. Uses runtime default if unset--
runAsGrouppositive integerThe GID to run the entrypoint of the container process. Uses runtime default if unset--
runAsNonRootbooleanIndicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does.--
privilegedbooleanRun container in privileged mode. Processes in privileged containers are essentially equivalent to root on the host--
allowPrivilegeEscalationbooleanAllowPrivilegeEscalation controls whether a process can gain more privileges than its parent process. This bool directly controls if the no_new_privs flag will be set on the container process. AllowPrivilegeEscalation is true always when the container is: 1) run as Privileged 2) has CAP_SYS_ADMIN--
readOnlyRootFilesystembooleanWhether this container has a read-only root filesystem--
capabilitiesobjectThe capabilities to add/drop when running containers. Defaults to the default set of capabilities granted by the container runtime--
capabilities.addlist of stringscapabilities to add--
capabilities.droplist of stringscapabilities to drop--

Valid additional parameters: kubectl explain pod.spec.containers.securityContext


Statefulset volumeClaimTemplates

section: statefulset.volumeClaimTemplates

Creating a Persistent Volume Claim (PVC) per pod in SetatefulSets require configuring its volumeClaimTemplates. Each statefulset workload in gonbad could have volumeClaimTemplates. A mapping with volume names as its keys and object with following parameters as value.

ParameterTypeDescriptionDefault
enabledbooleanEnables this volumeClaimTemplatetrue
sizepositive integer or string(Required) The size of PVC. (eg. 1024 or 2Gi)--
accessModestring(Required) Access Mode for this PVC; one of ReadOnlyMany, ReadWriteOnce or ReadWriteOnce--
storageClassstringstorageClass of ths PVC--

Common Regexes

Regex nameRegexDocumentation
k8s.label.key^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?([A-Za-z0-9][A-Za-z0-9_.-]*)?[A-Za-z0-9]$link
k8s.label.value^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$link
k8s.annotation.key^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?([A-Za-z0-9][A-Za-z0-9_.-]*)?[A-Za-z0-9]$link
k8s.annotation.valuestringlink

Samples

Here some samples to demonstrate some aspects of this chart

Hello World Sample

#!/usr/bin/env -S helm template hello-world-sample genpack -f
gonbad:
  workloads:
    web:
      kind: deployment
      replicaCount: 1
      containers:
        web:
          image:
            registry: docker.io # optional, defaults to ''
            repository: tutum/hello-world
            tag: latest # optional, defaults to latest
          ports:
            80:
              name: http
              scrapePath: /metrics # optional, will create a ServiceMonitor object

  ingresses:
    web:
      workloadName: web
      servicePort: http
      hosts:
        - host: hello-world.example.dev

Volume Sample

#!/usr/bin/env -S helm template volume-sample genpack -f
gonbad:
  workloads:
    web:
      kind: deployment
      replicaCount: 1
      containers:
        web:
          image:
            repository: nginx
          ports:
            80: http
          volumeMounts:
            - name: www-vol
              mountPath: /var/lib/nginx/sites/default/
            - name: existing-pvc-vol
              mountPath: /var/lib/nginx/sites/another/
            - name: config-vol
              mountPath: /etc/nginx/

  ingresses:
    web:
      workloadName: web
      servicePort: http
      hosts:
        - host: example.dev

  volumes:
    www-vol:
      type: persistentVolumeClaim
      size: 10Gi
      accessMode: ReadWriteOnce
      storageClass: zfs-hdd

    existing-pvc-vol:
      type: existingPVC
      name: pvc-fullname
      readOnly: false

    config-vol:
      type: configMap
      name: nginx-configs

NodePort Sample

#!/usr/bin/env -S helm template nodeport-sample genpack -f
gonbad:
  workloads:
    nginx:
      kind: deployment
      service:
        type: NodePort
      containers:
        nginx:
          image:
            repository: nginx
          ports:
            80:
              name: http
              nodePort: 30080
            443:
              name: https
              nodePort: 30443

    coredns:
      kind: deployment
      service:
        type: NodePort
      containers:
        coredns:
          image:
            repository: coredns
          ports:
            53/tcp:
              nodePort: 30053
            53/udp:
              nodePort: 30053

ExternalServices Sample

#!/usr/bin/env -S helm template external-service-sample genpack -f
gonbad:
  externalServices:
    kuma:
      externalIPs:
        - 1.2.3.4
      ports:
        443:
          enabled: true
          name: https
          scrapePath: /metrics

last update: 2023-02-14