Upgrading KubeEdge
Overview
This guide describes how to upgrade an existing KubeEdge cluster to a newer
version. In a typical deployment, edge nodes are remote devices already
running production workloads, so the priority of this guide is to help you
upgrade edgecore on those edge nodes safely and with minimal data loss.
A KubeEdge cluster is made up of two component groups:
- CloudCore — runs in the cloud / Kubernetes control plane. Upgraded
centrally, usually with
keadmor by re-applying the Helm chart / manifests. - EdgeCore — runs on each edge device. Each node holds local state
(the SQLite database
edgecore.dbthat caches workload, secret, and configmap data sent from the cloud, plus device twin information). This state must be preserved across an upgrade so that pods stay running and edge devices stay in sync afteredgecorerestarts.
Because of that local state, upgrading edgecore is the more delicate
part of the process. The bulk of this guide focuses on upgrading edge
nodes; an optional section at the end covers upgrading CloudCore.
Before upgrading, always check the Kubernetes compatibility matrix for the target KubeEdge version, and skim the corresponding release notes for breaking changes (CRD bumps, removed config keys, etc.).
Upgrade Strategy
There are two ways to upgrade edgecore:
Remote upgrade via the cloud (recommended for fleets). Submit a
NodeUpgradeJobresource to the Kubernetes API and let CloudCore drive the upgrade across many edge nodes in batches, with concurrency control and timeout handling. Available since KubeEdge v1.16. From v1.21 onward, the correspondingkeadmcommands are exposed askeadm edge upgrade,keadm edge backup, andkeadm edge rollback. Refer to the release notes of your target version for the exact API and CLI shape.Manual in-place upgrade on each edge device. SSH onto each edge node and run the steps below. This is the original procedure and is what the rest of this page documents. Use it when you have a small number of edge nodes, when you cannot reach edge nodes from the cloud for an automated job, or when you want full control over each step.
The remainder of this guide walks through the manual procedure.
Upgrading EdgeCore (Edge Nodes)
The manual procedure has five steps. The intent of each step is:
- Back up local state so that, if anything goes wrong, you can roll back to the previous version without losing pod/device data.
- Stop the running
edgecoreprocess so binaries and configuration can be replaced safely. - Clean up old binaries and stale runtime state to avoid mixing old and new artifacts.
- Restore the backed-up database so
edgecorerejoins the cluster with full knowledge of the workloads it was already managing. - Re-deploy
edgecoreat the new version.
Run these steps on each edge node, one node at a time. Workloads on a
node are unavailable while edgecore is stopped on that node, so use a
rolling approach if you cannot tolerate fleet-wide downtime.
1. Backup
Database
Back up the edgecore SQLite database on each edge node. This database
caches everything edgecore needs to keep workloads and devices running
when it cannot reach the cloud, so it is the single most important thing
to preserve:
mkdir -p /tmp/kubeedge_backup
cp /var/lib/kubeedge/edgecore.db /tmp/kubeedge_backup/
Config (optional)
You can keep your old edgecore.yaml so that custom changes (log levels,
module toggles, certificate paths, etc.) are easy to re-apply:
cp /etc/kubeedge/config/edgecore.yaml /tmp/kubeedge_backup/
Note: between releases, configuration options may be added, renamed, or removed. Do not drop the old config file directly into a newer
edgecore; instead, generate a fresh default withedgecore --defaultconfigand merge your custom values into it.
Device related (optional)
If you upgrade from 1.3 to 1.4, the device API was bumped from v1alpha1
to v1alpha2. You need to install
Device v1alpha2
and
DeviceModel v1alpha2,
and manually convert existing custom resources from v1alpha1 to
v1alpha2.
It's recommended to keep the v1alpha1 CRDs and custom resources in the
cluster (or exported somewhere) in case a rollback is needed.
For other version jumps, always check the release notes for similar API migrations.
2. Stop EdgeCore
Stop edgecore on the node so its files are no longer in use. How you
stop it depends on how it was originally deployed:
- Binary started directly or via
keadm:kill <edgecore-pid> - Managed by systemd:
systemctl stop edgecore
If you are upgrading the whole cluster, stop edge nodes first and only
stop CloudCore once every edgecore is down. This ordering avoids edge
nodes seeing an unexpected cloud-side restart while they are still
connected.
3. Clean Up
Remove the old edgecore runtime data directory and config directory so
the new version starts from a clean slate. The database has already been
copied to /tmp/kubeedge_backup and will be restored in the next step:
rm -rf /var/lib/kubeedge /etc/kubeedge
4. Restore the Database
Put the backed-up database back so the freshly installed edgecore picks
up all previously cached pods, secrets, configmaps, and device twins
instead of starting empty:
mkdir -p /var/lib/kubeedge
mv /tmp/kubeedge_backup/edgecore.db /var/lib/kubeedge/
5. Deploy the New EdgeCore
Install the target version of edgecore using the same method you used
originally (keadm join, binary, or systemd). For the full installation
flow see the setup guide.
If you saved your old config, regenerate a default edgecore.yaml with
the new binary and merge your customizations into it before starting the
service:
edgecore --defaultconfig > /etc/kubeedge/config/edgecore.yaml
# edit /etc/kubeedge/config/edgecore.yaml to re-apply your customizations
After edgecore starts, verify the node is back online from the cloud
side:
kubectl get nodes
kubectl get pods -A -o wide
The edge node should report Ready at the new version, and pods that
were running on it before should still be running.
Upgrading CloudCore (Optional)
CloudCore is stateless from KubeEdge's point of view (its persistent state lives in the Kubernetes API server), so upgrading it is largely a matter of rolling out new binaries or container images.
When CloudCore was installed with keadm
Use the dedicated upgrade command (available since v1.16):
keadm upgrade cloud --advertise-address=<the-exposed-ip> --kubeedge-version=<target-version>
<the-exposed-ip> should match what you originally passed to
keadm init --advertise-address so the regenerated certificates keep the
same SANs. Run keadm upgrade cloud --help for the full list of flags.
When CloudCore was installed from binaries
- Stop the running CloudCore process (
killorsystemctl stop cloudcore). - Replace the
cloudcorebinary with the new release. See Installing KubeEdge with Binary for where to download it from. - Re-apply the CRDs that ship with the new release (the install guide lists them). New releases sometimes introduce new CRDs or new versions of existing ones.
- Regenerate the default config with
cloudcore --defaultconfigand merge your customizations in, the same way as on the edge side. - Start
cloudcoreagain.
Order of operations
When upgrading both sides, the recommended order is:
- Upgrade CloudCore first (so the new APIs and CRDs are present cluster-wide).
- Then upgrade
edgecoreon each edge node, one at a time.
Cloud and edge are designed to tolerate small version skews, but they should always run versions from the supported compatibility matrix; do not let nodes stay on a much older release than the cloud for long.