The Frappe Operator supports installing specific apps during site creation through the FrappeSite CRD. This feature provides:
apiVersion: vyogo.tech/v1alpha1
kind: FrappeSite
metadata:
name: my-site
namespace: default
spec:
benchRef:
name: my-bench
siteName: mysite.example.com
# Specify apps to install
apps:
- erpnext
- hrms
dbConfig:
provider: mariadb
mode: shared
Apps are checked in the container: The operator checks for apps in the actual container filesystem (apps directory) and apps.txt, not just the bench CRD specification.
Graceful handling of missing apps: If an app specified in the CRD is not available in the container, it will be skipped with a warning in the logs. The site creation will continue successfully with the available apps.
Apps are installed during initial site creation only: Apps are installed when the site is first created using bench new-site --install-app=<app>. The apps field is effectively immutable - if you update it after the site is created, the operator will not attempt to install or remove apps. To add/remove apps on an existing site, use bench commands directly (bench install-app or bench uninstall-app).
If no apps are specified: Only the frappe framework will be installed on the site (no additional apps beyond frappe).
The operator performs the following validations and checks:
App name validation: App names are checked for valid characters (alphanumeric, underscore, hyphen only) to prevent shell injection. Invalid names generate warnings and are skipped.
Filesystem verification: During site creation, the initialization script checks that each app’s directory exists in the bench’s apps folder.
apps.txt check: The script also displays contents of apps.txt if available for reference.
Graceful skipping: If an app isn’t available in the filesystem, it’s skipped with a warning rather than failing the entire site creation.
Instead of failing, the script outputs:
⚠ WARNING: App 'custom_app' not found in bench directory - skipping
The app may not be installed in this bench yet
And continues with the apps that are available.
The FrappeSite status includes several fields to track app installation:
status:
# List of requested apps (some may have been skipped if not available)
installedApps:
- erpnext
- hrms
# Overall installation status message
appInstallationStatus: "Completed app installation for 2 requested app(s) - check logs for any skipped apps"
Note: The installedApps field shows apps that were requested, not necessarily all installed. Check the job logs to see which apps were actually installed vs skipped. The failedApps field is reserved for future use.
During installation:
"Installing <N> app(s)..." - Installation in progressOn completion:
"Completed app installation for N requested app(s) - check logs for any skipped apps" - Installation completed (some may have been skipped)"No apps specified - only frappe framework installed" - No apps requestedOn failure:
"Failed to install apps: <error details>" - Site creation failedkubectl get frappesite my-site -o yaml
kubectl get frappesite my-site -o jsonpath='{.status.installedApps}'
kubectl get frappesite my-site -o jsonpath='{.status.appInstallationStatus}'
kubectl describe frappesite my-site
Example events:
Normal AppsRequested Requested 2 app(s): [erpnext hrms] - will check availability in container
Normal AppsProcessed Processed app installation for: [erpnext hrms] - check job logs for any skipped apps
Warning InvalidAppName App 'my-app@123' contains invalid characters and will be skipped
# Get the job name
kubectl get jobs -l site=my-site
# View logs
kubectl logs job/my-site-init
The initialization script provides comprehensive logging:
==========================================
App Installation Configuration
==========================================
Apps requested for installation: erpnext hrms
Available apps in bench (from filesystem):
erpnext
hrms
Apps listed in apps.txt:
frappe
erpnext
hrms
frappe (framework - always available)
------------------------------------------
✓ App 'erpnext' found in bench and will be installed
✓ App 'hrms' found in bench and will be installed
==========================================
Total apps to install: 2
Install arguments: --install-app=erpnext --install-app=hrms
==========================================
==========================================
App Installation Configuration
==========================================
Apps requested for installation: erpnext custom_app hrms
Available apps in bench (from filesystem):
erpnext
hrms
frappe (framework - always available)
------------------------------------------
✓ App 'erpnext' found in bench and will be installed
⚠ WARNING: App 'custom_app' not found in bench directory - skipping
The app may not be installed in this bench yet
✓ App 'hrms' found in bench and will be installed
------------------------------------------
⚠ Skipped apps (not available): custom_app
These apps will not be installed on this site
To install them later, ensure they're available in the bench
and use: bench --site mysite.example.com install-app custom_app
==========================================
Total apps to install: 2
Install arguments: --install-app=erpnext --install-app=hrms
==========================================
==========================================
Creating Frappe Site
==========================================
Site Name: mysite.example.com
Database Provider: mariadb
Database Name: mysite-db
Database Host: mariadb:3306
Apps to install: erpnext hrms
==========================================
✓ Detected support for --db-user flag
Executing: bench new-site with apps: --install-app=erpnext --install-app=hrms
------------------------------------------
[bench new-site output...]
------------------------------------------
✓ Site created successfully!
✓ All 2 app(s) installed successfully
Installed apps:
✓ erpnext
✓ hrms
==========================================
Log Message:
⚠ WARNING: App 'custom_app' not found in bench directory - skipping
The app may not be installed in this bench yet
⚠ Skipped apps (not available): custom_app
These apps will not be installed on this site
Behavior: The site creation continues successfully with the apps that are available. No error is raised.
Kubernetes Event:
Normal AppsProcessed Processed app installation for: [erpnext custom_app hrms] - check job logs for any skipped apps
Log Message:
Skipping app with invalid characters: my-app@123
Kubernetes Event:
Warning InvalidAppName App 'my-app@123' contains invalid characters and will be skipped
Behavior: App is skipped, site creation continues.
Error Message:
✗ ERROR: Site creation failed with exit code 1
Error output:
[Detailed traceback and error information]
CRITICAL ERROR: Site creation failed. Exiting.
Kubernetes Event:
Warning SiteInitializationFailed Site initialization failed: exit code 1
Warning AppInstallationFailed Failed to install apps. Check pod my-site-init-xxxxx logs for details
Pod Status: The initialization job pod will show as Failed, and you can retrieve detailed logs using:
kubectl logs <pod-name>
Check:
kubectl logs job/my-site-init
Look for warning messages about skipped apps.
kubectl exec -it deployment/my-bench-gunicorn -- ls -la apps/
kubectl exec -it deployment/my-bench-gunicorn -- cat sites/apps.txt
Solution: Since apps are only installed during initial site creation through the CRD, you need to use bench commands:
# Get a shell in the bench pod
kubectl exec -it deployment/my-bench-gunicorn -- bash
# Install the app
cd /home/frappe/frappe-bench
bench --site mysite.example.com install-app custom_app
Steps:
kubectl get pods -l job-name=my-site-init
kubectl logs <pod-name>
Verify database connectivity and credentials
kubectl get frappebench my-bench
kubectl describe frappesite my-site
The FrappeSite’s app installation integrates with the FrappeBench’s app configuration:
# FrappeBench
apiVersion: vyogo.tech/v1alpha1
kind: FrappeBench
metadata:
name: my-bench
spec:
frappeVersion: "version-15"
# Apps available in this bench
apps:
- name: frappe
source: image
- name: erpnext
source: fpm
org: frappe
version: "15.0.0"
- name: hrms
source: fpm
org: frappe
version: "15.0.0"
# FrappeSite (can only install apps available in bench)
apiVersion: vyogo.tech/v1alpha1
kind: FrappeSite
metadata:
name: my-site
spec:
benchRef:
name: my-bench
# Select which apps to install on this site
apps:
- erpnext
- hrms
Validate bench apps first: Before creating a site, check the bench status to see which apps are available.
Use descriptive site names: This makes it easier to identify sites and their purposes in logs and status.
Monitor events: Use kubectl describe to monitor progress and catch errors early.
Keep logs: Job logs are automatically retained and can be reviewed for debugging.
Test in development first: Test app combinations in a development environment before deploying to production.
Version compatibility: Ensure the apps you’re installing are compatible with the Frappe version in the bench.
Apps are immutable after initial site creation: Once a site is created, updating the apps field in the CRD spec will have no effect. The apps can only be installed during the initial bench new-site command. If you need to add or remove apps after site creation, use bench install-app or bench uninstall-app commands directly on the bench.
Apps must exist in container filesystem: Apps are checked in the actual container (apps directory), not just the bench CRD spec.
No partial installation tracking: Currently, the status shows all requested apps, not which were actually installed vs skipped. Check job logs for details on skipped apps.
No automatic app sync: If you add an app to the bench after site creation, existing sites won’t automatically get it installed. You must manually install it on each site that needs it.
Potential future improvements: