I implemented the Consul application available in the Google Marketplace, and created a microservice with Cloud Run that should register in Consul. However, the microservice (spring boot app) does not recognize the name of the Consul service on the network. I have already connected to a shared VPC so that both can see each other, but it presents the error below.
Caused by: java.net.UnknownHostException: consul: Name or service not known
.
And my deployment code is as follows
gcloud run deploy bpms-gateway --image $CONTAINER_REGISTRY/$GCP_PROJECT_ID/$IMAGE_REPOSITORY/bpms-gateway:0.0.2 --platform managed --region $RUN_REGION --port 8080 --vpc-connector=vcp-p2f-connector --update-env-vars SPRING_CLOUD_CONSUL_HOST=consul --allow-unauthenticated
And a tried:
Replicate exactly what I did in my local environment (using docker-compose) by creating an environment variable SPRING_CLOUD_CONSUL_HOST passing the name of the service to it;
Pass in the variable the value consul-shared-consul-server (Consul HTTP API) but not solved;
Info from components consul application in GCP:
Any ideas to solve this? Thanks.