<p>I would like to create new mongo service for kubernetes which is outside kubernetes cluster.</p>

<p>Mongo deployment and service are working fine in cluster but When I create new mongo service which external IPs , then delete all apps <code>kubectl delete</code> and mongo and create again <code>kubectl apply</code> with new mongo service. </p>

<p>But DNS kubernetes does not update: </p>

<pre><code>kubectl exec -it python-guestbook-backend-8544c67965-pxlj5 ping python-guestbook-mongodb
PING python-guestbook-mongodb.default.svc.cluster.local (172.20.74.79) 56(84) bytes of data.
</code></pre>

<p>Still got old IP address.</p>

<pre><code>NAME                                         READY   STATUS    RESTARTS   AGE
python-guestbook-backend-8544c67965-pxlj5    1/1     Running   0          28m
python-guestbook-frontend-55677f6fd7-sjrf5   1/1     Running   0          28m
python-guestbook-mongodb-567654b76f-zxd6t    1/1     Running   0          5h53m
</code></pre>

<p>mongo-service.yaml </p>

<pre><code>kind: Service
metadata:
  name: python-guestbook-mongodb
#  name: python-guestbook-mongodb
  labels:
    app: python-guestbook
    tier: db
spec:
  ports:
  - name: python-guestbook
    protocol: TCP
    port: 27017
    targetPort: 27017
  selector:
    app: python-guestbook
    tier: db
  externalIPs:
  - 18.139.115.128
</code></pre>

Thanh Nguyen Van
<p>Actually, I missed <code>endpoint</code> for this service: </p>

<pre><code>apiVersion: v1
metadata:
 name: python-guestbook-mongodb
spec:
 ports:
 - port: 27017
   targetPort: 27017
---
kind: Endpoints
apiVersion: v1
metadata:
 name: python-guestbook-mongodb
subsets:
 - addresses:
     - ip: x.x.x.x
   ports:
     - port: 27017
</code></pre>
