- Update the PHP application to connect to MySQL
- Define Kubernetes manifests for MySQL
- Use Flux GitRepository and Kustomization resources for GitOps deployment
1. Update the PHP Application
On the7-demo branch, the PHP app has been extended to store high scores in a MySQL database. The connection logic in highscore.php now looks like:
2. Inspect the Infrastructure Branch
All MySQL manifests and namespace definitions reside in theinfrastructure branch under the database/ directory:
database/, you’ll find:
namespace.yamlconfigmap.yamlsecret.yamldeployment.yamlservice.yaml- PersistentVolume and PersistentVolumeClaim manifests
Storing passwords in plain text is insecure. Use sealed-secrets or another secret management solution for production environments.
3. Create a Flux GitRepository Source
Define aGitRepository resource in your Flux cluster repo (flux-clusters/dev-cluster) to track the infrastructure branch:
4. Create a Flux Kustomization
Use a Kustomization to apply resources underdatabase/:
5. Reconcile and Verify
Force Flux to apply changes immediately:database namespace is created:
database namespace:
Flux Resources Overview
Links and References
- Flux GitRepository Documentation
- Flux Kustomization Documentation
- Kubernetes Secrets
- MySQL Official Docs