educative.io

Educative

The containerPort in replicaSet yaml is different from the port in service yaml

In the example for the replicaSet yaml file, “containerPort” is 28017. However, in the example of the service yaml file, the port (target port) is 27017. The example works fine, but I was under the impression that they should be the same. Are they not related to each other at all?

Thanks for you help in advance!

Both ports are used at some point in the examples. 27017 is the default port for Mongo API while 28017 is for the UI.