diff --git a/examples/nginx-mycelium/nginx-mycelium.md b/examples/nginx-mycelium/nginx-mycelium.md index 18799e3..61485d9 100644 --- a/examples/nginx-mycelium/nginx-mycelium.md +++ b/examples/nginx-mycelium/nginx-mycelium.md @@ -1,459 +1,434 @@ -# ๐ Nginx-Mycelium: Global Web Hosting with IPv6 Direct Access +# Mycelium Cloud - Nginx with IPv6 Website Hosting -A **complete and proven** example of hosting a professional website globally using Mycelium Cloud Kubernetes. This demonstrates **real-world web hosting** with custom content and confirmed global accessibility. - -## ๐ฏ What's This About? - -This example shows how to: -- โ **Host a professional website globally** via Mycelium IPv6 addresses -- โ **Use hostNetwork deployment** for direct IPv6 interface binding -- โ **Serve custom content** with ConfigMap-based content management -- โ **Demonstrate confirmed global access** with working IPv6 connectivity +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 -``` -nginx-mycelium/ -โโโ nginx-mycelium.md # This comprehensive guide with testing info -โโโ mycelium-website-hostnetwork.yaml # Production deployment with custom website -โโโ update-content.sh # Dynamic IPv6 discovery script -``` +This directory contains everything you need to deploy a professional website with global IPv6 accessibility: -## ๐ Quick Start - Global Website (3 minutes) +- **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 with hostNetwork for direct IPv6 access -kubectl apply -f mycelium-website-hostnetwork.yaml +# 1. Deploy the website +kubectl apply -f mycelium-website-nodeport.yaml -# 2. Wait for pod to be ready +# 2. Wait for deployment to be ready kubectl wait --for=condition=ready pod -l app=mycelium-website --timeout=60s -# 3. Get the IPv6 address of the pod -NODE_NAME=$(kubectl get pod -l app=mycelium-website -o jsonpath='{.items[0].spec.nodeName}') -MYCELIUM_IP=$(kubectl get node $NODE_NAME -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}') +# 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 -echo "Website accessible at: http://[$MYCELIUM_IP]:80" - -# 4. Test global access from ANY Mycelium IPv6 address! -curl http://[51d:3596:6cc3:81e7:ff0f:d546:3737:4c8c]:80 -curl http://[476:c4f:b4cb:7205:ff0f:f56e:abea:6905]:80 -curl http://[552:5984:2d97:72dc:ff0f:39ef:6ec:a48c]:80 +# 4. Access your website globally +# Use the IPv6 address from step 3, replace [YOUR-IPV6] below: +curl -6 "http://[YOUR-IPV6]:8080/" ``` -**๐ Optional: Update Content with Dynamic IPv6 Discovery** +**Expected Result:** You'll see a professional website with gradient styling and IPv6 address detection. -The `update-content.sh` script can be used to regenerate content with current IPv6 addresses: +## ๐ What You'll Learn -```bash -# Run to update content with current cluster IPv6 addresses -./update-content.sh - -# This will: -# 1. Discover current Mycelium IPv6 addresses -# 2. Regenerate website content with IPv6 information -# 3. Update the ConfigMap with new content -# 4. Trigger pod update with new content -``` - -## ๐ Global Access URLs - -Once deployed, your website is **globally accessible** at all Mycelium IPv6 addresses on port 80: - -``` -๐ Master Nodes: -http://[51d:3596:6cc3:81e7:ff0f:d546:3737:4c8c]:80 -http://[476:c4f:b4cb:7205:ff0f:f56e:abea:6905]:80 -http://[538:964a:a1e1:4057:ff0f:63c7:960b:7c27]:80 - -๐ Worker Nodes: -http://[552:5984:2d97:72dc:ff0f:39ef:6ec:a48c]:80 -http://[437:9faf:1f1a:e2b1:ff0f:1fd9:7fd5:1095]:80 -http://[5c3:a162:45ab:6c53:ff0f:8c55:36b0:24af]:80 -``` - -**โ CONFIRMED WORKING**: Direct IPv6 connectivity has been tested and verified! - -**๐ Dynamic Discovery**: IPv6 addresses are automatically discovered from your cluster using the `update-content.sh` script, ensuring the URLs always match your current infrastructure. +- โ 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 -### hostNetwork Direct Access Design +This example uses a **single-file approach** with integrated components: -``` -๐ Internet (Mycelium Clients) - โ -๐ Mycelium IPv6 Network (Port 80) - โ -๐ฅ๏ธ hostNetwork Pod (direct IPv6 interface binding) - โ -๐ Custom Website Content (ConfigMap-managed) - โ -๐ nginx Web Server (custom content, health endpoints) -``` +1. **Deployment** - Pod with nginx and custom content +2. **ConfigMaps** - HTML content and nginx configuration +3. **Service** - NodePort for external accessibility -### Key Features +**Network Flow:** `Direct IPv6 โ nginx:8080 โ Custom HTML` -#### **Kubernetes Deployment with hostNetwork** +**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 interface binding + hostNetwork: true # Direct IPv6 access containers: - name: nginx image: nginx:alpine ports: - - containerPort: 80 # Standard web port - hostPort: 80 # Direct host binding + - 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 ``` -#### **Dynamic IPv6 Discovery** -The `update-content.sh` script automatically discovers Mycelium IPv6 addresses from your cluster: +**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 -# Run the script to update content with current IPv6 addresses -./update-content.sh +# 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) -# The script will: -# 1. Query kubectl for cluster node IPv6 addresses -# 2. Generate HTML with dynamic address discovery -# 3. Update the ConfigMap automatically -# 4. Show website content with current cluster state +# Access your website +curl -6 "http://[$IPV6]:8080/" +curl -6 "http://[$IPV6]:8080/health" + +# Or in browser: http://[YOUR-IPV6]:8080/ ``` -#### **Custom Website Content** -The deployment includes a professional website with: -- Modern HTML design with Mycelium Cloud branding -- Responsive layout with gradient backgrounds -- Interactive IPv6 address detection -- Real-time timestamp updates -- Professional web interface +**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 -#### **Content Management** -```yaml -volumes: -- name: html-content - configMap: - name: mycelium-website-content # Custom website content -- name: nginx-config - configMap: - name: mycelium-nginx-config # nginx configuration -``` +### Method 2: Health Check Verification -## ๐ Direct IPv6 Access Benefits - -### **Direct Interface Binding** -- **hostNetwork: true**: Pod directly binds to host network interface -- **IPv6 Address Access**: Gets Mycelium IPv6 address from host node -- **Simplified Architecture**: No service layer needed for IPv6 access -- **Direct Connectivity**: External clients connect directly to pod - -### **Performance Advantages** -- **Zero Latency**: Direct interface binding, no service proxy overhead -- **Full IPv6 Support**: Direct access to Mycelium IPv6 addresses -- **Simple Deployment**: Single pod with hostNetwork configuration -- **Production Ready**: Standard nginx configuration with health endpoints - -### **Global Accessibility** ```bash -# Access directly via any Mycelium IPv6 address -curl http://[552:5984:2d97:72dc:ff0f:39ef:6ec:a48c]:80 +# 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) ``` -## ๐ง Testing & Verification +### Method 3: Interactive Testing -### **โ CONFIRMED: IPv6 Connectivity Test** ```bash -# โ VERIFIED: Direct IPv6 connectivity working! -curl -v http://[552:5984:2d97:72dc:ff0f:39ef:6ec:a48c]:80 - -# Expected output shows successful connection: -# * Connected to 552:5984:2d97:72dc:ff0f:39ef:6ec:a48c (552:5984:2d97:72dc:ff0f:39ef:6ec:a48c) port 80 (#0) -# < HTTP/1.1 200 OK (or 404 if serving default content) -``` - -### **๐ฏ Pod Status Verification** -```bash -# Check pod status and location -kubectl get pods -l app=mycelium-website -o wide - -# Expected output shows: -# NAME READY STATUS NODE -# mycelium-website-xxxx-xxxx 1/1 Running kc22haven612worker1 - -# Get the IPv6 address of the pod's node -NODE_NAME=$(kubectl get pod -l app=mycelium-website -o jsonpath='{.items[0].spec.nodeName}') -MYCELIUM_IP=$(kubectl get node $NODE_NAME -o jsonpath='{.status.addresses[?(@.type=="InternalIP")].address}') -echo "Pod running on: $NODE_NAME with IPv6: $MYCELIUM_IP" -``` - -### **๐ Direct IPv6 Access Test** -```bash -# Test from multiple IPv6 addresses (all should work): -curl http://[51d:3596:6cc3:81e7:ff0f:d546:3737:4c8c]:80 -curl http://[476:c4f:b4cb:7205:ff0f:f56e:abea:6905]:80 -curl http://[552:5984:2d97:72dc:ff0f:39ef:6ec:a48c]:80 -curl http://[437:9faf:1f1a:e2b1:ff0f:1fd9:7fd5:1095]:80 -curl http://[5c3:a162:45ab:6c53:ff0f:8c55:36b0:24af]:80 -curl http://[538:964a:a1e1:4057:ff0f:63c7:960b:7c27]:80 - -# All should return the custom Mycelium Cloud website HTML -``` - -### **๐ฅ Health Endpoint Test** -```bash -# Test the health endpoint -kubectl exec pod/mycelium-website-xxxx-xxxx -- curl -s http://localhost:8080/health - -# Expected output: "healthy" -``` - -### **๐ Content Verification** -```bash -# Check that custom content is being served -curl -s http://[552:5984:2d97:72dc:ff0f:39ef:6ec:a48c]:80 | head -10 - -# Should show the custom Mycelium Cloud website HTML with: -# -