base

by Dysnix

Helm chartv0.3.12App 0.1.0Verified publisher

Generic base Helm chart for Kubernetes Applications

About this chart

Base

base is a library Helm chart. It aims to provide a value interface for resources generation from dependent charts.

Create a dependant chart

Create a chart from dysnix base:

CHART_NAME=mychart
mkdir -p $CHART_NAME/templates
( cd $CHART_NAME;  curl -sSO# https://raw.githubusercontent.com/dysnix/charts/main/dysnix/base/values.yaml )

cat <<EHD > $CHART_NAME/Chart.yaml
apiVersion: v2
name: $CHART_NAME
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "0.1.0"
dependencies:
  - name: common
    repository: https://charts.bitnami.com/bitnami
    tags:
      - bitnami-common
    version: 1.10.x
  - name: base
    version: 0.3.x
    repository: https://dysnix.github.io/charts
    tags:
      - dysnix-base
EHD

cat <<EHD > $CHART_NAME/templates/all.yaml
{{/* vim: set filetype=mustache: */}}
{{- include "base.component.default" $ -}}
EHD

Introduction

This chart provides library templates which are meant to deploy various number of Kubernetes resources using the Helm package manager. Base provides a rich set of templates to generate a component or multiple components along with the desired resources.

Unlike bitnami chart template which is used for charts generation and their further modification, base encourages "use values first" approach. So base chart is used as a library chart with its templates providing comprehensive resource generation facilities such to get Deployment(s), Service(s) etc up and running. This can be achieved simply by modifying values.yaml file first. At the same time dependant charts might add, customize its own values and resources as needed.

base chart has a concept of component which represents a set of chart resources grouped by the same component name. Resources such as Deployment, ServiceAccount, PersistentVolumeClaim are groupped together by mixing "common component" part into its' names, resources of non-default component also shipped with the additional label set - app.kubernetes.io/component: component_name.

Prerequisites

  • Kubernetes 1.18+
  • Helm 3.5.0

Usage

To generate the default component resources use:

{{- include "base.component.default" $ -}}

additional components can be generated using:

{{- include "base.component" (dict "value" .Values.componentX "component" "componentx" "context" $) -}}

Again there's posibility to use resource template such as base.service or base.deployment directly in dependant charts.

Chart configuration

The Parameters section provides a full set of configuration parameters which define the bahaviour for dependant charts. Modify values.yaml to define resources configuration logic specific for the chart being developed.

Service configuration

Configuration of a service has two forms: map and list. Map is a simplified form, works only for TCP ports and ports where targetPort matches the containerPort.

containerPorts:
  rest: 8080

# Only relevant for ports specified in the map form
nodePorts:
  grpc: 30100

service:
  type: NodePort
  ports:
    http: rest
    grpc: 443

The above will create as a NodePort service (http goes to 8080, grpc to 443). Note that target port (such as rest in the above example) is looked up in .containerPorts, .podContainers.*.ports and .sidecar.*.ports.

Use list form to have more precise control over the ports configuration:

containerPorts:
  rest: 8080

service:
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: rest
      nodePort: 30100

Parameters

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 for all deployed objects

NameDescriptionValue
kubeVersionOverride Kubernetes version""
nameOverrideString to partially override common.names.fullname template (will maintain the release name)""
fullnameOverrideString to fully override common.names.fullname template""
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[]

Default Component default parameters

NameDescriptionValue
defaultComponent.enabledCreate the default Podtrue
defaultComponent.controllerDefault Pod controller type (case-sensetive)Deployment

Component specific parameters

NameDescriptionValue
image.registryImage registry""
image.repositoryImage namefoo/bar
image.tagImage taglatest
image.pullPolicyImage pull policy""
image.pullSecretsImage pull secrets[]
replicaCountNumber of pod replicas to deploy1
containerPortsContainer Ports definition (dict form is also supported)[]
livenessProbe.enabledEnable livenessProbe on containersfalse
livenessProbe.initialDelaySecondsInitial delay seconds for livenessProbe20
livenessProbe.periodSecondsPeriod seconds for livenessProbe10
livenessProbe.timeoutSecondsTimeout seconds for livenessProbe5
livenessProbe.failureThresholdFailure threshold for livenessProbe3
livenessProbe.successThresholdSuccess threshold for livenessProbe1
readinessProbe.enabledEnable readinessProbe on containersfalse
readinessProbe.initialDelaySecondsInitial delay seconds for readinessProbe20
readinessProbe.periodSecondsPeriod seconds for readinessProbe10
readinessProbe.timeoutSecondsTimeout seconds for readinessProbe5
readinessProbe.failureThresholdFailure threshold for readinessProbe3
readinessProbe.successThresholdSuccess threshold for readinessProbe1
startupProbe.enabledEnable startupProbe on containersfalse
startupProbe.initialDelaySecondsInitial delay seconds for startupProbe20
startupProbe.periodSecondsPeriod seconds for startupProbe10
startupProbe.timeoutSecondsTimeout seconds for startupProbe5
startupProbe.failureThresholdFailure threshold for startupProbe3
startupProbe.successThresholdSuccess threshold for startupProbe1
customLivenessProbeCustom livenessProbe that overrides the default one{}
customReadinessProbeCustom readinessProbe that overrides the default one{}
customStartupProbeCustom startupProbe that overrides the default one{}
resources.limitsThe resources limits for the containers{}
resources.requestsThe requested resources for the containers{}
podSecurityContext.enabledEnabled pods' Security Contexttrue
podSecurityContext.fsGroupSet pod's Security Context fsGroup1001
containerSecurityContext.enabledEnabled containers' Security Contexttrue
containerSecurityContext.propogatedPropogate containerSecurityContext to all containers podContainers (when enabled==propogated==true)true
containerSecurityContext.runAsUserSet containers' Security Context runAsUser1001
containerSecurityContext.runAsNonRootSet containers' Security Context runAsNonRoottrue
commandOverride default container command (useful when using custom images)[]
argsOverride default container args (useful when using custom images)

Deploy base with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has base 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 chartbase is pinned at v0.3.12 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