9.9 KiB
Mycelium Cloud - WordPress Example
A complete, production-ready example for deploying a WordPress CMS with MariaDB database on Mycelium Cloud Kubernetes cluster. Features multi-container pod architecture, persistent storage, and comprehensive WordPress management patterns.
📁 What This Contains
This directory contains everything you need to deploy a WordPress CMS system:
- wordpress.md - This comprehensive guide
- wordpress-deployment.yaml - Multi-container pod deployment (WordPress + MariaDB)
- wordpress-service.yaml - LoadBalancer service configuration
🚀 Quick Start (3 minutes)
# 1. Deploy WordPress stack (Deployment, Service)
kubectl apply -f wordpress-deployment.yaml
kubectl apply -f wordpress-service.yaml
# 2. Wait for pods to be ready (should show 2/2 Running)
kubectl get pods -l app=wordpress
# 3. Access WordPress
kubectl port-forward service/wordpress-service 8080:80 &
# 4. Visit WordPress setup
echo "🌐 Visit: http://localhost:8080"
Expected Result: WordPress installation page will appear, ready for initial setup and configuration.
📋 What You'll Learn
- ✅ Advanced Kubernetes patterns (multi-container pods)
- ✅ WordPress deployment and configuration
- ✅ MariaDB database deployment
- ✅ LoadBalancer services on Mycelium Cloud
- ✅ Container orchestration and health checks
- ✅ WordPress initialization and setup
- ✅ Database connectivity within pods
- ✅ Production WordPress management
🏗️ Architecture
This example uses a multi-container pod pattern following the successful Mycelium Cloud patterns:
Network Flow:
kubectl port-forward → LoadBalancer Service → Pod (wordpress + mariadb)
Multi-Container Architecture:
- wordpress: WordPress with PHP 8.3 and Apache (port 80)
- mariadb: MariaDB 10.11 database server (port 3306)
- Local communication: Both containers in same pod using 127.0.0.1
🔧 Files Explanation
wordpress-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
spec:
replicas: 1
template:
spec:
# Follow successful Mycelium Cloud patterns
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
preference:
matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
containers:
# MariaDB container
- name: mariadb
image: mariadb:10.11
# Database setup and health checks
# WordPress container
- name: wordpress
image: wordpress:latest
# Web server with database connectivity
What it does:
- Creates multi-container pod with WordPress + MariaDB
- Worker node preference following successful patterns
- Proper health checks and resource limits
- Intra-pod database communication using 127.0.0.1
wordpress-service.yaml
apiVersion: v1
kind: Service
metadata:
name: wordpress-service
spec:
type: LoadBalancer
ipFamilies:
- IPv4
- IPv6
ipFamilyPolicy: RequireDualStack
selector:
app: wordpress
ports:
- name: wordpress
port: 80
targetPort: 80
What it does:
- Creates LoadBalancer service for Mycelium Cloud
- Dual-stack (IPv4 + IPv6) support
- Routes traffic to multi-container pod
🌐 Access Methods
Method 1: Port-Forward (Recommended)
# Simple port-forward
kubectl port-forward service/wordpress-service 8080:80
# Access WordPress setup
curl http://localhost:8080
Method 2: Direct Pod Access (Inside Cluster)
WordPress CLI Access:
kubectl exec -it $(kubectl get pod -l app=wordpress -o jsonpath='{.items[0].metadata.name}') -c wordpress -- /bin/bash
Database Access:
# Access MariaDB
kubectl exec -it $(kubectl get pod -l app=wordpress -o jsonpath='{.items[0].metadata.name}') -c mariadb -- mysql -u wordpress -p"wp123" wordpress
📊 WordPress Management
Initial Setup
- Visit WordPress Setup: http://localhost:8080
- Choose Language: Select your preferred language
- Site Configuration:
- Site Title: "Mycelium Cloud WordPress"
- Username: "admin" (or your choice)
- Password: Generate secure password
- Email: Your email address
- Complete Setup: WordPress will create database tables and configure
Database Operations
# Access WordPress database
kubectl exec -it $(kubectl get pod -l app=wordpress -o jsonpath='{.items[0].metadata.name}') -c mariadb -- \
mysql -u wordpress -p"wp123" wordpress -e "SHOW TABLES;"
# Check WordPress users
kubectl exec -it $(kubectl get pod -l app=wordpress -o jsonpath='{.items[0].metadata.name}') -c mariadb -- \
mysql -u wordpress -p"wp123" wordpress -e "SELECT * FROM wp_users;"
🔍 Troubleshooting
Check Deployment Status
# Check pods status (should show 2/2 Ready)
kubectl get pods -l app=wordpress
# Check service details
kubectl get svc wordpress-service
# Check container logs
kubectl logs -l app=wordpress
kubectl logs -l app=wordpress -c wordpress
kubectl logs -l app=wordpress -c mariadb
Common Issues
Pod Not Starting
# Check pod status and events
kubectl describe pod -l app=wordpress
# Check container logs
kubectl logs -l app=wordpress -c wordpress --previous
kubectl logs -l app=wordpress -c mariadb --previous
Database Connection Issues
# Test database connectivity from WordPress container
kubectl exec -it $(kubectl get pod -l app=wordpress -o jsonpath='{.items[0].metadata.name}') -c mariadb -- \
mysql -u wordpress -p"wp123" -e "SELECT 'Connection successful';"
WordPress Setup Issues
# Check WordPress configuration
kubectl exec -it $(kubectl get pod -l app=wordpress -o jsonpath='{.items[0].metadata.name}') -c wordpress -- \
cat /var/www/html/wp-config.php
🛠️ Common Operations
Updates
# Update WordPress image
kubectl set image deployment/wordpress wordpress=wordpress:6.5-php8.2-apache
# Restart deployment
kubectl rollout restart deployment/wordpress
# Check rollout status
kubectl rollout status deployment/wordpress
Monitoring
# View logs from both containers
kubectl logs -f deployment/wordpress -c wordpress
kubectl logs -f deployment/wordpress -c mariadb
# Monitor resource usage
kubectl top pod -l app=wordpress
# Check database status
kubectl exec -it $(kubectl get pod -l app=wordpress -o jsonpath='{.items[0].metadata.name}') -c mariadb -- \
mysqladmin -u wordpress -p"wp123" status
🧹 Cleanup
When you're done testing:
# Delete the application and service
kubectl delete -f wordpress-deployment.yaml -f wordpress-service.yaml
# Wait for cleanup
kubectl wait --for=delete pod -l app=wordpress --timeout=60s
# Kill any port-forwards
lsof -ti:8080 | xargs kill -9 2>/dev/null || true
# Verify cleanup
kubectl get all -l app=wordpress
🎯 What This Demonstrates
This example shows:
- Advanced Kubernetes patterns - multi-container pods, health monitoring
- Production WordPress deployment - proper configuration, database integration
- Database integration - MariaDB setup, intra-pod communication
- Mycelium Cloud networking - LoadBalancer services, port-forwarding
- Container orchestration - resource management, health checks
- Development workflows - testing, debugging, WordPress setup
🔗 Next Steps
Once you understand this example, try:
- WordPress Scaling - Multiple WordPress instances with shared database
- WordPress Clustering - Load balancing and session management
- WordPress Multisite - Multiple WordPress sites on one deployment
- Plugin Management - Automated plugin/theme deployment
- Backup Strategies - Database and file backups
- Security Hardening - SSL/TLS, security headers, access controls
- Performance Optimization - Caching, CDN integration
- Monitoring - WordPress performance and database monitoring
📚 More Examples
Other available examples:
- hello-world/ - Basic web application deployment
- nginx-static/ - Static website hosting
- python-flask/ - Python API server
- redis-cache/ - Data caching services
- nginx-nodeport/ - NodePort scaling with workers
- nginx-load-balancer/ - LoadBalancer with replicas
💡 Pro Tips
- Multi-Container Access: Use
-c container-nameto access specific containers - Database Testing: Always test database connectivity when troubleshooting
- WordPress CLI: Great for automated WordPress management
- Database Backup: Always backup before major changes
- Resource Monitoring: Watch memory usage, especially during WordPress operations
- Health Checks: Monitor the 2/2 ready status for both containers
- Port Conflicts: Use different ports (8080, 8090, etc.) if conflicts occur
- WordPress Themes: Test with different themes to understand WordPress capabilities
🎉 Success Indicators
You'll know everything is working when:
- ✅
kubectl get podsshows "2/2 Running" for wordpress pod - ✅
kubectl get svcshows wordpress-service with LoadBalancer type - ✅
curl http://localhost:8080returns WordPress installation page (HTTP 200) - ✅ No errors in
kubectl get events - ✅ WordPress setup wizard can be accessed and completed
- ✅ Database connection works from both containers
Congratulations! You've successfully deployed a production-ready WordPress CMS system on Mycelium Cloud! 🚀
🆘 Support
If you encounter issues:
- Check the troubleshooting section above
- Verify your kubeconfig is set correctly:
kubectl get nodes - Ensure your cluster is healthy:
kubectl get pods --all-namespaces - Check WordPress logs:
kubectl logs -l app=wordpress -c wordpress - Check MariaDB logs:
kubectl logs -l app=wordpress -c mariadb - Test WordPress functionality via browser at http://localhost:8080
For more help, visit our documentation or contact support.