Cloud Native 11 min read

How to Seamlessly Migrate Calico from etcd to Kubernetes Datastore

Learn step‑by‑step how to transition Calico’s data store from etcd to Kubernetes, covering prerequisite checks, locking the datastore, exporting and importing data, reconfiguring calicoctl, applying the new manifests, and unlocking the store, while highlighting benefits and tips for a smooth migration.

Linux Ops Smart Journey
Linux Ops Smart Journey
Linux Ops Smart Journey
How to Seamlessly Migrate Calico from etcd to Kubernetes Datastore

Prerequisites

Assume you have a running Kubernetes cluster, Calico using etcd as its datastore, and

calicoctl

installed.

Check Current Datastore

Verify the current storage backend by inspecting the Calico node daemonset for etcd environment variables.

<code>kubectl -n kube-system get ds calico-node -oyaml | grep -A3 "ETCD_"</code>

Migration Steps

Lock the etcd datastore

<code>$ calicoctl datastore migrate lock
Datastore locked.</code>

Export data from etcd

<code>$ calicoctl datastore migrate export > etcd-data</code>

Configure calicoctl for Kubernetes datastore

<code>$ calicoctl get ippool -owide</code>

Import data into Kubernetes

<code>$ DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl datastore migrate import -f etcd-data
Datastore locked.
Successfully applied 5 resource(s)
Importing IPAM resources
Successfully applied 6 IPAM resource(s)
Datastore information successfully imported. Please refer to the datastore migration documentation for next steps.</code>

Verify the import

<code>$ DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl get ippool
NAME                 CIDR           SELECTOR
default-ipv4-ippool 10.244.0.0/16  all()</code>

Install Calico using the Kubernetes datastore

<code># Download the Calico manifest for Kubernetes datastore
curl -o /etc/kubernetes/addons/calico.yaml https://raw.githubusercontent.com/projectcalico/calico/v3.27.4/manifests/calico.yaml

# Apply the manifest
kubectl apply -f /etc/kubernetes/addons/calico.yaml</code>

Unlock the datastore

<code>$ DATASTORE_TYPE=kubernetes KUBECONFIG=~/.kube/config calicoctl datastore migrate unlock
Datastore unlocked.</code>

Conclusion

Migrating Calico to use Kubernetes as its datastore reduces the overhead of maintaining a separate etcd cluster, streamlines resource management, and improves overall architecture consistency. Following the steps above ensures a smooth transition.

KubernetesetcdCalicoNetwork Policydatastore migration
Linux Ops Smart Journey
Written by

Linux Ops Smart Journey

The operations journey never stops—pursuing excellence endlessly.

0 followers
Reader feedback

How this landed with the community

login 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.