Restart RKE2 Kubernetes Cluster
This guide provides a step-by-step procedure for restarting an RKE2 Kubernetes cluster with master nodes and agent nodes grouped into specialized roles (app, kafka, storage).
Cluster Architecture
Section titled “Cluster Architecture”Our RKE2 cluster consists of:
- Master nodes (control plane)
- Agent nodes grouped by function:
- App type — application workloads
- Kafka type — Kafka broker pods
- Storage type — persistent storage workloads
Prerequisites
Section titled “Prerequisites”Check cluster health before proceeding:
# Verify all nodes are readykubectl get nodes
# Check control plane componentskubectl get pods -n kube-system
# Verify workload healthkubectl get pods --all-namespaces | grep -v RunningRestart Sequence
Section titled “Restart Sequence”Follow this order to minimize service disruption:
- Storage type agents (one at a time)
- Kafka type agents (one at a time)
- App type agents (one at a time)
- Master nodes (one at a time)
Phase 1 — Storage Type Agents
Section titled “Phase 1 — Storage Type Agents”Restart storage nodes one at a time to maintain quorum.
1.1 Identify storage nodes
Section titled “1.1 Identify storage nodes”kubectl get nodes -l node-type=storage1.2 Drain first storage node
Section titled “1.2 Drain first storage node”# Replace <storage-node-1> with actual node namekubectl drain <storage-node-1> \ --ignore-daemonsets \ --delete-emptydir-data \ --grace-period=120 \ --timeout=300s1.3 Restart node
Section titled “1.3 Restart node”SSH to the storage node and restart:
sudo rebootWait for service to stabilize after rebooting:
sudo systemctl status rke2-agent1.4 Uncordon node
Section titled “1.4 Uncordon node”kubectl uncordon <storage-node-1>1.5 Verify node is ready
Section titled “1.5 Verify node is ready”kubectl get node <storage-node-1>kubectl get pods -o wide | grep <storage-node-1>1.6 Repeat for remaining storage nodes
Section titled “1.6 Repeat for remaining storage nodes”Wait 2-5 minutes between nodes to ensure storage replication stabilizes.
Phase 2 — Kafka Type Agents
Section titled “Phase 2 — Kafka Type Agents”Restart Kafka nodes sequentially to maintain broker availability.
2.1 Identify Kafka nodes
Section titled “2.1 Identify Kafka nodes”kubectl get nodes -l node-type=kafka2.2 Drain first Kafka node
Section titled “2.2 Drain first Kafka node”kubectl drain <kafka-node-1> \ --ignore-daemonsets \ --delete-emptydir-data \ --grace-period=120 \ --timeout=300s2.3 Restart node
Section titled “2.3 Restart node”sudo rebootWait for service to stabilize after rebooting:
sudo systemctl status rke2-agent2.4 Uncordon and verify
Section titled “2.4 Uncordon and verify”kubectl uncordon <kafka-node-1>kubectl get node <kafka-node-1>2.5 Check Kafka broker health
Section titled “2.5 Check Kafka broker health”# Verify Kafka pods are runningkubectl get pods -n inma-kafka -o wide | grep <kafka-node-1>2.6 Repeat for remaining Kafka nodes
Section titled “2.6 Repeat for remaining Kafka nodes”Wait 3-5 minutes between nodes for broker synchronization.
Phase 3 — App Type Agents
Section titled “Phase 3 — App Type Agents”Application nodes can be restarted in parallel or sequentially based on capacity.
3.1 Identify app nodes
Section titled “3.1 Identify app nodes”kubectl get nodes -l node-type=app3.2 Drain app nodes
Section titled “3.2 Drain app nodes”You should drain one app nodes at time:
# Drain one at a time (safer)kubectl drain <app-node-1> \ --ignore-daemonsets \ --delete-emptydir-data \ --grace-period=60 \ --timeout=300s3.3 Restart each node
Section titled “3.3 Restart each node”sudo reboot3.4 Uncordon nodes
Section titled “3.4 Uncordon nodes”kubectl uncordon <app-node-1># ... etc3.5 Verify workloads
Section titled “3.5 Verify workloads”# Check all application podskubectl get pods --all-namespaces -o wide | grep <app-node-1>
# Verify deployments are healthykubectl get deployments --all-namespacesPhase 4 — Master Nodes
Section titled “Phase 4 — Master Nodes”Restart master nodes one at a time to maintain control plane quorum.
4.1 Identify master nodes
Section titled “4.1 Identify master nodes”kubectl get nodes -l node-role.kubernetes.io/master=true4.2 Restart first master
Section titled “4.2 Restart first master”4.2.1 SSH to master node
Section titled “4.2.1 SSH to master node”ssh <master-node-1>4.2.2 Reboot server
Section titled “4.2.2 Reboot server”sudo reboot4.2.3 Wait for control plane stabilization
Section titled “4.2.3 Wait for control plane stabilization”On another master or from kubectl:
kubectl get nodeskubectl get componentstatuses4.2.4 Verify master is back
Section titled “4.2.4 Verify master is back”sudo systemctl status rke2-serverkubectl get nodeskubectl get pods -n kube-system -o wide | grep <master-node-1>4.3 Wait before next master
Section titled “4.3 Wait before next master”Wait 5-10 minutes for:
- etcd member to rejoin cluster
- control plane pods to stabilize
- cluster state to synchronize
4.4 Repeat for remaining masters
Section titled “4.4 Repeat for remaining masters”Restart each master sequentially with 5-10 minute intervals.
4.5 Verify control plane health
Section titled “4.5 Verify control plane health”# Check all control plane componentskubectl get pods -n kube-systemPhase 5 — Post-Restart Verification
Section titled “Phase 5 — Post-Restart Verification”5.1 Node status
Section titled “5.1 Node status”kubectl get nodesAll nodes should show Ready.
5.2 Pod health
Section titled “5.2 Pod health”# Check for pods not in Running statekubectl get pods --all-namespaces | grep -v Running | grep -v Completed
# Check recent eventskubectl get events --all-namespaces --sort-by='.lastTimestamp' | tail -505.3 Service endpoints
Section titled “5.3 Service endpoints”kubectl get endpoints --all-namespacesVerify services have healthy endpoints.
5.4 Persistent volumes
Section titled “5.4 Persistent volumes”kubectl get pv,pvc --all-namespacesAll PVs should be Bound and PVCs Bound.
5.5 Application health checks
Section titled “5.5 Application health checks”Test critical application endpoints:
# check KalmarEnergi portal if all services workhttps://portal.kalmarenergi.seTroubleshooting
Section titled “Troubleshooting”Node won’t drain
Section titled “Node won’t drain”If drain hangs, check for:
# Pods with PDBs blocking evictionkubectl get poddisruptionbudgets --all-namespaces
# DaemonSet pods (use --ignore-daemonsets)kubectl get daemonsets --all-namespaces
# Local storage (use --delete-emptydir-data)kubectl describe node <node-name> | grep -A 10 "Non-terminated Pods"Force eviction (use cautiously):
kubectl drain <node-name> \ --ignore-daemonsets \ --delete-emptydir-data \ --force \ --grace-period=0RKE2 service won’t start
Section titled “RKE2 service won’t start”Check logs:
# For agentssudo journalctl -u rke2-agent -f# or for masterssudo journalctl -u rke2-server -fCommon issues:
- Certificate expiration
- Disk space full
- Network connectivity to master
- Kubelet port conflicts
etcd member won’t rejoin
Section titled “etcd member won’t rejoin”Check etcd member list:
kubectl exec -n kube-system etcd-<master-node> -- \ etcdctl --cacert=/var/lib/rancher/rke2/server/tls/etcd/server-ca.crt \ --cert=/var/lib/rancher/rke2/server/tls/etcd/server-client.crt \ --key=/var/lib/rancher/rke2/server/tls/etcd/server-client.key \ member listIf member is stuck, may need to remove and re-add (advanced recovery).
Pods stuck in Pending
Section titled “Pods stuck in Pending”Check scheduler and node resources:
kubectl describe pod <pod-name> -n <namespace>kubectl top nodesCommon causes:
- Insufficient resources (CPU/memory)
- Node selectors/affinity rules
- Taints preventing scheduling
Rollback Procedure
Section titled “Rollback Procedure”If issues arise during restart:
- Stop draining nodes — uncordon any drained nodes
- Restart affected services — restart RKE2 services if needed
- Restore from backup — if etcd corruption suspected
Best Practices
Section titled “Best Practices”- Test in non-production first — validate procedure in staging
- Automate with scripts — reduce human error for repeated operations
- Monitor during restart — watch metrics dashboards for anomalies
- Document deviations — record any unexpected issues for future reference
- Schedule during low traffic — minimize user impact
- Communicate status — update stakeholders throughout process
Maintenance Schedule Checklist
Section titled “Maintenance Schedule Checklist”- Backup current etcd state
- Verify cluster health pre-restart
- Notify stakeholders of maintenance window
- Restart storage type agents (sequential)
- Verify storage backend health
- Restart Kafka type agents (sequential)
- Verify Kafka broker availability
- Restart app type agents (sequential)
- Verify application health
- Restart master nodes (one at a time, 5-10 min intervals)
- Verify control plane health
- Run post-restart verification tests
- Update monitoring dashboards
- Document any issues encountered
- Notify stakeholders of completion