feat: Add comprehensive documentation and deployment reports for nginx-mycelium IPv6 hosting
This commit is contained in:
116
examples/nginx-mycelium/update-content.sh
Executable file
116
examples/nginx-mycelium/update-content.sh
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Dynamic Mycelium IPv6 Address Discovery Script
|
||||
# This script fetches Mycelium IPv6 addresses from the cluster and generates HTML content
|
||||
|
||||
set -e
|
||||
|
||||
echo "🔍 Discovering Mycelium IPv6 addresses..."
|
||||
|
||||
# Fetch IPv6 addresses from cluster nodes
|
||||
IPV6_ADDRESSES=$(kubectl get nodes -o jsonpath='{range .items[*]}{range .status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}{end}' | grep -E '^[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+$')
|
||||
|
||||
if [ -z "$IPV6_ADDRESSES" ]; then
|
||||
echo "❌ No IPv6 addresses found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Found IPv6 addresses:"
|
||||
echo "$IPV6_ADDRESSES"
|
||||
|
||||
# Generate HTML content with dynamic addresses
|
||||
cat > /tmp/index.html << HTML_EOF
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>🌍 Mycelium Global Web Hosting</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="30">
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; margin: 50px; background: #f0f0f0; }
|
||||
.container { background: white; padding: 40px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); max-width: 800px; margin: 0 auto; }
|
||||
h1 { color: #2c3e50; text-align: center; }
|
||||
.success { background: #e8f4fd; padding: 20px; border-radius: 8px; border-left: 4px solid #3498db; margin: 20px 0; }
|
||||
.info { background: #f8f9fa; padding: 20px; border-radius: 8px; margin: 20px 0; }
|
||||
.urls { background: #fff3cd; padding: 20px; border-radius: 8px; border-left: 4px solid #ffc107; margin: 20px 0; }
|
||||
.test { background: #d4edda; padding: 20px; border-radius: 8px; border-left: 4px solid #28a745; margin: 20px 0; }
|
||||
.dynamic { background: #f8d7da; padding: 20px; border-radius: 8px; border-left: 4px solid #dc3545; margin: 20px 0; }
|
||||
code { background: #f8f9fa; padding: 2px 4px; border-radius: 3px; font-size: 12px; }
|
||||
pre { background: #f8f9fa; padding: 10px; border-radius: 4px; font-size: 12px; color: #333; }
|
||||
.timestamp { text-align: center; color: #6c757d; font-size: 14px; margin-top: 20px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🌍 Mycelium Global Web Hosting</h1>
|
||||
|
||||
<div class="success">
|
||||
<h2>✅ Success!</h2>
|
||||
<p><strong>This website is globally accessible via Mycelium Cloud!</strong></p>
|
||||
<p>This demonstrates that you can host a real website that anyone with Mycelium can access from anywhere in the world.</p>
|
||||
</div>
|
||||
|
||||
<div class="dynamic">
|
||||
<h2>🔄 Dynamic Discovery</h2>
|
||||
<p><strong>IPv6 addresses are automatically discovered from the cluster!</strong></p>
|
||||
<p>This page updates every 30 seconds to show the current cluster state.</p>
|
||||
</div>
|
||||
|
||||
<div class="info">
|
||||
<h3>🗓️ Technical Details</h3>
|
||||
<ul>
|
||||
<li><strong>Deployment:</strong> 3 nginx pods across cluster nodes</li>
|
||||
<li><strong>Network:</strong> Kubernetes NodePort service for load balancing</li>
|
||||
<li><strong>Global Access:</strong> Available on all Mycelium IPv6 addresses</li>
|
||||
<li><strong>Load Balancing:</strong> Kubernetes distributes traffic across pods</li>
|
||||
<li><strong>Dynamic Discovery:</strong> IPv6 addresses fetched via kubectl</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="urls">
|
||||
<h3>🌐 Global Access URLs</h3>
|
||||
<p><strong>Your website is accessible via any Mycelium IPv6:</strong></p>
|
||||
<ul>
|
||||
HTML_EOF
|
||||
|
||||
# Add each IPv6 address to the HTML
|
||||
while IFS= read -r ipv6; do
|
||||
echo " <li><code>http://[$ipv6]:30090</code></li>" >> /tmp/index.html
|
||||
done <<< "$IPV6_ADDRESSES"
|
||||
|
||||
cat >> /tmp/index.html << HTML_EOF
|
||||
</ul>
|
||||
<p><em>Anyone with Mycelium can access your website from anywhere!</em></p>
|
||||
</div>
|
||||
|
||||
<div class="test">
|
||||
<h3>🚀 Load Balancing Test</h3>
|
||||
<p>Test if load balancing is working:</p>
|
||||
<pre>curl -H "Cache-Control: no-cache" http://[$(echo "$IPV6_ADDRESSES" | head -1)]:30090</pre>
|
||||
<p>Try multiple requests to see traffic distribute across different pods!</p>
|
||||
</div>
|
||||
|
||||
<div class="timestamp">
|
||||
<p>Last updated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")</p>
|
||||
<p>IPv6 addresses discovered: $(echo "$IPV6_ADDRESSES" | wc -l)</p>
|
||||
</div>
|
||||
|
||||
<div style="text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #dee2e6;">
|
||||
<p>
|
||||
<strong>Mycelium Cloud</strong> • Real Global Internet Infrastructure<br>
|
||||
<em>Deploy once, access worldwide! 🌍</em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML_EOF
|
||||
|
||||
echo "📝 Generated HTML content with $(echo "$IPV6_ADDRESSES" | wc -l) IPv6 addresses"
|
||||
|
||||
# Update the ConfigMap
|
||||
echo "🔄 Updating ConfigMap..."
|
||||
kubectl create configmap nginx-mycelium-content --from-file=index.html=/tmp/index.html --dry-run=client -o yaml | kubectl apply -f -
|
||||
|
||||
echo "✅ Successfully updated nginx-mycelium-content ConfigMap"
|
||||
echo "🌐 Website will be accessible at: http://[any-ipv6]:30090"
|
||||
Reference in New Issue
Block a user