This repository is designed to manage Kubernetes deployments for both staging and production environments using Flux and Helm. It provides a structured approach to manage and promote changes from staging to production with environment-specific overrides.
-
Branch-Based Configuration:
-
Each environment (
stagingandproduction) is managed on a separate branch. -
Environment-specific Helm values files and Flux configurations are maintained in their respective branches.
-
Example branches:
staging: Contains all changes for testing.production: Contains only validated and approved configurations.
-
-
Testing in Staging:
- Changes are first applied to the
stagingbranch. - Verify the application's behavior in the staging environment.
- Changes are first applied to the
-
Promoting to Production:
- After successful testing, merge the changes from the
stagingbranch into theproductionbranch. - Flux will automatically apply the changes to the production cluster.
- After successful testing, merge the changes from the
graphql
Copy code
kubernetes/
base/ # Common configurations shared across environments
apps/ # Applications (Sonarr, Radarr, etc.)
media/
pvc-media.yaml # Shared PersistentVolumeClaim for media storage
sonarr/
pvc-config.yaml # PVC for Sonarr's /config directory
helmrelease.yaml # HelmRelease for Sonarr
kustomization.yaml
infrastructure/ # Networking and infrastructure (e.g., Nginx)
network/
nginx/
helmrelease.yaml
kustomization.yaml
core/ # Core services (e.g., Cilium, Ceph-CSI)
network/
cilium/
namespace.yaml
helmrelease.yaml
kustomization.yaml
shared/ # Shared Helm repositories and resources
repo/
helm/
nginx-helmrepository.yaml
cilium-helmrepository.yaml
clusters/
staging/ # Cluster-specific configurations for staging
apps.yaml
infrastructure.yaml
kustomization.yaml
production/ # Cluster-specific configurations for production
apps.yaml
infrastructure.yaml
kustomization.yaml
-
Set Up the Staging Environment:
-
Deploy the base configurations using the
stagingbranch:bash Copy code flux apply -k ./clusters/staging
-
-
Modify and Test Changes:
- Update the appropriate
values.yamlfiles underbase/appsorstaging-overridesfor your application. - Example: Update
kubernetes/base/apps/media/sonarr/helmrelease.yamlto modify Sonarr settings.
- Update the appropriate
-
Verify Changes in Staging:
-
Monitor the deployment using
kubectl:bash Copy code kubectl get pods -n media
-
-
Iterate Until Validation:
- Repeat modifications until the application works as intended.
-
Merge Staging to Production:
-
Once changes are validated, merge the
stagingbranch into theproductionbranch:bash Copy code git checkout production git merge staging git push origin production
-
-
Deploy Production Configurations:
-
Flux automatically applies the changes to the production environment:
bash Copy code flux apply -k ./clusters/production
-
-
Verify Production Deployment:
-
Ensure the production environment reflects the changes:
bash Copy code kubectl get pods -n media
-
-
Staging Environment:
- Override files are stored under
staging-overrides/. - Example:
kubernetes/staging-overrides/apps/media/sonarr/values.yaml.
- Override files are stored under
-
Production Environment:
- Overrides are managed in the
productionbranch. - Flux applies the appropriate configurations from the branch automatically.
- Overrides are managed in the
-
Add a Feature:
- Update
values.yamlorhelmrelease.yamlfor the desired application in thestagingbranch.
- Update
-
Deploy to Staging:
-
Apply configurations in
clusters/staging:bash Copy code flux apply -k ./clusters/staging
-
-
Test and Validate:
- Confirm the application is working as expected.
-
Promote to Production:
-
Merge the
stagingbranch intoproductionand deploy:bash Copy code git checkout production git merge staging flux apply -k ./clusters/production
-
- Isolation of Environments:
stagingis for testing;productionis for live deployments.
- Promotion via Git:
- Ensure changes are thoroughly tested before merging into
production.
- Ensure changes are thoroughly tested before merging into
- Centralized Configurations:
- Shared configurations (e.g., Helm repositories) are stored in
shared/repo/helm/.
- Shared configurations (e.g., Helm repositories) are stored in
Operational docs live under docs/.
Useful entry points:
- Runbooks
- Observability Deployment Blueprint
- Observability, Monitoring, and Incident Reporting
- Monitoring and Reporting Implementation
- Backup system
- Submit pull requests for new features or fixes.
- Ensure all changes are validated in
stagingbefore merging intoproduction.
This repository is licensed under the MIT License. See the LICENSE file for details.