TheK8sBook icon indicating copy to clipboard operation
TheK8sBook copied to clipboard

Chapter 6: Using GKE does not allow to access the app

Open linuswagner opened this issue 2 years ago • 2 comments

When following the book (version year 2022) and using a GKE K8 cluster deployed like in the beginning of the book, it is not possible to access any of the deployed replica to see the deployed static webpage.
This is, because the Service located under ``deployments/svc.yml` is not suited for GKE, because it creates a service of type ClusterIP which does not expose the cluster to the internet.
Instead, the type LoadBalancer would be needed to expose the cluster and make the website available via port 8080.

This problem might apply to any part of the book where this pattern repeats. In the Pods chapter, this has been accounted for by providing a file for both local environments and cloud environments.

linuswagner avatar Aug 03 '22 13:08 linuswagner

Same here. I don't know if it has something to do with the current chapter but there is a lb.yml in the same folder, which creates a load balancer on GKE. Despite applying this file I still can't access the web app.

kerunaru avatar Aug 20 '22 08:08 kerunaru

Hello, I made the service reachable on GKE by creating a LoadBalancer service. I called it svc_2.yml (yeah, I'm great with names) with this code inside :

apiVersion: v1
kind: Service
metadata:
  name: lb-hello-world
spec:
  selector:
    app: hello-world
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  type: LoadBalancer

It now works for me, hope it helped you :)

EDIT :

  • I use this file instead of the original svc.yml provided
  • To get which ip address to call, use the kubectl get svc command as we did for the sidecar pod previously in the book

BastienLabouche avatar Sep 03 '22 17:09 BastienLabouche

If you still have this issue @kerunaru (sorry it's taken me so long to get to this)....

... tell me which chapter and sub-section and I'll try and fix it. Like you said though, the lb.yml file works in my testing. I'd be keen to try and recreate any problems you might be having and see if we can fix.

Nigel

PS. If I don't get a response I'll close the issue in a few weeks. Thanks for reaching out, and apologies again for slow response.

nigelpoulton avatar Jan 09 '23 15:01 nigelpoulton