Reusable Helm library chart providing standard Kubernetes resource templates.
mc-helm-lib.deployment- Deployment with config injection supportmc-helm-lib.service- Servicemc-helm-lib.hpa- HorizontalPodAutoscalermc-helm-lib.httproute- Gateway API HTTPRoute
Add to your Chart.yaml:
dependencies:
- name: mc-helm-lib
version: 0.1.0
repository: "file://../mc-helm-lib"Run: helm dependency update
# templates/deployment.yaml
{{ include "mc-helm-lib.deployment" (dict
"component" "api"
"config" .Values.api
"root" $
) }}# templates/configs.yaml
{{- define "myapp.config" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "myapp.fullname" . }}-config
data:
HTTP_PORT: "8080"
{{- end -}}
{{ include "myapp.config" . }}
---
# templates/deployment.yaml
{{ include "mc-helm-lib.deployment" (dict
"component" "api"
"config" .Values.api
"configRefs" (list
(dict
"type" "configMap"
"name" (printf "%s-config" (include "myapp.fullname" $))
"template" "myapp.config"
"params" $
)
)
"root" $
) }}How it works:
type: "configMap" or "secret"name: Resource name for envFrom injectiontemplate: Template name for checksum calculationparams: Parameters passed to template for checksum
Config changes trigger automatic pod restarts via checksum annotations.
{{ include "mc-helm-lib.service" (dict
"component" "api"
"config" .Values.api
"root" $
) }}{{ include "mc-helm-lib.hpa" (dict
"component" "api"
"config" .Values.api
"root" $
) }}{{ include "mc-helm-lib.httproute" (dict
"component" "api"
"config" .Values.api
"root" $
) }}api:
enabled: true
replicaCount: 2
image:
repository: myregistry/myapp
tag: "1.0.0"
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
targetPort: 8080
autoscaling:
enabled: false
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 80
httpRoute:
enabled: false
parentRefs:
- name: gateway
hostnames:
- api.example.com
rules:
- matches:
- path:
type: PathPrefix
value: /
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 250m
memory: 256Mi
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /ready
port: http
podSecurityContext: {}
securityContext: {}
podAnnotations: {}
podLabels: {}mc-helm-lib.namemc-helm-lib.fullnamemc-helm-lib.chartmc-helm-lib.labels(supports component)mc-helm-lib.selectorLabels(supports component)mc-helm-lib.serviceAccountName