tpl

by tjungbauer

Helm chartv1.0.31Apache-2.0Verified publisher

A library that shall collect certain templates to reuse them among different charts.

About this chart

tpl

Description

A library that shall collect certain templates to reuse them among different charts.

The tpl chart is a Helm library chart that provides reusable templates for common Kubernetes configurations. It currently includes templates for:

  • Tolerations
  • Resource requests/limits
  • Node selectors
  • Service accounts
  • Labels and selectors
  • Namespace annotations
  • Additional annotations/labels
  • Match expressions/labels
  • Sleep timer for jobs
  • security context
  • Pod security context

Instead of defining them in other Charts multiple times, it is possible to simply include the template.

Dependencies

This chart has the following dependencies:

RepositoryNameVersion

No dependencies

Maintainers

NameEmailUrl
tjungbauer[email protected]https://blog.stderr.at/

Sources

Source:

Source code: https://github.com/tjungbauer/helm-charts/tree/main/charts/tpl

Values

KeyTypeDefaultDescription
affinityobject{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"podAffinityTerm":{"labelSelector":{"matchLabels":{"app":"test-app"}},"topologyKey":"kubernetes.io/hostname"},"weight":100}]}}Pod affinity rules Example include: {{- if .Values.affinity }} {{ include "tpl.affinity" .Values.affinity
argocdMetadataobject{"extra":{"my-annotation":"example"},"syncOptions":"SkipDryRunOnMissingResource=true","syncWave":3}Argo CD sync metadata for any GitOps-managed resource (not Application CRs). Example include (operator CR): metadata: annotations: {{- include "tpl.argocdMetadata" (dict "syncWave" .Values.central.syncwave "extra" .Values.central.additionalAnnotations)
argocd_applicationsobject{"example-app":{"annotations":{},"destination":{"namespace":"guestbook","server":"https://kubernetes.default.svc"},"enabled":false,"finalizers":null,"ignoreDifferences":{},"info":[],"labels":{},"namespace":"openshift-gitops","project":"default","source":{"chart":"","helm":{"apiVersions":["traefik.io/v1alpha1/TLSOption","v1/Service"],"fileParameters":[{"name":"config","path":"files/config.json"}],"ignoreMissingValueFiles":false,"kubeVersion":"1.30.0","namespace":"custom-namespace","parameters":[{"forceString":true,"name":"nginx-ingress.enabled","value":"true"},{"name":"replicas","value":"3"}],"passCredentials":false,"releaseName":"my-release","skipCrds":false,"skipSchemaValidation":false,"valueFiles":["values.yaml","values-customyaml"],"values":"ingress:\n enabled: true\n path: /\n hosts:\n - mydomain.example.com\n annotations:\n kubernetes.io/ingress.class: nginx\n kubernetes.io/tls-acme: \"true\"\n labels: {}\n tls:\n - secretName: mydomain-tls\n hosts:\n - mydomain.example.com\n","valuesObject":{"ingress":{"annotations":{"kubernetes.io/ingress.class":"nginx","kubernetes.io/tls-acme":"true"},"enabled":true,"hosts":["mydomain.example.com"],"labels":{},"path":"/","tls":[{"hosts":["mydomain.example.com"],"secretName":"mydomain-tls"}]}},"version":"v3"},"path":"guestbook","repositoryURL":"https://github.com/argoproj/argocd-example-apps.git","targetRevision":"HEAD"},"syncPolicy":{"automated":{"allowEmpty":false,"prune":false,"selfHeal":false},"managedNamespaceMetadata":{},"retry":{"backoff":{"duration":"5s","factor":2,"maxDuration":"3m"},"limit":5},"syncOptions":[]}}}ArgoCD Application Example include: {{- if .Values.argocd_applications }} {{ include "tpl.argocdApplication" .Values.argocd_applications
argocd_applications.example-app.annotationsobject{}Add annotations to your application object. @default: {}
argocd_applications.example-app.destinationobject{"namespace":"guestbook","server":"https://kubernetes.default.svc"}Destination configuration
argocd_applications.example-app.destination.namespacestring"guestbook"The namespace will only be set for namespace-scoped resources that have not set a value for .metadata.namespace @default: ""
argocd_applications.example-app.destination.serverstring"https://kubernetes.default.svc"Use either server OR name, not both cluster API URL @default: "https://kubernetes.default.svc"
argocd_applications.example-app.enabledboolfalseEnable this application @default: false
argocd_applications.example-app.finalizersstringnilAdd this finalizer ONLY if you want these to cascade delete. @default: []
argocd_applications.example-app.ignoreDifferencesobject{}Will ignore differences between live and desired states during the diff. Note that these configurations are not used during the sync process unless the RespectIgnoreDifferences=true sync option is enabled. default: {}
argocd_applications.example-app.infolist[]Extra information to show in the Argo CD Application details tab @default: []
argocd_applications.example-app.labelsobject{}Add labels to your application object. @default: {}
argocd_applications.example-app.namespacestring"openshift-gitops"Basic application metadata @default: "openshift-gitops"
argocd_applications.example-app.projectstring"default"Alternatively, you can use background cascading deletion - resources-finalizer.argocd.argoproj.io/background -- Argo CD Project the application belongs to @default: "default"
argocd_applications.example-app.source.chartstring""Set this when pulling directly from a Helm repo. DO NOT set for git-hosted Helm charts. @default: ""
argocd_applications.example-app.source.helmobject{"apiVersions":["traefik.io/v1alpha1/TLSOption","v1/Service"],"fileParameters":[{"name":"config","path":"files/config.json"}],"ignoreMissingValueFiles":false,"kubeVersion":"1.30.0","namespace":"custom-namespace","parameters":[{"forceString":true,"name":"nginx-ingress.enabled","value":"true"},{"name":"replicas","value":"3"}],"passCredentials":false,"releaseName":"my-release","skipCrds":false,"skipSchemaValidation":false,"valueFiles":["values.yaml","values-customyaml"],"values":"ingress:\n enabled: true\n path: /\n hosts:\n - mydomain.example.com\n annotations:\n kubernetes.io/ingress.class: nginx\n kubernetes.io/tls-acme: \"true\"\n labels: {}\n tls:\n - secretName: mydomain-tls\n hosts:\n - mydomain.example.com\n","valuesObject":{"ingress":{"annotations":{"kubernetes.io/ingress.class":"nginx","kubernetes.io/tls-acme":"true"},"enabled":true,"hosts":["mydomain.example.com"],"labels":{},"path":"/","tls":[{"hosts":["mydomain.example.com"],"secretName":"mydomain-tls"}]}},"version":"v3"}Helm source configuration @default: {}
argocd_applications.example-app.source.helm.apiVersionslist["traefik.io/v1alpha1/TLSOption","v1/Service"]You can specify the Kubernetes resource API versions to pass to Helm when templating manifests. By default, Argo CD uses the API versions of the target cluster. The format is [group/]version/kind. @default: []
argocd_applications.example-app.source.helm.kubeVersionstring"1.30.0"You can specify the Kubernetes API version to pass to Helm when templating manifests. By default, Argo CD uses the Kubernetes version of the target cluster. The value must be semver formatted. Do not prefix with v. @default: ""
argocd_applications.example-app.source.helm.namespacestring"custom-namespace"Optional namespace to template with. If left empty, defaults to the app's destination namespace. @default: ""
argocd_applications.example-app.source.helm.parameterslist[{"forceString":true,"name":"nginx-ingress.enabled","value":"true"},{"name":"replicas","value":"3"}]Extra parameters to set (same as setting through values.yaml, but these take precedence) @default: []
argocd_applications.example-app.source.helm.releaseNamestring"my-release"Release name override (defaults to application name) @default: ""
argocd_applications.example-app.source.helm.valueFileslist["values.yaml","values-customyaml"]Value files to use for the Helm release @default: []
argocd_applications.example-app.source.pathstring"guestbook"This has no meaning for Helm charts pulled directly from a Helm repo instead of git.
argocd_applications.example-app.source.repositoryURLstring"https://github.com/argoproj/argocd-example-apps.git"Can point to either a Helm chart repo or a git repo.
argocd_applications.example-app.source.targetRevisionstring"HEAD"revision, For Helm, this refers to the chart version.
argocd_applications.example-app.syncPolicyobject{"automated":{"allowEmpty":false,"prune":false,"selfHeal":false},"managedNamespaceMetadata":{},"retry":{"backoff":{"duration":"5s","factor":2,"maxDuration":"3m"},"limit":5},"syncOptions":[]}Sync policy configuration
argocd_applications.example-app.syncPolicy.automatedobject{"allowEmpty":false,"prune":false,"selfHeal":false}automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using retry field. @default: {}
argocd_applications.example-app.syncPolicy.automated.allowEmptyboolfalseAllows deleting all application resources during automatic syncing ( false by default ). @default: false
argocd_applications.example-app.syncPolicy.automated.pruneboolfalse# Specifies if resources should be pruned during auto-syncing ( false by default ). @default: false
argocd_applications.example-app.syncPolicy.automated.selfHealboolfalseSpecifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ). @default: false
argocd_applications.example-app.syncPolicy.managedNamespaceMetadataobject{}Sets the metadata for the application namespace. Only valid if CreateNamespace=true (see above), otherwise it is ignored. @default: {}
argocd_applications.example-app.syncPolicy.retryobject{"backoff":{"duration":"5s","factor":2,"maxDuration":"3m"},"limit":5}Retry configuration for failed syncs. @default: {}
argocd_applications.example-app.syncPolicy.retry.backoffobject{"duration":"5s","factor":2,"maxDuration":"3m"}Backoff configuration for failed sync attempts @default: {}
argocd_applications.example-app.syncPolicy.retry.backoff.durationstring"5s"the amount to back off. Default unit is seconds, but could also be a duration (e.g. "2m", "1h")# duration between retries
argocd_applications.example-app.syncPolicy.retry.backoff.factorint2a factor to multiply the base duration after each failed retry
argocd_applications.example-app.syncPolicy.retry.backoff.maxDurationstring"3m"the maximum amount of time allowed for the backoff strategy
argocd_applications.example-app.syncPolicy.retry.limitint5Number of failed sync attempt retries; unlimited number of attempts if less than 0 @default: 0
argocd_applications.example-app.syncPolicy.syncOptionslist[]Sync options which modifies sync behavior The following can be set (see: https://argo-cd.readthedocs.io/en/stable/operator-manual/sync-options/) - Validate=true ... disables resource validation (equivalent to 'kubectl apply --validate=false') ( true by default ). - CreateNamespace=true ... Namespace Auto-Creation ensures that namespace specified as the application destination exists in the destination cluster. - PrunePropagationPolicy=foreground ... Supported policies are background, foreground and orphan. - PruneLast=true ... Allow the ability for resource pruning to happen as a final, implicit wave of a sync operation - RespectIgnoreDifferences=true ... When syncing changes, respect fields ignored by the ignoreDifferences configuration - ApplyOutOfSyncOnly=true ... Only sync out-of-sync resources, rather than applying every object in the application @default: []
matchExpressionslist[{"key":"kubernetes.io/metadata.name","operator":"NotIn","values":["kube-system","openshift*","default","kubde-info"]}]Deine a metchExpression to use key, oeprator, value pairs. Example include (used in chart admin-networkpolicies) spec: subject: {{- if .subject.namespaces }} namespaces: {{- if .subject.namespaces.matchExpressions }} matchExpressions: {{- range .subject.namespaces.matchExpressions }} {{- include "tpl.matchExpressions" .

Deploy tpl with OpenTenant

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