Skip to main content
In this lesson we deploy a MySQL database for the Block Buster app using Flux (GitRepository source) and the Kustomize controller. Starting with application version 7.7.0, highscore.php persists the high score into MySQL — the app connects to the database at mysql.database.svc.cluster.local. Example snippet from highscore.php showing the connection details:
We deploy the database infrastructure first so the application can connect as soon as the database becomes available. Why use Flux + Kustomize for the database?
  • GitOps: manifests are tracked in Git and applied declaratively.
  • Selective deploy: point Kustomize to only ./database so only DB manifests are applied from the infra branch.
  • Reconciliation and drift detection are handled automatically by Flux.
Relevant docs and references Repository branches and infra layout
  • Application code: 7-demo branch.
  • Infrastructure manifests (cluster-level): infrastructure branch (Sealed Secrets, cert-manager, database, ingress-nginx, etc.)
Listing of the repository root on the infrastructure branch:
Database manifests overview Inside the database/ directory you should find manifests for: Example plain-text Secret currently in the repo (for demonstration only):
Secrets in plain text in a Git repository are a security risk. We will later encrypt these (for example, with Sealed Secrets — see Introduction to Sealed Secrets in Kubernetes) before storing them in Git.
Using Flux to deploy only the database manifests We create a Flux GitRepository source that points to the infrastructure branch and a Kustomization that references only the ./database path. This ensures only the database resources are applied, avoiding cluster-wide changes from other infra manifests. Example GitRepository manifest (save this as a Flux Source in the flux-system namespace):
Create this source with the flux CLI. Example:
Kustomization that targets only the database subdirectory:
The path: ./database ensures Flux/Kustomize applies manifests only from the database directory of the infrastructure branch. Create, reconcile, and verify After placing infra-source-git.yml and infra-database-kustomize-git-mysql.yml in your Flux cluster manifests repo (for example, block-buster/flux-clusters/dev-cluster) commit and push them. You can then reconcile manually to apply immediately. Example terminal sequence (switching to the Flux cluster repo and exporting the Git source):
Once pushed and reconciled, a new database namespace should be created by Flux:
Confirm Flux source and Kustomization status:
Check the database namespace resources When first applied the MySQL pod may be Pending while PVs are provisioned. Example:
After volumes are bound and the container starts up, resources become Running / Available:
At this point you should verify:
  • Deployment/Pod status: kubectl -n database get pods,deploy
  • Service: kubectl -n database get svc mysql (ClusterIP, port 3306)
  • PVC / PV is Bound if using dynamic storage: kubectl -n database get pvc
  • ConfigMap initialization scripts applied and Secret exists (but remember it’s currently plain text)
Helpful checks and troubleshooting
  • View pod logs: kubectl -n database logs deploy/mysql
  • Check PVC status: kubectl -n database get pvc
  • Describe pod for events and volume errors: kubectl -n database describe pod <pod-name>
Tip: If the MySQL pod stays Pending, check your storage class and PV provisioning. Use kubectl describe pod and kubectl get pvc -o wide to inspect volume binding and related events.
Next steps
  • Seal or encrypt Secrets (e.g., Sealed Secrets) and store the sealed manifest in Git rather than plain text.
  • Add application Flux sources and Kustomizations that deploy the Block Buster app images (from your OCI registry) against this cluster namespace so the app can connect to mysql.database.svc.cluster.local.
  • Monitor Flux reconciliation and application health:
    • flux get kustomizations
    • kubectl -n <app-namespace> get pods,svc
Quick checklist before deploying the app
  1. Database namespace exists and is Active.
  2. MySQL pod is Running and Deployment is Available.
  3. Service mysql is a ClusterIP on port 3306.
  4. PVC is Bound and data directory is writable.
  5. Secrets are sealed/encrypted before committing to Git.
References

Watch Video