base
by Dysnix
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
| 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 for all deployed objects
| Name | Description | Value |
|---|---|---|
kubeVersion | Override Kubernetes version | "" |
nameOverride | String to partially override common.names.fullname template (will maintain the release name) | "" |
fullnameOverride | String to fully override common.names.fullname template | "" |
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 | [] |
Default Component default parameters
| Name | Description | Value |
|---|---|---|
defaultComponent.enabled | Create the default Pod | true |
defaultComponent.controller | Default Pod controller type (case-sensetive) | Deployment |
Component specific parameters
| Name | Description | Value |
|---|---|---|
image.registry | Image registry | "" |
image.repository | Image name | foo/bar |
image.tag | Image tag | latest |
image.pullPolicy | Image pull policy | "" |
image.pullSecrets | Image pull secrets | [] |
replicaCount | Number of pod replicas to deploy | 1 |
containerPorts | Container Ports definition (dict form is also supported) | [] |
livenessProbe.enabled | Enable livenessProbe on containers | false |
livenessProbe.initialDelaySeconds | Initial delay seconds for livenessProbe | 20 |
livenessProbe.periodSeconds | Period seconds for livenessProbe | 10 |
livenessProbe.timeoutSeconds | Timeout seconds for livenessProbe | 5 |
livenessProbe.failureThreshold | Failure threshold for livenessProbe | 3 |
livenessProbe.successThreshold | Success threshold for livenessProbe | 1 |
readinessProbe.enabled | Enable readinessProbe on containers | false |
readinessProbe.initialDelaySeconds | Initial delay seconds for readinessProbe | 20 |
readinessProbe.periodSeconds | Period seconds for readinessProbe | 10 |
readinessProbe.timeoutSeconds | Timeout seconds for readinessProbe | 5 |
readinessProbe.failureThreshold | Failure threshold for readinessProbe | 3 |
readinessProbe.successThreshold | Success threshold for readinessProbe | 1 |
startupProbe.enabled | Enable startupProbe on containers | false |
startupProbe.initialDelaySeconds | Initial delay seconds for startupProbe | 20 |
startupProbe.periodSeconds | Period seconds for startupProbe | 10 |
startupProbe.timeoutSeconds | Timeout seconds for startupProbe | 5 |
startupProbe.failureThreshold | Failure threshold for startupProbe | 3 |
startupProbe.successThreshold | Success threshold for startupProbe | 1 |
customLivenessProbe | Custom livenessProbe that overrides the default one | {} |
customReadinessProbe | Custom readinessProbe that overrides the default one | {} |
customStartupProbe | Custom startupProbe that overrides the default one | {} |
resources.limits | The resources limits for the containers | {} |
resources.requests | The requested resources for the containers | {} |
podSecurityContext.enabled | Enabled pods' Security Context | true |
podSecurityContext.fsGroup | Set pod's Security Context fsGroup | 1001 |
containerSecurityContext.enabled | Enabled containers' Security Context | true |
containerSecurityContext.propogated | Propogate containerSecurityContext to all containers podContainers (when enabled==propogated==true) | true |
containerSecurityContext.runAsUser | Set containers' Security Context runAsUser | 1001 |
containerSecurityContext.runAsNonRoot | Set containers' Security Context runAsNonRoot | true |
command | Override default container command (useful when using custom images) | [] |
args | Override 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartbase is pinned at v0.3.12 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