I have configured mysql cluster service and I am using the that service instead of hostname in jdbc url in my application.properties. It is not resolving. But when I use the minikube URL, it is connecting correctly. Shouldn't DNS resolution happen for jdbc url as well in application.properties for a java project ?
Just as @sfgroups mentioned, it is highly likely that the service has not been properly registered. Maybe you are using a different namespace or simply the service is not available. In order to check that:
kubectl get svc and kubectl get endpoints to check if the service is registered and the mysql pods selected. It may sound silly but I advise you to check if the service name you are using is correct.kubectl get pods, get the ID of your jdbc pod and launch kubectl exec -ti <ID> nslookup <servicename>. This will give you a hint if the dns resolution is working or not.minikube addons list that dns is enabled. If it is disabled, enable it (you will need to wait a little bit) and try again.