st-common

by Startechnica

Helm chartv0.1.21App 0.1.21Apache-2.0Verified publisher

A Library Helm Chart for grouping common logic between Startechnica charts. This chart is not deployable by itself.

About this chart

Startechnica Common Library Chart

A Helm Library Chart for grouping common logic between Startechnica charts.

TL;DR

dependencies:
  - name: st-common
    version: "*"
    repository: https://startechnica.github.io/apps
helm dependency update
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "st-common.names.fullname" . }}
data:
  myvalue: "Hello World"

Introduction

This chart provides a common template helpers which can be used to develop new charts using Helm package manager.

Prerequisites

  • Kubernetes 1.20+
  • Helm 3.2.0+

Parameters

Every helper returns either a string/dict for direct embedding, or false (literal) when the capability isn't available — letting callers do {{- if (include "st-common.capabilities.X.apiVersion" .) }}…{{- end }} cleanly.

Names

Helper identifierDescriptionExpected Input
st-common.names.nameExpand the name of the chart or use .Values.nameOverride. Chart context
st-common.names.fullnameCreate a default fully qualified app name. Chart context
st-common.names.namespaceAllow the release namespace to be overridden via .Values.namespaceOverride. Chart context
st-common.names.fullname.namespaceCreate a fully qualified app name with installation's namespace appended. Chart context
st-common.names.chartChart name plus version. Chart context
st-common.names.dependency.fullnameCreate a default fully qualified dependency namedict "chartName" "dep" "chartValues" .Values.dep "context" $
st-common.names.dotenvName of a generated .env ConfigMap (<fullname>-dotenv). Chart context
st-common.names.envvarsName of a generated env-vars ConfigMap (<fullname>-envvars). Chart context
st-common.names.gateway.nameResolve a Gateway resource name (override-aware). Chart context
st-common.names.gateway.namespaceResolve a Gateway resource namespace (override-aware). Chart context
st-common.names.gatewayWaypoint.nameResolve a Gateway-API Waypoint resource name. Chart context
st-common.names.gatewayWaypoint.namespaceResolve a Gateway-API Waypoint resource namespace. Chart context

Labels

Helper identifierDescriptionExpected Input
st-common.labels.standardKubernetes recommended labels (app.kubernetes.io/*) + custom labelsdict "customLabels" .Values.X "context" $
st-common.labels.matchLabelsLabels for deploy.spec.selector.matchLabels / svc.spec.selector (subset of standard)dict "customLabels" .Values.X "context" $

Affinities

Helper identifierDescriptionExpected Input
st-common.affinities.nodes.softReturn a soft nodeAffinity definitiondict "key" "FOO" "values" (list "BAR" "BAZ")
st-common.affinities.nodes.hardReturn a hard nodeAffinity definitiondict "key" "FOO" "values" (list "BAR" "BAZ")
st-common.affinities.nodesReturn a nodeAffinity definition (soft or hard)dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")
st-common.affinities.topologyKeyReturn a topologyKey definitiondict "topologyKey" "FOO"
st-common.affinities.pods.softReturn a soft podAffinity/podAntiAffinity definitiondict "component" "FOO" "context" $
st-common.affinities.pods.hardReturn a hard podAffinity/podAntiAffinity definitiondict "component" "FOO" "context" $
st-common.affinities.podsReturn a podAffinity/podAntiAffinity definitiondict "type" "soft" "component" "FOO" "context" $

Gateway

Helper identifierDescriptionExpected Input
st-common.gateway.clusterDomainReturn gateway cluster domain. Chart context
st-common.gateway.fullnameCreate a default fully qualified gateway name. Chart context
st-common.gateway.namespaceAllow the gateway namespace to be overridden. Chart context
st-common.gatewayWaypoint.fullnameCreate a default fully qualified Gateway-API Waypoint name. Chart context
st-common.gatewayWaypoint.namespaceAllow the Gateway-API Waypoint namespace to be overridden. Chart context

Images

Helper identifierDescriptionExpected Input
st-common.images.imageBuild a fully-qualified image reference (registry/repository:tag or @digest)dict "imageRoot" .Values.image "global" .Values.global
st-common.images.versionResolve image tag (.tag or .digest).Values.image
st-common.images.pullSecretsRender imagePullSecrets: block from per-image and global pull secretsdict "images" (list .Values.image) "context" $
st-common.images.renderPullSecretsSame as pullSecrets but skips the YAML key (imagePullSecrets:) — emits the list onlydict "images" (list .Values.image) "context" $

Ingress

Helper identifierDescriptionExpected Input
st-common.ingress.backendBuild a backend: block (v1 or v1beta1 shape based on cluster version)dict "serviceName" "svc" "servicePort" 80 "context" $
st-common.ingress.supportsPathTypeReturns true when networking.k8s.io/v1 Ingress is available. Chart context
st-common.ingress.supportsIngressClassnameReturns true when Ingress.spec.ingressClassName is supported. Chart context
st-common.ingress.certManagerRequestRender cert-manager annotations on an Ingress when ACME is configureddict "annotations" .Values.ingress.annotations

Resources / Storage / RBAC

Helper identifierDescriptionExpected Input
st-common.resources.presetResolve a resource preset (nano/micro/small/medium/large/xlarge/2xlarge) into requests/limitsdict "type" "small"
st-common.storage.classResolve storageClassName (component-level → global.defaultStorageClass → "")dict "persistence" .Values.persistence "global" .Values.global
st-common.rbac.serviceAccountNameResolve a ServiceAccount name (override-aware, falls back to chart fullname when create=true)dict "serviceAccount" .Values.serviceAccount "context" $

Secrets

Helper identifierDescriptionExpected Input
st-common.secrets.nameResolve a Secret name (existingSecret wins, else <fullname>-suffix)dict "existingSecret" .Values.X.existingSecret "defaultNameSuffix" "creds" "context" $
st-common.secrets.keyResolve a Secret data-key name (existingSecretKey wins, else default)dict "existingSecret" .Values.X.existingSecret "key" "password"
st-common.secrets.lookupLook up a Secret's value with lookup (returns "" if missing)dict "secret" "name" "namespace" "ns" "key" "k" "context" $
st-common.secrets.existsReturns true if a Secret with the given name exists in the namespacedict "secret" "name" "namespace" "ns" "context" $
st-common.secrets.passwords.manageGenerate or re-use a password from an existing Secret (idempotent across upgrades)dict "secret" "name" "key" "k" "providedValues" (list "X.password") "length" 16 "strong" true "context" $

tplvalues / Utils

Helper identifierDescriptionExpected Input
st-common.tplvalues.renderRender a string/list/dict that may contain tpl directives, against a chart contextdict "value" .Values.X "context" $
st-common.tplvalues.mergeDeep-merge a list of dicts (first-wins), render via tpl against a contextdict "values" (list .Values.A .Values.B) "context" $
st-common.tplvalues.merge-overwriteDeep-merge a list of dicts (last-wins), render via tpl against a contextdict "values" (list .Values.A .Values.B) "context" $
st-common.utils.createUriBuild a URI of the form scheme://host[:port][/path]dict "scheme" "https" "host" "h" "port" "443" "path" "/api"
st-common.utils.stringOrNumberForce-render a value as a YAML string or number (preserves type)`dict "value" .Values.X

Deploy st-common with OpenTenant

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