<p>This is my Service yaml. When create the svc on GKE.I don't know how can I visit the svc.I can't find a external ip for visiting the svc. How can I visit this svc in standard flow. Is it need to create an ingress?</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  namespace: dev
  name: ui-svc
  labels:
    targetEnv: dev
    app: ui-svc
spec:
  selector:
    app: ui
    targetEnv: dev
  ports:
    - name: ui
      port: 8080
      targetPort: 8080
      nodePort: 30080
  type: NodePort
</code></pre>
<p><a href="https://i.stack.imgur.com/XcQiN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XcQiN.png" alt="enter image description here" /></a></p>

Pengbo Wu
<p>If you don't use a <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept" rel="noreferrer">private cluster</a> where nodes don't have public IP addresses, you can access your <code>NodePort</code> services using any node's public IP address.</p>
<p>What you can see in <code>Services &amp; Ingresses</code> section in the <code>Endpoints</code> column, it's an internal, cluster ip address of your <code>NodePort</code> service.</p>
<p>If you want to know what are public IP addresses of your <strong>GKE nodes</strong>, please go to <strong>Compute Engine</strong> &gt; <strong>VM instances</strong>:</p>
<p><a href="https://i.stack.imgur.com/9jfIQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9jfIQ.png" alt="enter image description here" /></a></p>
<p>You will see the list of all your <strong>Compute Engine VMs</strong> which also includes your <strong>GKE nodes</strong>. Note the IP address in <code>External IP</code> column. You should use it along with port number which you may check in your <code>NodePort</code> service details. Simply click on it's name <code>&quot;ui-svc&quot;</code> to see the details. At the very bottom of the page you should see <code>ports</code> section which may look as follows:</p>
<p><a href="https://i.stack.imgur.com/axLbm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/axLbm.png" alt="enter image description here" /></a></p>
<p>So in my case I should use <code>&lt;any_node's_public_ip_address&gt;:31251</code>.</p>
<p>One more important thing. Don't forget to allow traffic to this port on <strong>Firewall</strong> as by default it is blocked. So you need to explicitly allow traffic to your nodes e.g. on <code>31251</code> port to be able to access it from public internet. Simply go to <strong>VPC Network</strong> &gt; <strong>Firewall</strong> and set the apropriate rule:</p>
<p><a href="https://i.stack.imgur.com/dPw60.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dPw60.png" alt="enter image description here" /></a></p>
<h3 id="update-md7s">UPDATE:</h3>
<p>If you created an <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/autopilot-overview" rel="noreferrer">Autopilot Cluster</a>, by default it is a public one, which means its nodes have public IP addresses:</p>
<p><a href="https://i.stack.imgur.com/BDdAk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BDdAk.png" alt="enter image description here" /></a></p>
<p>If during the cluster creation you've selected a second option i.e. <code>&quot;Private cluster&quot;</code>, your nodes won't have public IPs by design and you won't be able to access your <code>NodePort</code> service on any public IP. So the only option that remains in such scenario is exposing your workload via <code>LoadBalancer</code> service or <code>Ingress</code>, where a single public IP endpoint is created for you, so you can access your workload externally.</p>
<p>However if you've chosen the default option i.e. <code>&quot;Public cluster&quot;</code>, you can use your node's public IP's to access your <code>NodePort</code> service in the very same way as if you used a Standard (non-autopilot) cluster.</p>
<p>Of course in autopilot mode you won't see your nodes as compute engine VMs in your GCP console, but you can still get their public IPs by running:</p>
<pre><code>kubectl get nodes -o wide
</code></pre>
<p>They will be shown in <code>EXTERNAL-IP</code> column.</p>
<p>To connect to your cluster simply click on 3 dots you can see to the right of the cluster name (<code>&quot;Kubernetes Engine&quot;</code> &gt; <code>&quot;Clusters&quot;</code>) &gt; click <code>&quot;Connect&quot;</code> &gt; click <code>&quot;RUN IN CLOUD SHELL&quot;</code>.</p>
<p>Since you don't know what network tags have been assigned to your GKE auto-pilot nodes (if any) as you don't manage them and they are not shown in your GCP console, you won't be able to use specified network tags when defining a firewall rule to allow access to your <code>NodePort</code> service port e.g. <code>30543</code> and you would have to choose the option <code>&quot;All instances in the network&quot;</code> instead:</p>
<p><a href="https://i.stack.imgur.com/NAvdd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NAvdd.png" alt="enter image description here" /></a></p>
