Skip to content

camptocamp/helm-custom-pod

Repository files navigation

Kubernetes HELM chart for a simple custom application

With this chart you can easily deploy a simple custom application on Kubernetes, with only configuration.

This will create a Deployment, a Service, a Pod Disruption Budget, optionally an Ingress, optionally a Service Account, optionally a Pod Monitor (for Prometheus).

See as example.

Goals

The goals of this chart is double, it's to be able to deploy all the needed Kubernetes object to deploy a simple Pod, and to be able one values file for the application, and one for the environment specific like integration and production.

Schema documentation

Documentation based on the schema defined in values.md.

Contributing

Install the pre-commit hooks:

pip install pre-commit
pre-commit install --allow-missing-config

Helpers present in this Chart

application.serviceAccountName

Create the name of the service account to use.

Parameters:

  • root: the root object, should be $.

Used values:

application.podConfig

Create the pod configuration.

Parameters:

  • root: the root object, should be $.
  • service: the service object.
  • affinitySelector: the affinity selector (optional).

Used values:

Used Functions:

  • application.serviceAccountName

application.containerConfig

Create the container configuration.

Parameters:

  • root: the root object, should be $.
  • container: the container definition.

Used values:

Used functions:

  • common.oneEnv

application.podMetadata

Create the metadata for the Pod.

Parameters:

  • service: the service object.

Used values:

Used functions:

  • common.selectorLabels

application.oneEnv

Create one environment variable.

Parameters:

Used functions:

  • common.fullname

Environment variables

In the container config you should define an env and configMapNameOverride dictionaries with, for the env:

The hey represent the environment variable name, and the value is a dictionary with a type key.

It the type is value (default) you can specify the value of the environment variable in value, example:

env:
  VAR:
    type: value # default
    value: toto

If the type is none the environment variable will be ignored, example:

env:
  VAR:
    type: none

If the type is configMap or secret you should have an name with the ConfigMap or Secret name, and a key to know with key you want to get, example:

env:
  VAR:
    type: configMap # or secret
    name: configmap-name
    key: key-in-configmap

We can also easily linked the internal ConfigMap or Secret with the self[-metadata] name, example:

env:
  SELF_CONFIGMAP:
    type: configMap
    name: self
    key: <key>
  SELF_SECRET:
    type: secret
    name: self
    key: <key>
  SELF_METADATA:
    type: configMap
    name: self-metadata
    key: CHART_NAME # or anythings else

We also have an attribute order to be able to use the $(env) syntax, example:

env:
  AA_VAR:
    value: aa$(ZZ_VAR)aa
    order: 1
  ZZ_VAR:
    value: zz

Currently we put at first the order <= 0 and at last the order > 0, default is 0 (first).

Image name

In the container config you should define the image like this:

image:
  repository: camptocamp/mapserver
  tag: latest
  sha:
  pullPolicy: IfNotPresent

The sha will be taken in priority of the tag

Pod affinity

In the podConfig you can have an affinitySelector to be able to configure a podAntiAffinity.

Example:

application.podConfig" ( dict
  "root" .
  "service" .Values
  "affinitySelector" (dict
    "app.kubernetes.io/instance" .Release.Name
    "app.kubernetes.io/name" ( include "common.name" . )
    "app.kubernetes.io/component" "<servicename>"
  )
)