<p>I have a cluster created in the GCP cloud having a simple k8s YAML file.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: lb-svc
  labels:
    app: lb-demo
spec:
  type: LoadBalancer
  ports:
  - port: 8080
  selector:
    app: np-demo

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: np-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: np-demo
  template:
    metadata:
      labels:
        app: np-demo
    spec:
      containers:
      - name: np-pod
        image: nigelpoulton/k8s-deep-dive:0.1
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
</code></pre>

<p>Now; this YAML configuration has a LoadBalancer service which in return exposes an external IP address to the public.
thus we can see the external IP address using:</p>

<pre><code>kubectl get svc
</code></pre>

<p>The issue is, I can easily access the load balancer using curl within the cloud shell but couldn't reach it when trying to access it from outside (example browser).</p>

<p>Tried:</p>

<pre><code>curl external-ip:8080
</code></pre>

<p>Any help?</p>

MWA
<p>Your service ip only accessible to local VPC, if you need to expose service or ingress you need reserve a static ip, read here to reserve a static ip <a href="https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address" rel="nofollow noreferrer">https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address</a></p>

<p>To assign your static ip to service, you need set <code>loadBalancerIP</code> on your service configuration</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: lb-svc
  labels:
    app: lb-demo
spec:
  type: LoadBalancer
  loadBalancerIP: &lt;your reserved ip&gt;
  ports:
  - port: 8080
  selector:
    app: np-demo
</code></pre>

<p>To assign your ip to ingress</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: &lt;name of reserved static ip&gt;
  labels:
    app: my-app
spec:
  backend:
    serviceName: lb-svc
    servicePort: 8080
</code></pre>

<p>read more <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip" rel="nofollow noreferrer">here</a></p>
