Connect consul application, from marktplace kubernetes engine, with microservice google cloud run

5/27/2021

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:

  1. 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;

  2. Pass in the variable the value consul-shared-consul-server (Consul HTTP API) but not solved;

Info from components consul application in GCP: Image with info from components consul application in GCP

Any ideas to solve this? Thanks.

-- Nycolas Lacerda de Oliveira
google-cloud-platform
google-cloud-run
kubernetes
spring-boot
spring-cloud-consul

0 Answers