Cloud Native 11 min read

Seamless Migration of Stateful Apps with ACK Backup Center’s Resource Adjustment

This guide explains how Alibaba Cloud ACK Backup Center enables reliable backup, resource adjustment, and seamless migration of stateful applications across Kubernetes clusters, detailing the backup workflow, configurable adjustment strategies, and a step‑by‑step example of moving a StatefulSet from an on‑premise cluster to ACK.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Seamless Migration of Stateful Apps with ACK Backup Center’s Resource Adjustment

Introduction

Backing up and restoring Kubernetes (K8s) clusters is essential for disaster recovery (DR) and workload migration. Differences between source and target clusters often require manual resource adjustments, which increase operational complexity and recovery time (RTO). The ACK Backup Center automates these adjustments during the restore phase.

ACK Backup Center Overview

The Backup Center provides a unified backup‑and‑migration service for containerized workloads. The typical workflow consists of three steps:

Backup

Optional resource‑adjustment strategy

Restore

During restore, the system can automatically adapt resources (namespace, storage class, image registry, etc.) to the target cluster environment.

Backup Process

Operators can create periodic backup plans or one‑time application backups. Unlike plain ETCD snapshots, the Backup Center allows selection by namespace, label, and resource type, and can include PersistentVolume (PV) data for stateful applications. Backups are stored unchanged in an OSS bucket.

Resource Adjustment Strategies

The Backup Center defines three categories of adjustment strategies:

Default modification : No configuration required. The component automatically removes temporary fields (e.g., uid), upgrades API versions, converts FlexVolume to CSI, and applies known cross‑cloud compatibility fixes.

Common modification : Simple field mappings configured on the restore task, such as namespace mapping, storage‑class mapping, image‑registry mapping, and annotation rewrites for Services and Ingresses.

General modification : Advanced changes using Velero’s resourceModifier feature. Users supply a ConfigMap containing JSON‑patch operations (add, delete, replace) to modify arbitrary fields.

Best‑Practice Guidelines

Use default modification for straightforward DR scenarios.

Apply common modification when migrating to a different namespace, storage class, or image registry.

Leverage general modification for complex changes such as removing node affinity or altering custom annotations.

Migration Example: Stateful Application

This example shows how to move a stateful Nginx application from a self‑built K8s cluster (Alibaba Cloud ECS nodes) to an ACK cluster.

1. Deploy the StatefulSet on the source cluster

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
  namespace: default
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  serviceName: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: is_idc
                operator: Exists
      containers:
      - name: nginx
        image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
        ports:
        - containerPort: 80
          name: web
          protocol: TCP
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html/
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 20Gi
      storageClassName: alicloud-disk-topology-alltype
      volumeMode: Filesystem

2. Create a backup task

apiVersion: csdr.alibabacloud.com/v1beta1
kind: ApplicationBackup
metadata:
  name: BACKUP_NAME
  namespace: csdr
spec:
  backupType: AppAndPvBackup
  includedNamespaces:
  - default
  pvBackup:
    defaultPvBackup: true
  storageLocation: BACKUP_LOCATION
  ttl: 720h0m0s

Wait until the backup status becomes Completed.

3. Define a custom resource‑adjustment ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: BACKUP_NAME-resource-modifier
  namespace: csdr
data:
  modifier: |
    version: v1
    resourceModifierRules:
    - conditions:
        groupResource: statefulsets.apps
        namespaces:
        - default
        labelSelector:
          matchLabels:
            app: nginx
      patches:
      - operation: remove
        path: "/spec/template/spec/affinity/nodeAffinity"
    - conditions:
        groupResource: pods
        resourceNameRegex: "^web.*$"
        namespaces:
        - default
        labelSelector:
          matchLabels:
            app: nginx
      patches:
      - operation: remove
        path: "/spec/affinity"

4. Restore to the ACK cluster with adjustments

apiVersion: csdr.alibabacloud.com/v1beta1
kind: ApplicationRestore
metadata:
  name: RESTORE_NAME
  namespace: csdr
spec:
  backupName: BACKUP_NAME
  namespaceMapping:
    default: default1
  imageRegistryMapping:
    anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis: registry.cn-beijing.aliyuncs.com/ACR_REGISTRY
  resourceModifier:
    kind: ConfigMap
    name: BACKUP_NAME-resource-modifier

After the restore reaches Completed, verify that the namespace, image registry, and node affinity have been updated as expected.

5. Verify the restored StatefulSet

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
  namespace: default1
  labels:
    app: nginx
spec:
  replicas: 2
  template:
    spec:
      affinity: {}
      containers:
      - name: nginx
        image: registry.cn-beijing.aliyuncs.com/ACR_REGISTRY/nginx:1.14.1-8.6
        ports:
        - containerPort: 80
          name: web
          protocol: TCP
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html/

The application starts successfully on unlabelled ACK nodes, and the restored volume is attached as a new disk.

Conclusion

By leveraging ACK Backup Center’s flexible resource‑adjustment policies, operators can handle environment‑specific differences during Kubernetes backup and migration, achieving smooth business continuity and rapid recovery across clusters.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

KubernetesBackupACK
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.