I used this command to deploy my spring boot application
sudo kubectl run mykubernetes-springboot
--image=glgelopfalcon/springboot_docker_maven:0.0.1-SNAPSHOT --port=8080
Deplyment is created but when i check logs by
kubectl logs pod podname
It giving exception as
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
I installed postgres on my local machine.
Test for semah answer postgres.yaml
kind: Service
apiVersion: v1
metadata:
name: postgres-svc
namespace: default
spec:
type: ExternalName
externalName: 10.0.2.2
kubectl get svc gives
postgres-svc ExternalName <none> 10.0.2.2 <none> 2m12s
Spring boot app deployement logs give
IOException occurred while connecting to postgres-svc.external.svc:5432
java.net.UnknownHostException: postgres-svc.external.svc
See Question&Answers more detail:os