Cloud providers, tools and best practices in running Magento on Kubernetes Adrian Balcan DevOps @ MindMagnet Software
About Me Companies Projects Adrian Balcan contact@adrianbalcan.com
Agenda Magento on K8s? Why? How will my code get on the server? GCP & AWS tools for Magento on K8s PHP-FPM Configuration Monitoring & Alerts
Magento on K8s?!? Why? Cost effective Autoscaling Load balancing + Fast Disaster Recovery Fast Deployments with zero down time
How will my code get on the server? Developer Google Container Registry 1 Git repository AWS Elastic Container Registry 3 Docker Hub Container Registry 2 5 CI Pipeline Kubernetes Deployment Git Pull Automatic Tests App s Init Container Build Docker Image Copy source files to Shared Folder mount path /var/www/ Nginx Container ReadOnly access mount path /var/www/ PHP-FPM Container Read/Write access mount path /var/www/ Push Docker Image Kubernetes Deploy 4 EmptyDir a temporary directory that shares a pod's lifetime
Magento POD Components Magento Pod App s Init Container Copy source files to Shared Folder mount path /var/www/ Nginx Container ReadOnly access mount path /var/www/ PHP-FPM Container Read/Write access mount path /var/www/ Google FireStore AWS EFS EmptyDir a temporary directory that shares a pod's lifetime Google SQL Amazon RDS Google StackDriver AWS CloudWatch
GCP & AWS tools for Magento on K8s Google Cloud Platform Amazon Web Services Kubernetes GKE / Kops* EKS / Kops* Storage FireStore EFS Database SQL RDS Redis MemoryStore ElastiCache Logging StackDriver CloudWatch ElasticSearch VM - Cloud Engine ElasticSearch Service * Kubernetes Operations (kops) - Production Grade K8s Installation, Upgrades and Management
GCP & AWS Infra for Magento on K8s Google Cloud Platform / Amazon Web Services Kubernetes cluster ElasticSearch ElasticSearch Magento App nginx + php-fpm Browser Ingress Multiple Pods Sessions LoadBalancer Redis Magento CronJob Cache php-cli Redis Single Pods Google FireStore AWS EFS Google SQL Amazon RDS Google StackDriver AWS CloudWatch
PHP-FPM Configuration Static 10 Processes/POD Dynamic - start 2 proc Max 10 Processes/POD On-Demand Fastest Slow Fast High Mem Consumption Medium Mem Consumption Low Mem Consumption Easy to predict Hard to predict Easy to predict up to 10 processes #Winner
PHP-FPM Configuration Setting pm.max_requests to a lower value (between 200 and 500 requests per process): - Will free your RAM Memory - Will Respawn the Child processes
Best practices Keep your images small - Alpine linux is accessible Use a non-root user inside the container Set resources for each container One service per container
Open Source Tools for Monitoring, Alerting & Logs Behat - Testing Sidecar tools - Monitoring Prometheus - Monitoring Grafana - Monitoring AlertManager - Monitoring Jaeger - Trace FluentD - K8s Logging
Docker/Kubernetes Sidecar MySQL Monitoring Sidecar Mysql Monitor Can run continuously Prometheus + Grafana metrics Low resources needed Logs Go, Java, PHP and anything else bin/magento dev:query-log:enable No graphs Logs Only Magento 2
Other Solutions for Monitoring, Alerting and Logging Blackfire - Testing & Tracing New Relic - Monitoring AppDynamics by Cisco - Complete Solution DataDog - Complete Solution
Thank you! Q&A Adrian Balcan contact@adrianbalcan.com