0

I am new to Kubernetes and I am trying to host a testing site,I have pods running as below

NAME                              READY   STATUS    RESTARTS   AGE
sasank-website-78864ff54b-656ld   1/1     Running   0          30m
sasank-website-78864ff54b-qdn65   1/1     Running   0          30m

Deployment file used:

piVersion: apps/v1
kind: Deployment
metadata:
  name: sasank-website
  labels:
    app: website
spec:
  replicas: 2
  selector:
    matchLabels:
      app: website
  template:
    metadata:
      labels:
        app: website
    spec:
      containers:
      - name: webtesting
        image: 9110727495/userdetails:latest
        ports:
        - containerPort: 80

Service file used:

apiVersion: v1
kind: Service
metadata:
  name: testingsite
  labels:
    app: website
spec:
  type: NodePort
  externalIPs:
  - 192.168.1.10
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
  selector:
    app: website

NAME          TYPE        CLUSTER-IP      EXTERNAL-IP    PORT(S)        AGE
kubernetes    ClusterIP   10.96.0.1       <none>         443/TCP        102m
testingsite   NodePort    10.96.246.110   192.168.1.10   80:31438/TCP   5m9s

When I try to access the Ip with port 31438 it is refusing to connect but it is using port 80 in the clustr. When I try to access with the same IP outside the cluster it is refusing to connect even to port 80. I am not sure how to understand this.. Please help. Thank you.

  • Where are you running your k8s cluster? minikube, cloud?.. Is there a reason to specify the externalIPs for the service? When you say outside of cluster, do you mean the same network, but different machine, or from the internet? – jabbson Dec 02 '21 at 16:53
  • @jabbson I made a cluster using 3 VMs running ubuntu, I have used a docker image file we runs apache2 server and was hosted in container. so to make it accessible to outside the cluster I used external but it is being only able to access in the cluster. What should I do? – Sasank Kathera Dec 15 '21 at 12:38

0 Answers0