<p>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. (<a href="https://cloud.google.com/vpc/docs/configure-serverless-vpc-access?hl=bg" rel="nofollow noreferrer">https://cloud.google.com/vpc/docs/configure-serverless-vpc-access?hl=bg</a>). I have created the Serverless VPC access and used in one of cloud function. </p>

<p>Now my problem is, how can I connect the internal ip of Kubernetes clusters from my cloud function?. I have written code in Go. </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>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))
    }
}</code></pre>
</div>
</div>
</p>

<p>But I am getting error: The HTTP request failed with error %s
Get <a href="http://10.59.247.177:47002/" rel="nofollow noreferrer">http://10.59.247.177:47002/</a>: dial tcp 10.59.247.177:47002: i/o timeout</p>

iOSLover
<p>By default Kubernetes services are internal to Kubernetes cluster. You have to expose services so that applications from outside of Kubernetes can connect to it. </p>

<p>There are 3 main ways to expose service in Kubernetes:</p>

<ol>
<li>Public load balancer. Service is exposed to Internet.  </li>
<li>Internal load balancer. Service is exposed internally within VPC and region.</li>
<li>NodePort. Service is exposed on Kube nodes IP addresses on some high number port. This makes service visible internally and between regions within VPC.</li>
</ol>

<p>Read more here <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types</a> and here <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer</a></p>
