During the standing up of etcd, the runtime connect uses default endpoints /run/containerd/containerd.sock /run/crio/crio.sock and /var/run/cri-docker.sock. If all three of those have rpc error: code = Unavailable desc = connection error: desc = transport: Error while dialing, what most likely is the reason? What steps can be taken to troubleshoot and fix the etcd creation?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Excellent troubleshooting question! This error indicates that the container runtime (containerd) is not running or not accessible when RKE2 is trying to start etcd as a static pod.
Root Cause Analysis
The error message shows that crictl (the CLI tool for interacting with container runtimes) cannot connect to any of the standard CRI (Container Runtime Interface) socket endpoints. For RKE2 specifically, the relevant one is containerd.
Most Likely Reasons:
Containerd hasn't started yet - RKE2 includes its own embedded containerd, and there may be a timing/startup issue
Containerd failed to start - Due to configuration errors or resource constraints
Socket file permissions issue - The socket exists but isn't accessible
Wrong socket path being checked - RKE2 uses a custom containerd socket path
Systemd service ordering issue - Dependencies not properly configured
RKE2-Specific Context
Here's the critical detail: RKE2 uses its own containerd instance at a custom path:
code
/run/k3s/containerd/containerd.sock
Even though RKE2 is a separate project from K3s, it inherited much of K3s's architecture, including this socket path naming convention.
Troubleshooting Steps
Step 1: Check RKE2 Service Status
bash
# Check if rke2-server is running
sudo systemctl status rke2-server
# Check recent logs
sudo journalctl -u rke2-server -n 100 --no-pager
# Follow logs in real-time
sudo journalctl -u rke2-server -f
Look for errors related to containerd startup.
Step 2: Verify Containerd Socket Location
bash
# Check if the RKE2 containerd socket exists
ls -la /run/k3s/containerd/containerd.sock
# If it doesn't exist, check the parent directory
ls -la /run/k3s/containerd/
# Also check for any containerd processes
ps aux | grep containerd
Step 3: Use crictl with Correct Socket
bash
# Set the correct runtime endpoint for RKE2
export CONTAINER_RUNTIME_ENDPOINT=unix:///run/k3s/containerd/containerd.sock
# Or use crictl directly with the -r flag
sudo /var/lib/rancher/rke2/bin/crictl -r unix:///run/k3s/containerd/containerd.sock ps
# Check crictl configuration
cat /etc/crictl.yaml
The /etc/crictl.yaml should look like this for RKE2:
# Check if ports are already in use (etcd uses 2379, 2380)
sudo netstat -tulpn | grep -E '2379|2380'
# Or with ss
sudo ss -tulpn | grep -E '2379|2380'
# Check disk space (etcd needs space for data-dir)
df -h /var/lib/rancher/rke2/server/db/etcd
# Check memory
free -h
Step 5: Examine Containerd Logs Specifically
bash
# Since containerd is embedded, check for containerd-specific messages
sudo journalctl -u rke2-server | grep containerd
# Look for any "panic" or "fatal" errors
sudo journalctl -u rke2-server | grep -i -E 'panic|fatal|error'
# Check the RKE2 directories have correct permissions
ls -laZ /var/lib/rancher/rke2/
ls -laZ /run/k3s/
# Ensure the rke2 data directory is writable
sudo touch /var/lib/rancher/rke2/test && sudo rm /var/lib/rancher/rke2/test
Common Fixes
Fix 1: Clean Restart
bash
# Stop the service
sudo systemctl stop rke2-server
# Clean up any stale sockets
sudo rm -f /run/k3s/containerd/containerd.sock
# Clean up pods directory (if necessary - this is more aggressive)
# sudo rm -rf /var/lib/rancher/rke2/agent/pod-manifests/*
# Start fresh
sudo systemctl start rke2-server
# Watch logs
sudo journalctl -u rke2-server -f
Fix 2: Check for Stale Processes
bash
# Look for orphaned containerd or etcd processes
ps aux | grep -E 'containerd|etcd' | grep -v grep
# Kill any stale processes (careful with this!)
# sudo pkill -9 containerd
# sudo pkill -9 etcd
# Then restart
sudo systemctl restart rke2-server
# ONLY for troubleshooting - not for production
sudo setenforce 0
# Try starting again
sudo systemctl restart rke2-server
# If this works, you need to create proper SELinux policies
# Set it back
sudo setenforce 1
Fix 5: Increase Systemd Timeout
Sometimes containerd needs more time to initialize. Edit the systemd service:
# Stop the service
sudo systemctl stop rke2-server
# Run the official uninstall script
sudo /usr/local/bin/rke2-uninstall.sh
# Clean up any remaining data
sudo rm -rf /var/lib/rancher/rke2
sudo rm -rf /etc/rancher/rke2
sudo rm -rf /run/k3s
# Reinstall
curl -sfL https://get.rke2.io | sudo sh -
# Configure
sudo mkdir -p /etc/rancher/rke2
# Add your config.yaml
# Enable and start
sudo systemctl enable rke2-server --now
# Monitor
sudo journalctl -u rke2-server -f
Debug Mode
For maximum verbosity:
bash
# Stop the service
sudo systemctl stop rke2-server
# Run manually with debug flags
sudo /usr/local/bin/rke2 server --debug
This will show you exactly what's happening during startup.
Key Indicators of Success
Once fixed, you should see:
bash
# Socket exists
$ ls -la /run/k3s/containerd/containerd.sock
srw-rw---- 1 root root 0 Jan 1 12:00 /run/k3s/containerd/containerd.sock
# crictl works
$ sudo /var/lib/rancher/rke2/bin/crictl ps
CONTAINER ID IMAGE CREATED STATE NAME POD ID
# etcd pod manifest exists
$ ls /var/lib/rancher/rke2/agent/pod-manifests/etcd.yaml
# Eventually, etcd container appears
$ sudo /var/lib/rancher/rke2/bin/crictl ps | grep etcd
Does this help narrow down your specific issue? If you share the actual error logs from journalctl, I can provide more targeted guidance!