collabnix / kubelabs

Get Started with Kubernetes
https://kubelabs.collabnix.com
Apache License 2.0
2.79k stars 955 forks source link

unable to access pod from external world #76

Closed nayabatir1 closed 2 years ago

nayabatir1 commented 2 years ago
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    name: nginx-pod
spec:
  containers:
    - name: nginx
      image: nginx
      ports:
        - containerPort: 80

I used this yml config to create a pod. I tried to access pod through network namespace, but unable to do so resulted in connection timeout. but when curl inside the container index.html loads correctly.

image image

anshu049 commented 2 years ago

In kubernetes pods have their own IPs and pods are dynamic mean they often crashes. so, you cannot access pod outside cluster directly. we can access it via Services like NodePort or LoadBalancer to make the service reachable outside the cluster as it provide Virtual IP.