Skip to content

Helm Charts Development

Guide for developing and maintaining Helm charts for the RCIIS DevOps platform.

Overview

The RCIIS platform uses a custom Helm chart located in charts/rciis/ that provides a standardized deployment template for all RCIIS services.

Chart Structure

Directory Layout

charts/rciis/
├── Chart.yaml              # Chart metadata
├── values.yaml             # Default values
└── templates/
    ├── deployment.yaml      # Application deployment
    ├── statefulset.yaml     # Stateful services
    ├── service.yaml         # Service definitions
    ├── ingress.yaml         # Ingress resources
    ├── pvc.yaml            # Persistent volume claims
    ├── helpers.tpl         # Template helpers
    ├── integrationPlatform.yaml  # Camel K integration
    └── integrations.yaml   # Integration resources

Chart Development

Chart Metadata

# Chart.yaml
apiVersion: v2
name: rciis
description: RCIIS application chart
type: application
version: 0.1.306
appVersion: "1.0.0"
maintainers:
- name: RCIIS DevOps Team
  email: devops@rciis.africa
dependencies:
- name: postgresql
  version: "12.0.0"
  repository: https://charts.bitnami.com/bitnami
  condition: postgresql.enabled

Template Development

# templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "rciis.fullname" . }}
  labels:
    {{- include "rciis.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "rciis.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "rciis.selectorLabels" . | nindent 8 }}
    spec:
      containers:
      - name: {{ .Chart.Name }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        ports:
        - name: http
          containerPort: {{ .Values.service.targetPort }}
          protocol: TCP
        {{- with .Values.env }}
        env:
        {{- toYaml . | nindent 8 }}
        {{- end }}

Values Configuration

Default Values

# values.yaml
replicaCount: 1

image:
  repository: harbor.devops.africa/rciis/app
  pullPolicy: IfNotPresent
  tag: ""

nameOverride: ""
fullnameOverride: ""

service:
  type: ClusterIP
  port: 80
  targetPort: 8080

ingress:
  enabled: false
  className: "nginx"
  annotations: {}
  hosts:
  - host: chart-example.local
    paths:
    - path: /
      pathType: Prefix
  tls: []

resources:
  limits:
    cpu: 500m
    memory: 512Mi
  requests:
    cpu: 100m
    memory: 128Mi

autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80

persistence:
  enabled: false
  storageClass: ""
  accessMode: ReadWriteOnce
  size: 8Gi

Chart Testing

Lint and Validation

# Lint chart
helm lint charts/rciis/

# Template dry-run
helm template test-release charts/rciis/ --values test-values.yaml

# Validate against cluster
helm template test-release charts/rciis/ | kubectl apply --dry-run=client -f -

Unit Testing

# Install helm-unittest plugin
helm plugin install https://github.com/helm-unittest/helm-unittest

# Run tests
helm unittest charts/rciis/

Test Values

# test-values.yaml
image:
  repository: nginx
  tag: "1.21"

service:
  type: NodePort
  port: 80

ingress:
  enabled: true
  hosts:
  - host: test.local
    paths:
    - path: /
      pathType: Prefix

resources:
  limits:
    cpu: 100m
    memory: 128Mi
  requests:
    cpu: 50m
    memory: 64Mi

Chart Versioning

Version Management

# Bump chart version
yq '.version = "0.1.307"' -i charts/rciis/Chart.yaml

# Package chart
helm package charts/rciis/

# Push to registry
helm push rciis-0.1.307.tgz oci://harbor.devops.africa/rciis

Automated Versioning

# GitHub Actions workflow
- name: Bump chart version
  run: |
    NEW_VERSION="0.1.${{ github.run_number }}"
    yq ".version = \"$NEW_VERSION\"" -i charts/rciis/Chart.yaml

- name: Package and push chart
  run: |
    helm package charts/rciis/
    helm push rciis-*.tgz oci://harbor.devops.africa/rciis

Best Practices

Template Design

  1. Use helpers: Create reusable template functions
  2. Conditional resources: Use conditions for optional components
  3. Resource naming: Consistent naming conventions
  4. Documentation: Comment complex template logic

Values Design

  1. Sensible defaults: Provide working default values
  2. Environment flexibility: Support different environments
  3. Security: Secure defaults for production use
  4. Validation: Validate required values

Testing

  1. Comprehensive coverage: Test all template paths
  2. Multiple scenarios: Test different value combinations
  3. Integration testing: Test with real clusters
  4. Regression testing: Prevent breaking changes

For advanced Helm chart development, refer to the Helm documentation.