I have created a Kubernetes clusters with sample Spring Boot application and it works well from public ip. Now I want to access the end point of Spring boot in Kubernetes clusters. I have already followed the tutorial from Google for Configuring Serverless VPC Access. (https://cloud.google.com/vpc/docs/configure-serverless-vpc-access?hl=bg). I have created the Serverless VPC access and used in one of cloud function.
Now my problem is, how can I connect the internal ip of Kubernetes clusters from my cloud function?. I have written code in Go.
package p
import (
"fmt"
"io/ioutil"
"net/http"
)
func HelloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Println("Starting the application...")
response, err := http.Get("http://10.59.247.177:47002/")
if err != nil {
fmt.Fprint(w, "The HTTP request failed with error %s\n", err)
} else {
data, _ := ioutil.ReadAll(response.Body)
fmt.Fprint(w, string(data))
}
}
But I am getting error: The HTTP request failed with error %s Get http://10.59.247.177:47002/: dial tcp 10.59.247.177:47002: i/o timeout