Skip to main content


Why Duplicate DevMode#

Replace DevMode is the default development mode of Nocalhost. When developing a workload, the container image of the original workload will be replaced with the development image. As shown below:


Using Replace DevMode can well maintain the original call relations between services and transfer the traffic of other services in the cluster to the service being developed. However, there are also some shortcomings:

1. It may destroy the original environment. The problems in the service being developed may cause problems to the whole environment.
2. It may affect the normal use of the environment by other team members. Other members may only want to access the normal environment rather than the development environment.
3. Multiple team members cannot develop the same service in the same K8s cluster at the same time.

To solve these problems, we can use Duplicate DevMode.

How it works#

In Duplicate DevMode, instead of modifying the original workload, Nocalhost creates a duplicate of the original workload and further develops on it. Duplicate DevMode can be run on different devices to create the duplicate of the workload for development at the same time. Nocalhost will mark the device ID on the duplicate to identify which device is developing which duplicate. (Note that the device ID is automatically generated by Nocalhost and invisible to all users. Different devices will not have the same ID). Moreover, the duplicates will not affect each other. As shown below:


The duplicate and the pod managed by it will use different labels from the original workload, so it will not receive any traffic that wants to access the original workload. The reason for doing so is that Duplicate DevMode enables you to enter the development mode on many devices, which is different from Replace DevMode, so if both the duplicate and the original workload can receive the online traffic, we cannot know which duplicate is being used and the result of accessing the environment will be unpredictable.

If the microservice application uses a third-party service discovery component (such as NACOS) instead of K8s Service, it is still possible that other services in the cluster access the duplicates created by Duplicate Mode. That also makes the result of accessing the environment unpredictable. In this case, you need to decide whether to register the service in the duplicate to the registration center.

Duplicate Mode and Replace Mode can be run in different devices in the same time, but you can only choose one for development on one device.

When we need to access the service being developed in the duplicate, we can forward the local port to the target port of the remote service by the port forwarding function of Nocalhost. Then the service can be accessed locally through lcoalhost:[local port].

The created duplicate is invisible to users, so it will not be displayed in the workload list of VS Code and Jetbrains

How to use#

Right-click Start DevMode(duplicate) on the Jetbrains and VS Code extension to enter Duplicate DevMode:


Enter Duplicate DevMode and you will see the corresponding icon of the workload, indicating that the workload is in Duplicate DevMode.


Other operations in Duplicate DevMode are the same as the default development mode.

Just like in the default development mode, if you need to access the service being developed through the local port, right-click Port Forward to use the port forwarding function of Nocalhost.


Since the traffic from other services will not be received in Duplicate Mode , what's the difference between it and running and developing the program locally?#

Running the program locally might need to import many environment variables. Especially if the workload needs other K8s resources in the cluster, such as (configmap / secrets), it will be more complicated to deal with.

Because the local programs is in a different network from the cluster, some specific configurations are required to access other services in the cluster (such as mysql, redis, etc.). Although the duplicate created by Duplicate Mode cannot be accessed by other services, it can directly access other services in the cluster.

In addition, developing the program in the container can maintain good consistency with the production environment.

Is there a limitation on the number of duplicates?#

There is no limitation on the number of duplicates in Nocalhost. Theoretically, Duplicate Mode can be run on any number of devices to create their own duplicates for development. However, it may be limited by cluster resources in real scenarios.

Last updated on by name