tpl
by tjungbauer
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:
| Repository | Name | Version |
|---|
No dependencies
Maintainers
| Name | Url | |
|---|---|---|
| tjungbauer | [email protected] | https://blog.stderr.at/ |
Sources
Source:
- https://github.com/tjungbauer/helm-charts
- https://charts.stderr.at/
- https://github.com/tjungbauer/openshift-clusterconfig-gitops
Source code: https://github.com/tjungbauer/helm-charts/tree/main/charts/tpl
Values
| Key | Type | Default | Description |
|---|---|---|---|
| affinity | object | {"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 |
| argocdMetadata | object | {"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_applications | object | {"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.annotations | object | {} | Add annotations to your application object. @default: {} |
| argocd_applications.example-app.destination | object | {"namespace":"guestbook","server":"https://kubernetes.default.svc"} | Destination configuration |
| argocd_applications.example-app.destination.namespace | string | "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.server | string | "https://kubernetes.default.svc" | Use either server OR name, not both cluster API URL @default: "https://kubernetes.default.svc" |
| argocd_applications.example-app.enabled | bool | false | Enable this application @default: false |
| argocd_applications.example-app.finalizers | string | nil | Add this finalizer ONLY if you want these to cascade delete. @default: [] |
| argocd_applications.example-app.ignoreDifferences | object | {} | 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.info | list | [] | Extra information to show in the Argo CD Application details tab @default: [] |
| argocd_applications.example-app.labels | object | {} | Add labels to your application object. @default: {} |
| argocd_applications.example-app.namespace | string | "openshift-gitops" | Basic application metadata @default: "openshift-gitops" |
| argocd_applications.example-app.project | string | "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.chart | string | "" | Set this when pulling directly from a Helm repo. DO NOT set for git-hosted Helm charts. @default: "" |
| argocd_applications.example-app.source.helm | object | {"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.apiVersions | list | ["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.kubeVersion | string | "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.namespace | string | "custom-namespace" | Optional namespace to template with. If left empty, defaults to the app's destination namespace. @default: "" |
| argocd_applications.example-app.source.helm.parameters | list | [{"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.releaseName | string | "my-release" | Release name override (defaults to application name) @default: "" |
| argocd_applications.example-app.source.helm.valueFiles | list | ["values.yaml","values-customyaml"] | Value files to use for the Helm release @default: [] |
| argocd_applications.example-app.source.path | string | "guestbook" | This has no meaning for Helm charts pulled directly from a Helm repo instead of git. |
| argocd_applications.example-app.source.repositoryURL | string | "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.targetRevision | string | "HEAD" | revision, For Helm, this refers to the chart version. |
| argocd_applications.example-app.syncPolicy | object | {"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.automated | object | {"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.allowEmpty | bool | false | Allows deleting all application resources during automatic syncing ( false by default ). @default: false |
| argocd_applications.example-app.syncPolicy.automated.prune | bool | false | # Specifies if resources should be pruned during auto-syncing ( false by default ). @default: false |
| argocd_applications.example-app.syncPolicy.automated.selfHeal | bool | false | Specifies 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.managedNamespaceMetadata | object | {} | Sets the metadata for the application namespace. Only valid if CreateNamespace=true (see above), otherwise it is ignored. @default: {} |
| argocd_applications.example-app.syncPolicy.retry | object | {"backoff":{"duration":"5s","factor":2,"maxDuration":"3m"},"limit":5} | Retry configuration for failed syncs. @default: {} |
| argocd_applications.example-app.syncPolicy.retry.backoff | object | {"duration":"5s","factor":2,"maxDuration":"3m"} | Backoff configuration for failed sync attempts @default: {} |
| argocd_applications.example-app.syncPolicy.retry.backoff.duration | string | "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.factor | int | 2 | a factor to multiply the base duration after each failed retry |
| argocd_applications.example-app.syncPolicy.retry.backoff.maxDuration | string | "3m" | the maximum amount of time allowed for the backoff strategy |
| argocd_applications.example-app.syncPolicy.retry.limit | int | 5 | Number of failed sync attempt retries; unlimited number of attempts if less than 0 @default: 0 |
| argocd_applications.example-app.syncPolicy.syncOptions | list | [] | 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: [] |
| matchExpressions | list | [{"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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the charttpl is pinned at v1.0.31 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