Dns kubernetes External IPs for new service does not update

7/26/2019

I would like to create new mongo service for kubernetes which is outside kubernetes cluster.

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

But DNS kubernetes does not update:

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.

Still got old IP address.

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

mongo-service.yaml

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
-- Thanh Nguyen Van
dns
docker
eks
kubernetes
mongodb

1 Answer

7/27/2019

Actually, I missed endpoint for this service:

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
-- Thanh Nguyen Van
Source: StackOverflow