Skip to main content

EspoCRM on GKE Autopilot

EspoCRM on GKE Autopilot

EspoCRM is an open-source, GPLv3-licensed Customer Relationship Management (CRM) platform built on PHP and Apache. This module deploys EspoCRM on GKE Autopilot on top of the App_GKE foundation, which provisions and manages the shared Google Cloud and Kubernetes infrastructure.

This guide focuses on the cloud services EspoCRM uses and how to explore and operate them from the Google Cloud Console and the command line. For the mechanics that are common to every GKE application — Workload Identity, ingress, autoscaling, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC Service Controls, backups, and the deployment lifecycle — refer to the App_GKE foundation guide rather than repeating them here.


1. Overview

EspoCRM runs as a PHP/Apache web workload. The deployment wires together a focused set of Google Cloud services:

CapabilityGoogle Cloud serviceNotes
ComputeGKE AutopilotApache/PHP pods, 1 vCPU / 2 GiB by default, horizontally autoscaled
DatabaseCloud SQL for MySQL 8.0Required — EspoCRM does not support PostgreSQL; reached via the Auth Proxy sidecar
Object storageCloud Storage + NFS (Filestore)espocrm-data bucket; shared NFS mounted at /var/lib/espocrm for uploads
CacheRedis (optional)Optional object cache; disabled by default
SecretsSecret ManagerAuto-generated ESPOCRM_ADMIN_PASSWORD; database password
IngressCloud Load BalancingExternal LoadBalancer, optional custom domain + managed certificate

Sensible defaults worth knowing up front:

  • MySQL 8.0 is mandatory. The database engine is fixed by the shared application layer (database_type = "MYSQL_8_0"); EspoCRM does not support PostgreSQL.
  • The database is reached through the Auth Proxy sidecar on loopback. The GKE variant overrides DB_HOST = "127.0.0.1" so EspoCRM dials the co-located Cloud SQL Auth Proxy sidecar on 127.0.0.1:3306; enable_cloudsql_volume = true by default.
  • The admin account is bootstrapped automatically. The upstream installer creates the admin user with the auto-generated ESPOCRM_ADMIN_PASSWORD on first boot — retrieve it from Secret Manager to log in.
  • Schema is created on first boot, not by a migrate job. db-init creates the database and user; the upstream docker-entrypoint.sh then runs the install/migrate action automatically when the pod starts.
  • NFS is enabled by default. enable_nfs = true mounts a shared Filestore volume at /var/lib/espocrm, so EspoCRM's uploaded attachments and runtime data persist across pod restarts and are shared between replicas.
  • Single replica by default. min_instance_count = 1, max_instance_count = 1 — GKE keeps at least one pod running (no scale-to-zero) so the CRM is always reachable.
  • Session affinity is ClientIP by default, routing a client's requests to the same pod — useful once you scale beyond one replica.
  • ESPOCRM_SITE_URL is derived from the service URL so EspoCRM's absolute links and installer checks use the reachable host rather than localhost.

2. Google Cloud Services & How to Explore Them

All commands assume you have run gcloud container clusters get-credentials <cluster> --region <region> --project <project> and that PROJECT, REGION, and NAMESPACE are set. The namespace and other identifiers are reported in the deployment Outputs.

A. GKE Autopilot — the EspoCRM workload

EspoCRM pods are scheduled on Autopilot, which bills for the CPU/memory the pods actually request. Horizontal Pod Autoscaling sizes the deployment between the minimum and maximum replica counts. Because the app is NFS-backed, the foundation uses the Recreate update strategy so two pods never write the same NFS volume during a rollout.

  • Console: Kubernetes Engine → Workloads → select the EspoCRM workload to see pods and events. Kubernetes Engine → Services & Ingress shows the external IP.
  • CLI:
    kubectl get pods,svc,hpa -n "$NAMESPACE"
    kubectl logs -n "$NAMESPACE" deploy/<service-name> --tail=100
    kubectl describe hpa -n "$NAMESPACE" # current vs target utilisation

See App_GKE for how Autopilot, scaling, and the workload type (Deployment vs StatefulSet) are managed.

B. Cloud SQL for MySQL 8.0

EspoCRM stores all application data (contacts, leads, opportunities, activities, users) in a managed Cloud SQL for MySQL 8.0 instance. Pods reach it privately through the Cloud SQL Auth Proxy sidecar bound to 127.0.0.1:3306; no public IP is exposed. On first deploy an initialization Job creates the application database and user.

  • Console: SQL → select the instance for connections, backups, flags, and metrics.
  • CLI:
    gcloud sql instances list --project "$PROJECT"
    gcloud sql instances describe <instance-name> --project "$PROJECT"
    # Open an interactive shell to inspect schema/data:
    gcloud sql connect <instance-name> --user=<db-user> --database=<db-name> --project "$PROJECT"

The instance name, database name, user, and the Secret Manager secret holding the password are all surfaced in the Outputs. For the connection model, automated backups, and password rotation, see App_GKE.

C. Cloud Storage & NFS

A dedicated Cloud Storage bucket (espocrm-data) is provisioned automatically, and a shared NFS (Filestore) volume is mounted at /var/lib/espocrm for EspoCRM's uploaded attachments and runtime data. The workload service account is granted access to the bucket.

  • Console: Cloud Storage → Buckets; Filestore → Instances.
  • CLI:
    gcloud storage buckets list --project "$PROJECT"
    gcloud filestore instances list --project "$PROJECT"
    kubectl exec -n "$NAMESPACE" deploy/<service-name> -- ls -la /var/lib/espocrm

See App_GKE for CMEK options, GCS Fuse mounts, and the NFS server model.

D. Redis (object cache)

Redis is disabled by default. When enable_redis = true is set, REDIS_HOST and REDIS_PORT are injected and EspoCRM uses Redis as its object cache backend to reduce database load. When redis_host is left empty and enable_nfs is true, the NFS server VM's IP is used as the Redis endpoint.

  • Console: Memorystore → Redis (if using a managed instance).
  • CLI:
    redis-cli -h <redis-host> ping
    # Confirm the Redis env injected into the running pod:
    kubectl exec -n "$NAMESPACE" deploy/<service-name> -- env | grep REDIS

E. Secret Manager

The first-run admin password (ESPOCRM_ADMIN_PASSWORD) is generated automatically and stored in Secret Manager, then injected into the pod as a secret env var via the Secret Store CSI driver. The database password is managed separately by the foundation.

  • Console: Security → Secret Manager.
  • CLI:
    gcloud secrets list --project "$PROJECT" --filter="name~espocrm-admin-password"
    gcloud secrets versions access latest --secret=<secret-name> --project "$PROJECT"

The database password secret name is in the Outputs. See App_GKE for the Secret Store CSI integration and rotation.

F. Networking & ingress

By default the workload is exposed through an external Cloud Load Balancing IP (service_type = LoadBalancer). A custom domain with a Google-managed certificate can be enabled, and a static IP can be reserved so the address survives redeploys.

  • Console: Network services → Load balancing; VPC network → IP addresses.
  • CLI:
    kubectl get ingress,svc -n "$NAMESPACE"
    gcloud compute addresses list --project "$PROJECT"

See App_GKE for custom domains, Cloud CDN, and static IP details.

G. Cloud Logging & Monitoring

Pod stdout/stderr flow to Cloud Logging; GKE and Cloud SQL metrics flow to Cloud Monitoring. Optional uptime checks and alert policies are available. The cloud-entrypoint.sh prints the resolved ESPOCRM_DATABASE_* and ESPOCRM_SITE_URL values at pod start — a quick way to confirm the DB host and site URL.

  • Console: Logging → Logs Explorer; Monitoring → Dashboards / Alerting.
  • CLI:
    gcloud logging read 'resource.type="k8s_container" AND resource.labels.namespace_name="'"$NAMESPACE"'"' \
    --project "$PROJECT" --limit 50

3. EspoCRM Application Behaviour

  • First-deploy database setup. An initialization Job runs db-init.sh using mysql:8.0-debian. It resolves the Cloud SQL connection (Auth Proxy socket if present, otherwise TCP), idempotently creates the application database and user, grants privileges, and verifies the app user can connect (warming the MySQL 8 caching_sha2_password auth cache). The job runs on apply and is safe to re-run.
  • Schema created on first boot. There is no separate migrate job. Once db-init has provisioned the database, the upstream EspoCRM docker-entrypoint.sh runs the install/migrate action automatically on pod start, creating the schema and the admin user.
  • Admin login is auto-generated. The admin user's password comes from the ESPOCRM_ADMIN_PASSWORD secret. Retrieve it before your first login:
    gcloud secrets versions access latest \
    --secret="secret-<resource_prefix>-espocrm-admin-password" --project "$PROJECT"
    Change it in the EspoCRM UI (Administration → Users) once you are in.
  • Uploads persist on NFS. With enable_nfs = true (default), EspoCRM's attachments and runtime data live under the shared /var/lib/espocrm Filestore mount, surviving pod restarts and shared across replicas.
  • Site URL must match the reachable host. EspoCRM builds absolute links from ESPOCRM_SITE_URL; the entrypoint sets it from the service URL. After the LoadBalancer IP or custom domain is known, ensure the site URL reflects the external host so links and OAuth redirects are correct.
  • Health path. Both the startup and liveness probes are HTTP GET / — EspoCRM serves its login page there unauthenticated (200). The startup probe (startup_probe_config) defaults to a 10-second initial delay, 10-second period, and 3-failure threshold; the liveness probe (health_check_config) defaults to a 15-second initial delay, 30-second period, and 3-failure threshold. These are noticeably tighter than the Cloud Run variant's defaults — on a slow first boot (the install/migrate step), pods can flap before EspoCRM finishes initializing; raise the initial delay / failure threshold via startup_probe_config / health_check_config if you see this.
  • Inspect job execution:
    kubectl get jobs -n "$NAMESPACE"
    kubectl logs -n "$NAMESPACE" job/<job-name>

4. Configuration Variables

Variables are grouped exactly as they appear on the deployment platform. Only settings specific to or notable for EspoCRM are listed; every other input is inherited from App_GKE with its standard behaviour and defaults.

Group 3 — Application Identity

VariableDefaultDescription
application_nameespocrmBase name for resources. Do not change after first deploy.
application_versionlatestImage tag for espocrm/espocrm; latest is pinned internally to 10.0.2. Pin to a specific release in production.
php_memory_limit512MPHP memory limit; raise for heavy plugins or large media.
upload_max_filesize / post_max_size64MUpload / POST size limits; post_max_size must be ≥ upload_max_filesize.

Group 4 — Runtime & Scaling

VariableDefaultDescription
deploy_applicationtrueSet false to provision infrastructure only.
cpu_limit1000mCPU per pod; minimum 1 vCPU for EspoCRM + MySQL.
memory_limit2GiMemory per pod; minimum 512Mi (PHP 8.x).
min_instance_count1Minimum replicas; GKE keeps ≥ 1 so the CRM is always reachable.
max_instance_count1Maximum replicas. Increase only with shared NFS + ClientIP affinity confirmed.
container_port80Apache listens on port 80.
enable_cloudsql_volumetrueCloud SQL Auth Proxy sidecar (loopback 127.0.0.1:3306).

Group 6 — GKE Backend & Cluster

VariableDefaultDescription
service_typeLoadBalancerHow the Kubernetes Service is exposed.
workload_typenull (Deployment)Deployment (default) or StatefulSet with per-pod PVCs.
session_affinityClientIPSticky routing to the same pod.

Group 13 — Filesystem (NFS)

VariableDefaultDescription
enable_nfstrueMount a shared Filestore volume for EspoCRM uploads/runtime data.
nfs_mount_path/var/lib/espocrmContainer mount path for the NFS volume.

Group 15 — Redis Cache

VariableDefaultDescription
enable_redisfalseEnable Redis as EspoCRM's object cache backend.
redis_host""Redis endpoint. Leave empty to use the NFS server IP.
redis_port6379Redis port.

Group 16 — Database Backend

VariableDefaultDescription
database_typenull variable default → effectively MYSQL_8_0 (EspoCRM_Common always sets MYSQL_8_0 in its config output; this variant's own database_type variable only overrides it when explicitly set to a non-null value)Cloud SQL engine. EspoCRM requires MySQL — do not select PostgreSQL.
application_database_nameespocrmMySQL database name. Immutable after first deploy.
application_database_userespocrmApplication database user. Password auto-generated in Secret Manager.

All other inputs follow standard App_GKE behaviour.


5. Outputs

These values are returned on a successful deployment and are the quickest way to locate and explore the running resources.

OutputDescription
service_nameKubernetes Service name.
namespaceNamespace the workload runs in.
service_cluster_ipIn-cluster ClusterIP.
stage_service_cluster_ipsMap of ClusterIPs for stage-specific services.
service_external_ipExternal LoadBalancer IP (when a static IP is reserved).
service_urlURL to reach EspoCRM.
database_instance_nameCloud SQL instance name.
database_nameApplication database name.
database_userApplication database user.
database_password_secretSecret Manager secret holding the DB password.
database_host / database_portDB endpoint (127.0.0.1 via the Auth Proxy) / port.
storage_bucketsCreated Cloud Storage buckets.
network_name / network_exists / regionsVPC network, presence, available regions.
container_image / container_registryDeployed image and Artifact Registry repo.
monitoring_enabled / monitoring_notification_channelsMonitoring status and channels.
initialization_jobs / db_import_jobNames of the setup (db-init) and (optional) import jobs.
deployment_id / tenant_id / resource_prefixNaming identifiers.
project_id / project_numberProject identifiers.
cicd_enabled / cicd_configurationCI/CD status and details (repo, trigger, registry).
github_repository_url / github_repository_owner / github_repository_nameCI/CD GitHub details.
artifact_registry_repository / cloudbuild_trigger_name / cloudbuild_trigger_idRegistry and build trigger.
kubernetes_readyWhether the cluster/workload is ready.
vpc_sc_enabled / vpc_sc_perimeter_name / vpc_sc_dry_run_modeVPC-SC status.
audit_logging_enabled / artifact_registry_cmek_enabledAudit logging and CMEK status.

6. Configuration Pitfalls & Sensible Defaults

Risk: Critical (data loss / outage / security) — High (service degraded) — Medium (cost or partial degradation) — Low (minor).

Inherited plan-time validation. This module passes its configuration through the App_GKE foundation engine, which validates values and combinations at plan time — binary-unit memory quotas, a StatefulSet conflict, IAP with no authorized identities, an out-of-range redis_port/backup_retention_days. Invalid configuration fails the plan with a clear, named error before any resource is created, so most mistakes below are caught up front rather than at apply or runtime.

SettingSensible valueRiskConsequence if wrong
database_typeMYSQL_8_0CriticalEspoCRM only supports MySQL; selecting PostgreSQL breaks startup.
application_database_name / application_database_userSet onceCriticalImmutable after first deploy; renaming recreates the DB/user and destroys all data.
ESPOCRM_ADMIN_PASSWORD (auto-generated)Retrieve from Secret Manager; change in UICriticalOnly sets the admin password on the first install; losing it locks you out until reset via DB.
enable_nfstrueCriticalDisabling it stores uploads on ephemeral pod disk — attachments are lost on pod restart/reschedule.
DB_HOST (overridden to 127.0.0.1)Leave as-isHighEspoCRM dials the Auth Proxy sidecar on loopback; changing it breaks DB connectivity.
enable_cloudsql_volumetrueHighThe Auth Proxy sidecar is required for MySQL connectivity on GKE.
ESPOCRM_SITE_URL (auto-derived)External LoadBalancer / custom-domain URLHighA wrong site URL breaks absolute links, the installer check, and OAuth redirects.
memory_limit2GiHighBelow 512Mi PHP 8.x OOM-kills during install/migrate and under load.
max_instance_count1 unless affinity + NFS confirmedHighScaling with a RollingUpdate on an NFS-backed app can deadlock; the foundation uses Recreate for NFS apps.
session_affinityClientIPMediumWithout stickiness, multi-replica sessions bounce between pods.
quota_memory_requests / _limitsbinary units (4Gi, 8192Mi)CriticalBare integers are bytes and block all pod scheduling in the namespace.
enable_iaponly when public UI not neededMediumIAP requires Google sign-in for every request, including API integrations.
application_versionPin in productionMediumlatest maps to a pinned tag internally, but pinning explicitly avoids surprise upgrades on redeploy.

For the foundation behaviour referenced throughout — IAM and Workload Identity, autoscaling, ingress and certificates, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC-SC, backups, and image mirroring — see App_GKE. EspoCRM-specific application configuration shared with the Cloud Run variant is described in EspoCRM_Common.