GitOps Principles
The platform follows GitOps best practices:- Git as Single Source of Truth: All configuration in version control
- Declarative Configuration: Desired state, not imperative commands
- Automated Synchronization: Continuous reconciliation from Git to cluster
- Observability: Audit trail and drift detection built-in
ArgoCD
ArgoCD is the GitOps operator that continuously syncs Git state to Kubernetes.Installation
ArgoCD is bootstrapped via theargocd-bootstrap.sh script:
Architecture
ArgoCD consists of several components: Application Controller:- Monitors Git repositories for changes
- Compares desired state (Git) with live state (cluster)
- Triggers sync operations when drift detected
- Handles health assessment and status reporting
- Clones Git repositories
- Renders manifests (Helm, Kustomize, plain YAML)
- Caches rendered manifests for performance
- Runs Nixidy transformations (in this platform)
- Provides Web UI and gRPC API
- User authentication and authorization
- Project and application management
- Exposed via NodePort on port 30080 (HTTP) and 30443 (HTTPS)
- Sends alerts on sync events (success, failure, degraded)
- Integrates with Slack, GitHub, email, etc.
- Configurable triggers and templates
- Generates Applications from templates
- Discovers targets from Git, clusters, labels, etc.
- Enables managing hundreds of apps with one resource
Access
Access ArgoCD UI athttp://localhost:30080 when running Full bootstrap mode.
Initial credentials:
ApplicationSet Pattern
The platform uses ApplicationSet to manage multiple microservices from a single definition.Services ApplicationSet
How It Works
Git Generator:- Scans the
microservice-apprepository - Finds directories matching
services/*/k8s/generated - Creates one Application per discovered directory
- Examples:
services/user-service/k8s/generated,services/auth-service/k8s/generated
{{path[0]}}→ First path segment (e.g.,services,frontend){{path[1]}}→ Second path segment (e.g.,user-service,auth-service)- Application name:
services-user-service,frontend
automated.prune: true→ Delete resources removed from Gitautomated.selfHeal: true→ Revert manual changes to Git state
Benefits
- Scalability: One ApplicationSet → N Applications
- Consistency: All services use same sync policy
- Discoverability: New services automatically deployed when added to Git
- Maintainability: Update sync policy in one place
Nixidy Manifest Generation
Nixidy is a Nix-based tool for generating Kubernetes manifests with type safety and reusability.Why Nixidy?
Traditional approaches:- Plain YAML: No validation, copy-paste duplication
- Helm: Templating language, hard to test, version conflicts
- Kustomize: Limited logic, awkward composition
- Type checking: Catch errors before applying to cluster
- Reusability: Share modules across environments (local, staging, prod)
- Helm integration: Use Helm charts with Nix’s reproducibility
- Version pinning: Exact chart versions in flake.lock
- Testing: Evaluate manifests without cluster access
Architecture
Environment Structure
Module Examples
Helm Chart Module
chart = charts.prometheus-community.kube-prometheus-stack→ Resolves from nixhelmvalues = { ... }→ Type-checked Helm valuescreateNamespace = true→ Generates Namespace manifestsyncPolicy.syncOptions.serverSideApply = true→ Uses server-side apply
Raw Manifest Module
resources.configMaps→ Generates ConfigMap manifestresources.deployments→ Generates Deployment manifestresources.services→ Generates Service manifest- Nix variables (
labels,collectorConfig) for reusability
Building Manifests
Manifests are generated via Nix build:Chart Version Pinning
Helm chart versions are pinned inflake.lock:
- Reproducible builds (same input → same output)
- No surprise upgrades
- Explicit version bumps via
nix flake update - Binary cache for faster builds
Watch Mode
For development, watch mode auto-regenerates and applies manifests:- Edit
.nixfile innixidy/env/local/ - Watchexec detects change
- Regenerates manifests
- Applies to cluster
- See changes in seconds
Deployment Workflow
Local Development (Bootstrap)
Production (ArgoCD)
Multi-Environment
Nixidy supports multiple environments:- Local: NodePort services, small resource limits, debug logging
- Prod: LoadBalancer services, production resource requests/limits, info logging
App-of-Apps Pattern
Nixidy generates an “app-of-apps” Application that manages all other Applications:- Single entry point for all infrastructure
- Bootstrap by applying one Application
- Hierarchical dependency management
- Centralized sync policies
Secrets Management
Sensitive data is encrypted with SOPS (Secrets OPerationS):Workflow
Initialize age key:- Use argocd-vault-plugin or sealed-secrets
- Decrypt at sync time
- Never commit plaintext to Git
Drift Detection
ArgoCD continuously compares Git state to live cluster state.Out of Sync Scenarios
Manual kubectl edit:- User edits Deployment in cluster
- ArgoCD marks Application as “OutOfSync”
- If
selfHeal: true, ArgoCD reverts to Git state
- Manifest has validation error
- Application stuck in “Progressing” state
- Check sync status and logs in UI
- Resource deleted from Git
- If
prune: true, ArgoCD deletes from cluster - If
prune: false, resource remains (orphaned)
Sync Options
Troubleshooting
Nixidy Build Errors
ArgoCD Sync Failures
Helm Chart Issues
ApplicationSet Not Generating Apps
Best Practices
Repository Structure
Separate infrastructure and application repos:microservice-infra: Nixidy modules, platform servicesmicroservice-app: Application code and manifests
- Different access controls
- Independent CI/CD pipelines
- Clear separation of concerns
Environment Promotion
Use separate Git branches or directories:infra-dev,infra-staging,infra-prod
- Test changes in dev environment
- Merge to staging branch
- Automated or manual promotion to production
- Rollback = revert Git commit
Resource Organization
Group by application, not by resource type: Good:Next Steps
Kubernetes Setup
Understand the underlying cluster configuration
Observability
See how GitOps manages the observability stack