Deploying with FluxCD#
This chapter covers deploying your application via FluxCD — the GitOps continuous delivery tool. Instead of running helm install manually, FluxCD watches a Git repository and keeps the cluster in sync automatically.
How it works#
FluxCD uses two core resource types from the source.toolkit.fluxcd.io and helm.toolkit.fluxcd.io API groups:
- HelmRepository — registers the Helm chart registry where
workload-helmis published - HelmRelease — declares which chart version to install and what values to use
When you commit a change to a HelmRelease in Git, FluxCD detects it and applies the change to the cluster automatically. No helm upgrade commands needed.
Prerequisites#
- Your cluster applies a folder of your GitOps repository (on kloudease workload clusters, the one agreed with kloudease)
- You have a namespace to deploy into
On kloudease workload clusters, the HelmRepository and the HelmRelease live in your application's namespace, and the HelmRelease runs as customer-flux. The cluster refuses a HelmRelease without serviceAccountName: customer-flux or with a chart source in another namespace.
Step Register the Helm repository#
Create a HelmRepository resource in your application's namespace that points to the Kloudease Helm registry:
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: kloudease
namespace: my-app
spec:
interval: 10m
url: https://gitlab.kloudease.tech/api/v4/projects/105/packages/helm/stable
secretRef:
name: kloudease-helm-auth
The referenced secret must exist in the same namespace with GitLab credentials. Don't commit it to Git; create it directly, or with an ExternalSecret from OpenBao:
kubectl create secret generic kloudease-helm-auth \
--namespace my-app \
--from-literal=username=pat \
--from-literal=password="$GITLAB_TOKEN"
GITLAB_TOKEN can be obtained from the Kloudease team.
Step Create the namespace#
apiVersion: v1
kind: Namespace
metadata:
name: my-app
Step Write the HelmRelease#
A HelmRelease references the chart and contains your values.yaml inline under spec.values:
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: my-app
namespace: my-app
spec:
interval: 10m
serviceAccountName: customer-flux # required on kloudease workload clusters
chart:
spec:
chart: workload-helm
version: "1.10.2" # pin an exact version
sourceRef:
kind: HelmRepository
name: kloudease # in the same namespace
interval: 10m
values:
global:
fullnameOverride: my-app
image:
repository: registry.example.com/my-team/my-app
tag: "1.0.0"
service:
main:
ports:
http:
port: 8080
autoconfig:
ingress:
enabled: true
host: my-app.workload.<project>.<org>.kloudease.tech
Step Commit to Git#
Commit the namespace, the HelmRepository and the HelmRelease to the folder your cluster applies. Flux picks them up and keeps them in sync. On kloudease workload clusters you don't write a Flux Kustomization yourself; the cluster already has one for your folder.
Managing Secrets#
Avoid storing plain-text passwords in a HelmRelease committed to Git. Two recommended patterns:
Pattern A — Use externalSecret for PostgreSQL#
Pre-create a kubernetes.io/basic-auth secret, then reference it:
persistence:
postgres:
enabled: true
database:
name: mydb
owner: myuser
externalSecret: my-app-pg-credentials # Secret must exist before HelmRelease is applied
Pattern B — Use valuesFrom for arbitrary values#
Store sensitive values in a Kubernetes Secret (on kloudease, created by an ExternalSecret from OpenBao), then reference it:
spec:
valuesFrom:
- kind: Secret
name: my-app-secret-values
valuesKey: values.yaml
optional: false
HTTP Health Probes#
The chart's default probes are TCP socket checks. If your application has an HTTP health endpoint (e.g. /healthz), override the probes in your HelmRelease:
probes:
liveness:
custom: true
spec:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 1
readiness:
custom: true
spec:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
timeoutSeconds: 1
startup:
custom: true
spec:
httpGet:
path: /healthz
port: 8080
periodSeconds: 5
failureThreshold: 30
timeoutSeconds: 1
Worked Example — Chirpy#
A complete, working example for the Chirpy demo application is available in example/chirpy/:
| File | Purpose |
|---|---|
example/chirpy/namespace.yaml |
The chirpy namespace |
example/chirpy/helmrepository.yaml |
HelmRepository for the Kloudease registry |
example/chirpy/helmrelease.yaml |
Full HelmRelease: image, probes, env, PostgreSQL, ingress, monitoring |
example/chirpy/kustomization.yaml |
Kustomize resource list for FluxCD |
Chirpy is a Go application that demonstrates: private registry pull secrets, HTTP health probes, PostgreSQL with CNPG (including schema bootstrapping via initSQL), autoconfig ingress, and Prometheus metrics.
See Getting started in the public documentation for a step-by-step walkthrough.
What's Next#
You have everything you need to run your application on Kloudease. Head back to the Table of Contents to explore advanced configuration options.