API Endpoints for fluxcd/flux2-kustomize-helm-example
Documentation: Defined Routes in fluxcd/flux2-kustomize-helm-example
This documentation provides an in-depth analysis of the routes defined within the fluxcd/flux2-kustomize-helm-example
codebase. The focus will be on the ingress configuration relevant to both staging and production environments.
Ingress Configuration
The routes are primarily defined using the ingress
specifications within the HelmRelease configurations. Below are the specific files and relevant sections that specify these routes.
Staging Environment: apps/staging/podinfo-values.yaml
In the staging environment, routes are defined as follows:
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: podinfo
namespace: podinfo
spec:
chart:
spec:
version: ">=1.0.0-alpha"
test:
enable: false
values:
ingress:
hosts:
- host: podinfo.staging
paths:
- path: /
pathType: ImplementationSpecific
Explanation:
- The
host
specifies that the route is accessible atpodinfo.staging
. - It uses a wildcard route (
path: /
) to handle all requests directed to the host.
Production Environment: apps/production/podinfo-values.yaml
In the production environment, routes are similarly configured:
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
Explanation:
- Here, the
host
is set topodinfo.production
. - Just like the staging configuration, it routes all traffic intended for this host (
path: /
).
Ingress Controller Configuration: infrastructure/controllers/ingress-nginx.yaml
Additionally, there is a defined ingress controller that facilitates traffic to these routes. The configuration for the ingress-nginx controller is found in the file 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
Explanation:
- This defines the ingress-nginx controller which is essential for managing ingress resources available in both production and staging environments.
Additional Route Managed Configurations
Furthermore, these HelmRelease
definitions can contain configurations that manage various aspects of the routes such as path handling through the values of ingress specifications in different overlay directories, allowing for a clean abstraction and versioning of routes.
Application Layer Kustomization
- Base Configuration: The common routes are configured in
apps/base/podinfo/release.yaml
and can be viewed as:
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
interval: 50m
install:
remediation:
retries: 3
values:
redis:
enabled: true
repository: public.ecr.aws/docker/library/redis
tag: 7.0.6
ingress:
enabled: true
className: nginx
Discussion:
- This configuration showcases that ingress is enabled and uses the nginx class, ensuring that the routes effectively leverage the ingress-nginx controller.
Conclusion
The fluxcd/flux2-kustomize-helm-example
codebase includes a structured approach to defining routes through the use of HelmRelease
and ingress configurations across different environments (staging and production). The core configuration is represented in the respective values
sections of the HelmRelease
definitions, detailing how traffic is routed within the specified namespaces.
Sources
- infrastructure/controllers/ingress-nginx.yaml
- infrastructure/controllers/kustomization.yaml
- infrastructure/configs/kustomization.yaml
- clusters/production/flux-system/gotk-components.yaml
- apps/production/podinfo-values.yaml
- clusters/staging/flux-system/gotk-components.yaml
- apps/base/podinfo/kustomization.yaml
- apps/base/podinfo/namespace.yaml
- apps/staging/kustomization.yaml
- clusters/staging/flux-system/kustomization.yaml
- clusters/production/flux-system/kustomization.yaml
- apps/staging/podinfo-values.yaml
- apps/production/kustomization.yaml
- apps/base/podinfo/release.yaml