Skip to content
欢迎报名8月2日上海首个AI原生应用架构开源沙龙!Know more

Nacos supports synchronizing metadata from K8S service discovery

Data synchronization

Nacos monitors the changes of services and instances in K8S, obtains its service metadata, and synchronizes the change information to Nacos’ service discovery. Supports K8S version 1.22 (corresponding to K8S-Java-API version 14.0.0).The diagram is as follow:

Mapping scheme of K8S resource synchronization to Nacos resource (single-direction, Nacos resource synchronization to K8S resource to be supplemented) :

K8S Data to be synchronizedField in K8SField mapped to Nacos
service targetPort(pod port)(multiple)service.ports.targetPortinstance.port
service nameservice.metadata.nameinstance.cluster
service port(multiple)service.ports.portinstance.extendData<String, Object>
pod ippod.status.hostIP / service.ipFamiliesinstance.ip

Configuration file

Deploy the Nacos cluster according to the deploy document

Configure the file to enable K8S synchronization:


If you are using the Java API from an application outside the K8S cluster, you need to specify kubeConfig:


After configuration, services and instance changes in K8S are automatically synchronized to Nacos.