This section provides a step-by-step guide on the configuration options available in the development environment for fluxcd/flux2-kustomize-helm-example
. It will focus on the essential components of the configuration without redundancy.
Directory Structure
The project has a defined structure for better organization. The primary directories and their roles are as follows:
./apps/
├── base
│ └── podinfo
├── production
└── staging
./infrastructure/
├── configs
└── controllers
./clusters/
├── production
└── staging
- apps/: Contains Helm releases with a custom configuration specific to each cluster.
- infrastructure/: Houses common infrastructure tools such as ingress-nginx and cert-manager.
- clusters/: Contains the Flux configurations for each cluster.
Configuration of Clusters
Each cluster has its own directory containing configurations. For instance, in the clusters/staging/ directory, the Flux Kustomization definitions are provided, typically in a file named apps.yaml
:
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: apps
namespace: flux-system
spec:
interval: 10m0s
dependsOn:
- name: infra-configs
sourceRef:
kind: GitRepository
name: flux-system
path: ./apps/staging
prune: true
wait: true
Important Fields
- dependsOn: Ensures that the specified resources are created before deploying the applications.
- sourceRef: Points to the Git repository and path from which Flux should sync the resources.
Helm Releases Configuration
In the apps/base/podinfo/ directory, you can define a HelmRelease that contains common values applicable to both clusters:
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: podinfo
spec:
releaseName: podinfo
chart:
spec:
chart: podinfo
sourceRef:
kind: HelmRepository
name: podinfo
namespace: podinfo
Specifying Chart Version
To automatically upgrade to the latest stable chart version, utilize the following configuration:
spec:
chart:
spec:
version: ">=1.0.0"
This specification allows Flux to manage the chart upgrades smoothly.
Custom Values per Environment
For environment-specific values in the production/ and staging/ directories:
Example for Production
In apps/production/podinfo-values.yaml:
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: podinfo
spec:
chart:
spec:
version: ">=1.0.0"
values:
ingress:
hosts:
- host: podinfo.production
paths:
- path: /
pathType: ImplementationSpecific
Example for Staging
In apps/staging/podinfo-values.yaml:
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: podinfo
spec:
chart:
spec:
version: ">=1.0.0"
values:
ingress:
hosts:
- host: podinfo.staging
paths:
- path: /
pathType: ImplementationSpecific
Infrastructure Configuration
The configuration for common infrastructure tools such as ingress-nginx is present in the infrastructure/controllers/ingress-nginx.yaml:
apiVersion: v1
kind: Namespace
metadata:
name: ingress-nginx
labels:
toolkit.fluxcd.io/tenant: sre-team
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: ingress-nginx
namespace: ingress-nginx
spec:
interval: 24h
url: https://kubernetes.github.io/ingress-nginx
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: ingress-nginx
namespace: ingress-nginx
spec:
interval: 30m
chart:
spec:
chart: ingress-nginx
version: "*"
sourceRef:
kind: HelmRepository
name: ingress-nginx
namespace: ingress-nginx
values:
controller:
service:
type: "NodePort"
admissionWebhooks:
enabled: false
This configuration outlines the setup of namespaces and Helm releases for ingress-nginx.
Conclusion
This guide focuses on the configuration options for the development environment of the fluxcd/flux2-kustomize-helm-example. It defines the necessary directory structure, Helm releases, custom values for environments, and infrastructure configurations in detail.
The information presented here is extracted from the project’s README.md and related files. For detailed reading and insights, refer to the source documentation.