unable to connect with pod running in GKE

12/15/2021
  1. Created 3 node GKE cluster.

  2. From cmd prompt local logged into gcloud.

  3. Created a pod with nginx container and exposed port 80
apiVersion: v1
kind: Pod
metadata:
  name: basicpod
  labels:
    type: webserver
spec:
  containers:
  - name: webcont
    image: nginx
    ports:
    - containerPort: 80
  1. Now trying to do curl command curl http://<pod-ip> but getting timeout. my question is why iam getting timeout ? the same curl command work if execute inside pod. like kubectl exec -it basicpod -- /bin/sh and then inside pod execute curl http://<pod-ip><br> GKE cluster details: <br> Networking <br> Private cluster Disabled Network default Subnet default VPC-native traffic routing Disabled Cluster pod address range (default) X.X.X.X/X Service address range X.X.X.X/X Intranode visibility Disabled NodeLocal DNSCache Disabled HTTP Load Balancing Enabled Subsetting for L4 Internal Load Balancers Disabled Control plane authorized networks Disabled Network policy Disabled Dataplane V2 Disabled Security <br> Binary authorization Disabled Shielded GKE nodes Enabled Confidential GKE Nodes Beta Disabled Application-layer secrets encryption Disabled Workload Identity Disabled Google Groups for RBAC Disabled Legacy authorization Disabled Basic authentication Disabled Client certificate Disabled
-- leffe
gke-networking
google-kubernetes-engine
kubernetes

2 Answers

12/15/2021

Curling from inside cluster should work, curling from outside (browser as an example) you need to make sure firewalls are set up. + you need to expose the service through a LB as an example

-- dany L
Source: StackOverflow

4/18/2022

Curling inside the cluster it works. create service and expose it then do curl it works fine.

apiVersion: v1
kind: Service
metadata:
  name: basicpod-svc
spec:
  selector:
     type: webserver
  type: LoadBalancer
  ports:
    - nodePort: 
      port: 80
      targetPort: 80
-- Suresh
Source: StackOverflow