'unable to connect with pod running in GKE
Created 3 node GKE cluster.
From cmd prompt local logged into gcloud.
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
- 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. likekubectl exec -it basicpod -- /bin/sh and then inside pod execute curl http://<pod-ip>
GKE cluster details:
Networking
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
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
Solution 1:[1]
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
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | dany L |
Solution 2 | Suresh |