Delete files
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to fix "too many open files" error in Kubernetes
|
||||
# This error occurs when the system hits inotify limits
|
||||
|
||||
echo "Fixing inotify limits for Kubernetes..."
|
||||
|
||||
# Check current inotify limits
|
||||
echo "Current inotify limits:"
|
||||
sysctl fs.inotify.max_user_watches
|
||||
sysctl fs.inotify.max_user_instances
|
||||
sysctl fs.inotify.max_queued_events
|
||||
|
||||
echo ""
|
||||
echo "Increasing inotify limits..."
|
||||
|
||||
# Increase inotify limits (temporary - lasts until reboot)
|
||||
sudo sysctl -w fs.inotify.max_user_watches=524288
|
||||
sudo sysctl -w fs.inotify.max_user_instances=1024
|
||||
sudo sysctl -w fs.inotify.max_queued_events=16384
|
||||
|
||||
# Verify the changes
|
||||
echo ""
|
||||
echo "New inotify limits:"
|
||||
sysctl fs.inotify.max_user_watches
|
||||
sysctl fs.inotify.max_user_instances
|
||||
sysctl fs.inotify.max_queued_events
|
||||
|
||||
echo ""
|
||||
echo "For permanent fix, add these lines to /etc/sysctl.conf:"
|
||||
echo "fs.inotify.max_user_watches=524288"
|
||||
echo "fs.inotify.max_user_instances=1024"
|
||||
echo "fs.inotify.max_queued_events=16384"
|
||||
echo ""
|
||||
echo "Then run: sudo sysctl -p"
|
||||
|
||||
echo ""
|
||||
echo "If you're using Docker Desktop or Kind, you may need to:"
|
||||
echo "1. Restart Docker Desktop"
|
||||
echo "2. Or for Kind: kind delete cluster && kind create cluster"
|
||||
echo "3. Or adjust the node's system limits directly"
|
||||
|
||||
echo ""
|
||||
echo "For production environments, consider adding these limits to your deployment:"
|
||||
echo "securityContext:"
|
||||
echo " runAsUser: 1000"
|
||||
echo " runAsGroup: 1000"
|
||||
echo " fsGroup: 1000"
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to fix "too many open files" error in Kubernetes
|
||||
# This error occurs when the system hits inotify limits
|
||||
|
||||
echo "🔧 Fixing Kubernetes inotify limits..."
|
||||
|
||||
# Check if we're running on macOS (Docker Desktop) or Linux
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
echo "🍎 Detected macOS - Docker Desktop environment"
|
||||
echo ""
|
||||
echo "For Docker Desktop on macOS, you need to:"
|
||||
echo "1. Open Docker Desktop settings"
|
||||
echo "2. Go to 'Resources' -> 'Advanced'"
|
||||
echo "3. Increase the memory allocation (recommended: 8GB+)"
|
||||
echo "4. Restart Docker Desktop"
|
||||
echo ""
|
||||
echo "Alternatively, you can run:"
|
||||
echo "docker system prune -a --volumes"
|
||||
echo "Then restart Docker Desktop"
|
||||
|
||||
# Also check if we can adjust macOS system limits
|
||||
echo ""
|
||||
echo "Checking current macOS inotify limits..."
|
||||
sysctl kern.maxfilesperproc
|
||||
sysctl kern.maxfiles
|
||||
|
||||
echo ""
|
||||
echo "To increase macOS limits permanently, add to /etc/sysctl.conf:"
|
||||
echo "kern.maxfiles=1048576"
|
||||
echo "kern.maxfilesperproc=65536"
|
||||
echo "Then run: sudo sysctl -w kern.maxfiles=1048576"
|
||||
echo "And: sudo sysctl -w kern.maxfilesperproc=65536"
|
||||
|
||||
elif [[ "$(uname)" == "Linux" ]]; then
|
||||
echo "🐧 Detected Linux environment"
|
||||
|
||||
# Check if we're in a Kubernetes cluster
|
||||
if kubectl cluster-info >/dev/null 2>&1; then
|
||||
echo "🎯 Detected Kubernetes cluster"
|
||||
|
||||
# Check current inotify limits
|
||||
echo ""
|
||||
echo "Current inotify limits:"
|
||||
sysctl fs.inotify.max_user_watches
|
||||
sysctl fs.inotify.max_user_instances
|
||||
sysctl fs.inotify.max_queued_events
|
||||
|
||||
# Increase limits temporarily
|
||||
echo ""
|
||||
echo "Increasing inotify limits temporarily..."
|
||||
sudo sysctl -w fs.inotify.max_user_watches=524288
|
||||
sudo sysctl -w fs.inotify.max_user_instances=1024
|
||||
sudo sysctl -w fs.inotify.max_queued_events=16384
|
||||
|
||||
# Verify changes
|
||||
echo ""
|
||||
echo "New inotify limits:"
|
||||
sysctl fs.inotify.max_user_watches
|
||||
sysctl fs.inotify.max_user_instances
|
||||
sysctl fs.inotify.max_queued_events
|
||||
|
||||
# Check if we can make permanent changes
|
||||
if [[ -f /etc/sysctl.conf ]]; then
|
||||
echo ""
|
||||
echo "Making inotify limits permanent..."
|
||||
sudo bash -c 'cat >> /etc/sysctl.conf << EOF
|
||||
# Increased inotify limits for Kubernetes
|
||||
fs.inotify.max_user_watches=524288
|
||||
fs.inotify.max_user_instances=1024
|
||||
fs.inotify.max_queued_events=16384
|
||||
EOF'
|
||||
sudo sysctl -p
|
||||
fi
|
||||
|
||||
# Check for Docker containers that might need restarting
|
||||
echo ""
|
||||
echo "Checking for running containers that might need restarting..."
|
||||
docker ps --format "{{.Names}}" | while read container; do
|
||||
echo "Restarting container: $container"
|
||||
docker restart "$container" >/dev/null 2>&1 || echo "Failed to restart $container"
|
||||
done
|
||||
|
||||
else
|
||||
echo "⚠️ Kubernetes cluster not detected"
|
||||
echo "This script should be run on a Kubernetes node or with kubectl access"
|
||||
fi
|
||||
else
|
||||
echo "❓ Unsupported operating system: $(uname)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📋 Additional recommendations:"
|
||||
echo "1. For Kind clusters: kind delete cluster && kind create cluster"
|
||||
echo "2. For Minikube: minikube stop && minikube start"
|
||||
echo "3. For production: Adjust node system limits and restart kubelet"
|
||||
echo "4. Consider adding resource limits to your deployments"
|
||||
|
||||
echo ""
|
||||
echo "✅ Inotify fix script completed!"
|
||||
Reference in New Issue
Block a user