App of Apps Pattern
The App of Apps pattern is used to manage all applications deployed through ArgoCD. This approach provides a centralized way to manage multiple applications as a single unit, simplifying deployment and maintenance.
Overview
Application management for ArgoCD deployments is handled through the infra repository, specifically in the app-of-apps directory. This pattern allows us to:
- Manage multiple applications with a single ArgoCD application
- Maintain consistent deployment configurations
- Enable environment-specific deployments
- Simplify application lifecycle management
Prerequisites
Before working with the App of Apps pattern, ensure you have:
Required Tools
-
Tanka (tk): Configuration utility for Kubernetes
- Installation: https://tanka.dev/install/
- Version: Latest stable release recommended
-
Jsonnet Bundler (jb): Package manager for Jsonnet
- Installation: https://github.com/jsonnet-bundler/jsonnet-bundler
- Used for managing Jsonnet dependencies
Required Access
- Kubernetes Access: Valid
kubeconfigfile with cluster access- Obtain from pass:
PASSWORD_STORE_DIR=~/projects/medapsis/pass pass show oracle/kubeconfig - Or extract from Terraform outputs (see Connecting to K0s)
- Obtain from pass:
- Repository Access: Clone permissions for the infra repository
Required Knowledge
- Familiarity with Oracle Cloud Infrastructure setup
- Basic understanding of Kubernetes and ArgoCD concepts
- Knowledge of Jsonnet for configuration management
Getting Started
1. Clone the Repository
git clone git@github.com:Zytera/infra.git
cd infra/app-of-apps
2. Install Dependencies
Install all required Jsonnet dependencies:
jb install
This command will:
- Download required Jsonnet libraries
- Set up the vendor directory
- Prepare the environment for Tanka operations
3. Configure Kubernetes Access
Set up your kubeconfig file:
# Option 1: Retrieve from pass
PASSWORD_STORE_DIR=~/projects/medapsis/pass pass show oracle/kubeconfig > kubeconfig
export KUBECONFIG=$(pwd)/kubeconfig
# Option 2: Use existing kubeconfig from Terraform
export KUBECONFIG=../oci/kubeconfig
Deploying Applications
Environment-Specific Deployments
Deploy applications to specific environments using Tanka:
# Deploy to staging environment
KUBECONFIG=../oci/kubeconfig tk apply staging
# Deploy to production environment
KUBECONFIG=../oci/kubeconfig tk apply production
Viewing Configuration
Before applying changes, review the generated configuration:
# Show the rendered configuration for staging
KUBECONFIG=../oci/kubeconfig tk show staging
# Show differences between current and desired state
KUBECONFIG=../oci/kubeconfig tk diff staging
Managing Individual Applications
To work with specific applications within the App of Apps:
# List all applications in an environment
KUBECONFIG=../oci/kubeconfig tk env list
# Show specific application configuration
KUBECONFIG=../oci/kubeconfig tk show staging --target app=<app-name>
Directory Structure
app-of-apps/
├── environments/ # Environment-specific configurations
│ ├── staging/ # Staging environment settings
│ ├── production/ # Production environment settings
├── lib/ # Shared Jsonnet libraries
├── vendor/ # External dependencies (managed by jb)
├── jsonnetfile.json # Jsonnet dependency manifest
└── jsonnetfile.lock.json # Locked dependency versions