Migrating stateful microservices in Kubernetes requires careful state management because in-memory state is lost when a container restarts. For StatefulSet-managed workloads, the problem is compounded by identity constraints that prohibit two pods with the same ordinal from running simultaneously, forcing a sequential stop-recreate cycle with a median 38.5s of service downtime. This paper presents SHADOW Seamless Handoff And Zero-Downtime Orchestrated Workload Migration, a Kubernetes-native framework that implements the Message-based Stateful Microservice Migration (MS2M) approach as a Kubernetes Operator. SHADOW introduces the ShadowPod strategy, where a shadow pod is created from a CRIU checkpoint image on the target node while the source pod continues serving traffic, allowing concurrent operation during message replay. For StatefulSet workloads, an identity swap procedure with the ExchangeFence mechanism re-checkpoints the shadow pod, creates a StatefulSet-owned replacement, and drains both message queues to guarantee zero message loss during the handoff. An evaluation on a bare-metal Kubernetes cluster with 280 migration runs across four configurations and seven message rates (10--120msg/s) shows that, compared to the sequential baseline on the same StatefulSet workload, the ShadowPod strategy reduces the restore phase by up to 92%, eliminates service downtime entirely, and reduces total migration time by up to 77%, with zero message loss across all 280 runs.
翻译:在Kubernetes中迁移有状态微服务需要谨慎的状态管理,因为容器重启会导致内存状态丢失。对于由StatefulSet管理的工作负载,身份约束进一步加剧了问题——它禁止具有相同序号的Pod同时运行,迫使系统执行连续的停止-重建循环,造成中位数为38.5秒的服务停机。本文提出SHADOW(Seamless Handoff And Zero-Downtime Orchestrated Workload Migration),一个作为Kubernetes Operator实现的Kubernetes原生框架,其核心是基于消息的有状态微服务迁移(MS2M)方法。SHADOW引入ShadowPod策略:在目标节点上通过CRIU检查点镜像创建影子Pod,同时源Pod继续处理服务流量,从而在消息重放期间实现并发运行。针对StatefulSet工作负载,框架通过ExchangeFence机制执行身份交换流程:对影子Pod重新建立检查点,创建由StatefulSet管理的替代Pod,并清空两个消息队列以确保切换过程中零消息丢失。在裸金属Kubernetes集群上的评估表明,针对同一StatefulSet工作负载,在四种配置及七种消息速率(10-120msg/s)下进行的280次迁移测试中,ShadowPod策略相比顺序基线方案将恢复阶段缩短最多92%,完全消除服务停机,并将总迁移时间降低77%,且280次运行均未发生消息丢失。