Skip to content

Commit 2060c7d

Browse files
authored
feat(helm): add initial Helm chart for Kubernetes configuration (#1321)
* feat(helm): add initial Helm chart for Kubernetes configuration Introduce a new Helm chart, `tfy-k8s-config`, to manage Kubernetes deployments. This includes templates for naming conventions, labels, and a priority class configuration. The priority class is set for critical TrueFoundry components, allowing for better resource management and prioritization in Kubernetes environments. * docs(values.yaml): clarify parameter documentation by prefixing with priorityClass for better readability and consistency * docs(README.md): add README for tfy-k8s-config Helm chart to provide an overview and purpose of the chart * docs(tfy-k8s-config): add parameters section to README for clarity style(values.yaml): enhance section header for priorityClass configuration * Update README.md with readme-generator-for-helm Signed-off-by: sachincool <[email protected]> * refactor(helm): rename and update priority class configuration Remove unused helper templates and rename the priority class configuration from `priorityClass` to `prirotiyClassNodeCritical` for clarity. Update the priority class value to a higher number to reflect its critical importance. Remove the old `priorityClass.yaml` and add `prirotiyClassNodeCritical.yaml` to align with the new naming convention. This change improves the organization and clarity of the Helm chart configuration. * fix(values.yaml): correct typos and update parameter names for clarity Corrects 'prirotiyClassNodeCritical' to 'priorityClassNodeCritical' and updates parameter names to match the section name for consistency and clarity. * fix(values.yaml): correct typo in priorityClassNodeCritical comment for clarity * fix(k8s-config): correct filename typo for priority class template Rename `prirotiyClassNodeCritical.yaml` to `priorityClassNodeCritical.yaml` to fix a typo in the filename. This ensures consistency and prevents potential issues with file referencing in the Kubernetes configuration. * feat(helm): add selector labels and annotations to priority class Add selector labels to `_helpers.tpl` for consistent label management. Enhance `priorityClassNodeCritical.yaml` with labels and annotations for better resource identification and management in Kubernetes. * fix(values.yaml): correct typo in priorityClassNodeCritical comment * Update README.md with readme-generator-for-helm Signed-off-by: sachincool <[email protected]> * feat(helpers.tpl): add common annotations template to support custom annotations in Kubernetes configurations * feat(helm): enhance label and annotation handling for priority class Refactor label and annotation templates to use a global dictionary for better management. Introduce support for custom labels and annotations in priorityClassNodeCritical, allowing more flexible configuration. Adjust values.yaml to include new fields for labels and annotations, improving customization options for users. * Update README.md with readme-generator-for-helm Signed-off-by: sachincool <[email protected]> * refactor(templates): enhance label and annotation handling Introduce user-supplied labels and annotations support by merging default and custom values. Refactor helpers to improve modularity and maintainability, ensuring consistent application of labels and annotations across resources. --------- Signed-off-by: sachincool <[email protected]> Co-authored-by: sachincool <[email protected]>
1 parent ff8d3c3 commit 2060c7d

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed

charts/tfy-k8s-config/Chart.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v2
2+
name: tfy-k8s-config
3+
description: A Helm chart for Kubernetes
4+
type: application
5+
version: 0.1.0
6+
appVersion: 0.1.0
7+
maintainers:
8+
- name: truefoundry

charts/tfy-k8s-config/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Tfy-k8s-config helm chart packaged by TrueFoundry
2+
3+
Tfy-k8s-config is a Helm chart that facilitates the PriorityClass and some global configurations necessary for Truefoundry components.
4+
5+
## Parameters
6+
7+
### priorityClassNodeCritical Configuration for priorityClass `truefoundry-critical`
8+
9+
| Name | Description | Value |
10+
| -------------------------------------------- | -------------------------------------------------------------------------- | ---------------------- |
11+
| `priorityClassNodeCritical.name` | The name of the priority class. | `truefoundry-critical` |
12+
| `priorityClassNodeCritical.enabled` | Whether to enable the priority class. | `true` |
13+
| `priorityClassNodeCritical.preemptionPolicy` | The preemption policy of the priority class. [PreemptLowerPriority, Never] | `PreemptLowerPriority` |
14+
| `priorityClassNodeCritical.value` | The value of the priority class. | `100000000` |
15+
| `priorityClassNodeCritical.globalDefault` | Whether to set the priority class as the global default. | `false` |
16+
| `priorityClassNodeCritical.labels` | Labels to add to the priority class. | `{}` |
17+
| `priorityClassNodeCritical.annotations` | Annotations to add to the priority class. | `{}` |
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "tfy-k8s-config.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "tfy-k8s-config.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "tfy-k8s-config.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common annotations
35+
*/}}
36+
{{- define "tfy-k8s-config.annotations" -}}
37+
{{- $annotations := merge (dict) (default (dict) .Values.annotations) }}
38+
{{- toYaml $annotations | nindent 8 }}
39+
{{- end }}
40+
41+
{{/*
42+
Common labels (with support for user-supplied labels)
43+
*/}}
44+
{{- define "tfy-k8s-config.labels" -}}
45+
{{- $labels := merge (dict
46+
"helm.sh/chart" (include "tfy-k8s-config.chart" .)
47+
"app.kubernetes.io/name" (include "tfy-k8s-config.name" .)
48+
"app.kubernetes.io/instance" .Release.Name
49+
"app.kubernetes.io/managed-by" .Release.Service
50+
) (default (dict) .Values.labels) }}
51+
{{- if .Chart.AppVersion }}
52+
{{- $_ := set $labels "app.kubernetes.io/version" .Chart.AppVersion }}
53+
{{- end }}
54+
{{- toYaml $labels | nindent 4 }}
55+
{{- end }}
56+
57+
{{/*
58+
Selector labels
59+
*/}}
60+
{{- define "tfy-k8s-config.selectorLabels" -}}
61+
app.kubernetes.io/name: {{ include "tfy-k8s-config.name" . }}
62+
app.kubernetes.io/instance: {{ .Release.Name }}
63+
{{- end }}
64+
65+
{{/*
66+
PriorityClassNodeCritical labels helper
67+
*/}}
68+
{{- define "tfy-k8s-config.priorityClassNodeCritical.labels" -}}
69+
{{- $base := (include "tfy-k8s-config.labels" . | fromYaml) }}
70+
{{- $labels := merge $base (default (dict) .Values.priorityClassNodeCritical.labels) }}
71+
{{- toYaml $labels | nindent 4 }}
72+
{{- end }}
73+
74+
{{/*
75+
PriorityClassNodeCritical annotations helper
76+
*/}}
77+
{{- define "tfy-k8s-config.priorityClassNodeCritical.annotations" -}}
78+
{{- $base := (include "tfy-k8s-config.annotations" . | fromYaml) }}
79+
{{- $annotations := merge $base (default (dict) .Values.priorityClassNodeCritical.annotations) }}
80+
{{- toYaml $annotations | nindent 4 }}
81+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.priorityClassNodeCritical.enabled }}
2+
apiVersion: scheduling.k8s.io/v1
3+
kind: PriorityClass
4+
metadata:
5+
name: {{ .Values.priorityClassNodeCritical.name }}
6+
labels:{{ include "tfy-k8s-config.priorityClassNodeCritical.labels" . | nindent 2 }}
7+
annotations:{{ include "tfy-k8s-config.priorityClassNodeCritical.annotations" . | nindent 2 }}
8+
value: {{ .Values.priorityClassNodeCritical.value }}
9+
preemptionPolicy: {{ .Values.priorityClassNodeCritical.preemptionPolicy }}
10+
globalDefault: {{ .Values.priorityClassNodeCritical.globalDefault }}
11+
description: 'This priority class is used for critical TrueFoundry system components.'
12+
{{- end }}

charts/tfy-k8s-config/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## @section priorityClassNodeCritical Configuration for priorityClass `truefoundry-critical`
2+
priorityClassNodeCritical:
3+
## @param priorityClassNodeCritical.name The name of the priority class.
4+
name: truefoundry-critical
5+
## @param priorityClassNodeCritical.enabled Whether to enable the priority class.
6+
enabled: true
7+
## @param priorityClassNodeCritical.preemptionPolicy The preemption policy of the priority class. [PreemptLowerPriority, Never]
8+
preemptionPolicy: PreemptLowerPriority
9+
## @param priorityClassNodeCritical.value The value of the priority class.
10+
value: "100000000"
11+
## @param priorityClassNodeCritical.globalDefault Whether to set the priority class as the global default.
12+
globalDefault: false
13+
## @param priorityClassNodeCritical.labels Labels to add to the priority class.
14+
labels: {}
15+
## @param priorityClassNodeCritical.annotations Annotations to add to the priority class.
16+
annotations: {}

0 commit comments

Comments
 (0)