# Mycelium Cloud - Nginx with IPv6 Website Hosting A complete, production-ready example for deploying a globally accessible website on Mycelium Cloud using IPv6 networking. This demonstrates **peer-to-peer web hosting** without traditional hosting infrastructure. ## ๐Ÿ“ What This Contains This directory contains everything you need to deploy a professional website with global IPv6 accessibility: - **nginx-mycelium.md** - This comprehensive guide - **mycelium-website-nodeport.yaml** - Complete deployment configuration - **test-ipv6-website.sh** - IPv6 testing and verification script - **update-content.sh** - Content update script (for future use) ## ๐Ÿš€ Quick Start (3 minutes) ```bash # 1. Deploy the website kubectl apply -f mycelium-website-nodeport.yaml # 2. Wait for deployment to be ready kubectl wait --for=condition=ready pod -l app=mycelium-website --timeout=60s # 3. Get your IPv6 address POD_NAME=$(kubectl get pods -l app=mycelium-website -o name | head -1) kubectl exec $POD_NAME -- ip addr show | grep "476:\|51d:\|552:" | head -1 # 4. Access your website globally # Use the IPv6 address from step 3, replace [YOUR-IPV6] below: curl -6 "http://[YOUR-IPV6]:8080/" ``` **Expected Result:** You'll see a professional website with gradient styling and IPv6 address detection. ## ๐Ÿ“‹ What You'll Learn - โœ… IPv6-only web hosting on Mycelium Cloud - โœ… Production nginx configuration with dual-stack support - โœ… ConfigMap-based content management - โœ… Global accessibility via peer-to-peer networking - โœ… hostNetwork deployment patterns - โœ… IPv6 troubleshooting and verification ## ๐Ÿ—๏ธ Architecture This example uses a **single-file approach** with integrated components: 1. **Deployment** - Pod with nginx and custom content 2. **ConfigMaps** - HTML content and nginx configuration 3. **Service** - NodePort for external accessibility **Network Flow:** `Direct IPv6 โ†’ nginx:8080 โ†’ Custom HTML` **Key Innovation:** Uses `hostNetwork: true` for direct access to Mycelium IPv6 interfaces. ## ๐Ÿ”ง Files Explanation ### mycelium-website-nodeport.yaml ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: mycelium-website spec: replicas: 1 template: spec: hostNetwork: true # Direct IPv6 access containers: - name: nginx image: nginx:alpine ports: - containerPort: 8080 hostPort: 8080 volumeMounts: - name: html-content mountPath: /usr/share/nginx/html - name: nginx-config mountPath: /etc/nginx/conf.d volumes: - name: html-content configMap: name: mycelium-website-content - name: nginx-config configMap: name: mycelium-nginx-config ``` **What it does:** - Creates 1 pod with nginx and custom website content - Uses `hostNetwork: true` for direct IPv6 interface access - Includes ConfigMaps for dynamic content management - Dual-stack nginx (IPv4 + IPv6) configuration ## ๐ŸŒ Access Methods ### Method 1: Direct IPv6 (Primary - Recommended) ```bash # Get your pod's IPv6 address POD_NAME=$(kubectl get pods -l app=mycelium-website -o name | head -1) IPV6=$(kubectl exec $POD_NAME -- ip addr show | grep "476:\|51d:\|552:" | head -1 | awk '{print $2}' | cut -d'/' -f1) # Access your website curl -6 "http://[$IPV6]:8080/" curl -6 "http://[$IPV6]:8080/health" # Or in browser: http://[YOUR-IPV6]:8080/ ``` **Why this works:** - `hostNetwork: true` gives direct access to host IPv6 interfaces - nginx listens on both IPv4 and IPv6 - Mycelium provides globally routable IPv6 addresses - No port translation or proxy needed ### Method 2: Health Check Verification ```bash # Test health endpoint curl -6 "http://[YOUR-IPV6]:8080/health" # Expected: "healthy" # Test main page (should return 3975+ bytes) curl -6 "http://[YOUR-IPV6]:8080/" | wc -c # Expected: 3975 (or similar large number) ``` ### Method 3: Interactive Testing ```bash # Keep testing connection watch -n 2 'curl -6 -s "http://[YOUR-IPV6]:8080/health" && echo " - $(date)"' ``` ## ๐Ÿ” Troubleshooting ### Check Deployment Status ```bash # Check if pods are running kubectl get pods -l app=mycelium-website # Check service details kubectl get svc mycelium-website-service # Check what's deployed kubectl get all -l app=mycelium-website # Verify nginx is listening on both IPv4 and IPv6 POD_NAME=$(kubectl get pods -l app=mycelium-website -o name | head -1) kubectl exec $POD_NAME -- netstat -tuln | grep 8080 ``` ### Common Issues #### IPv6 Binding Problems ```bash # Problem: nginx only listening on IPv4 # Check current binding: kubectl exec $POD_NAME -- netstat -tuln | grep 8080 # Should show: # tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN # tcp 0 0 :::8080 :::* LISTEN (IPv6) # If missing IPv6, restart the deployment: kubectl delete pod $POD_NAME ``` #### Pod Not Starting ```bash # Check pod status and events kubectl describe pod -l app=mycelium-website # Check pod logs kubectl logs -l app=mycelium-website # Check nginx configuration kubectl exec $POD_NAME -- cat /etc/nginx/conf.d/default.conf ``` #### IPv6 Not Accessible ```bash # Verify IPv6 address exists kubectl exec $POD_NAME -- ip addr show | grep "476:\|51d:\|552:" # Test IPv6 connectivity ping6 [YOUR-IPV6] # Test nginx inside pod kubectl exec $POD_NAME -- curl -s http://localhost:8080/health ``` #### Content Not Loading ```bash # Verify ConfigMaps are mounted kubectl exec $POD_NAME -- ls -la /usr/share/nginx/html/ # Check actual content kubectl exec $POD_NAME -- cat /usr/share/nginx/html/index.html | head -10 # Verify nginx config is loaded kubectl exec $POD_NAME -- nginx -t ``` ## ๐Ÿ› ๏ธ Common Operations ### Updating Website Content ```bash # Update the ConfigMap with new HTML content kubectl create configmap mycelium-website-content \ --from-file=index.html=./new-website.html \ --dry-run=client -o yaml | kubectl apply -f - # Restart pod to pick up changes POD_NAME=$(kubectl get pods -l app=mycelium-website -o name | head -1) kubectl delete pod $POD_NAME ``` ### Scaling ```bash # Scale to 2 replicas (each gets different IPv6) kubectl scale deployment mycelium-website --replicas=2 # Check distribution across nodes kubectl get pods -o wide -l app=mycelium-website ``` ### Monitoring ```bash # View nginx logs kubectl logs -f deployment/mycelium-website # Check resource usage kubectl top pod -l app=mycelium-website # Monitor IPv6 addresses watch 'kubectl get pods -o wide -l app=mycelium-website' ``` ### IPv6 Address Discovery ```bash # Get all IPv6 addresses for the website pod POD_NAME=$(kubectl get pods -l app=mycelium-website -o name | head -1) kubectl exec $POD_NAME -- ip addr show | grep "inet6" | grep "scope global" # Test multiple IPv6 addresses for ipv6 in $(kubectl exec $POD_NAME -- ip addr show | grep "476:\|51d:\|552:" | awk '{print $2}' | cut -d'/' -f1); do echo "Testing IPv6: $ipv6" curl -6 -m 2 "http://[$ipv6]:8080/health" && echo " - SUCCESS" || echo " - FAILED" done ``` ## ๐Ÿงน Cleanup When you're done testing: ```bash # Delete the entire deployment kubectl delete -f mycelium-website-nodeport.yaml # Verify cleanup kubectl get all -l app=mycelium-website # Remove any lingering ConfigMaps (optional) kubectl delete configmap mycelium-website-content mycelium-nginx-config ``` ## ๐ŸŽฏ What This Demonstrates This example shows: - **IPv6-Only Web Hosting** - Complete website delivery via peer-to-peer networking - **Production nginx Configuration** - Dual-stack (IPv4/IPv6) web server - **Dynamic Content Management** - ConfigMaps for easy updates - **Global Accessibility** - Direct IPv6 URL access worldwide - **Kubernetes Best Practices** - Proper separation of concerns ## ๐Ÿ”— Next Steps Once you understand this example, try: 1. **SSL/HTTPS** - Add TLS termination for secure communications 2. **Custom Domains** - Integrate with Mycelium DNS services 3. **Multiple Applications** - Deploy several websites with load balancing 4. **Monitoring** - Add Prometheus/Grafana for observability 5. **CDN Integration** - Leverage Mycelium's distributed nature ## ๐Ÿ“š Advanced Features ### Custom nginx Configuration ```bash # Edit nginx config kubectl create configmap mycelium-nginx-config \ --from-file=default.conf=./custom-nginx.conf \ --dry-run=client -o yaml | kubectl apply -f - # Restart to apply kubectl rollout restart deployment/mycelium-website ``` ### Multiple Website Support ```bash # Deploy multiple websites (each gets unique IPv6) kubectl apply -f - <