0

I have following section in my kubernetes config yml:

kind: Service
apiVersion: v1
metadata:
  name: afsa-ui-loadbalancer
  labels:
    app: afsa-ui
spec:
  # type: NodePort
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
      nodePort: 31000
  selector:
    app: afsa-ui
  # ---

I connected to remote debian VM (running on 10.99.1.173, provided by out IT department) using ssh. And started this service on that VM. Kubectl now shows:

$ kubectl get pod
NAME                                       READY   STATUS    RESTARTS   AGE
afsa-ui-9648866b9-dp252                    1/1     Running   0          30m
afsa-ui-9648866b9-lcw8m                    1/1     Running   0          30m
postgres-6bf6c4d88b-mkjd9                  1/1     Running   0          95m
springboot-postgres-k8s-76798d6f6b-l5485   1/1     Running   0          10m

Minikube shows:

~/app/src/main/resources$ minikube service list
|-------------|-------------------------|--------------|---------------------------|
|  NAMESPACE  |          NAME           | TARGET PORT  |            URL            |
|-------------|-------------------------|--------------|---------------------------|
| default     | afsa-ui-loadbalancer    |           80 | http://192.168.49.2:31000 |
| default     | kubernetes              | No node port |
| default     | postgres                | No node port |
| default     | springboot-postgres-k8s |         8080 | http://192.168.49.2:30163 |
| kube-system | kube-dns                | No node port |
|-------------|-------------------------|--------------|---------------------------|

But I am unable to access react UI rendered by afsa-ui-loadbalancer at http://10.99.1.173:31000. I tried port-forwarding as suggested here and here:

$ kubectl port-forward service/afsa-ui-loadbalancer 31001:80
Forwarding from 127.0.0.1:31001 -> 80
Forwarding from [::1]:31001 -> 80

and tried accessing http://10.99.1.173:31001. But still I am not able to access the UI. What I am missing?

Maha
  • 29
  • 2
  • When you use `kubectl port-forward` you'd connect to `http://localhost:31001`. In principle you could set up a direct route to the NodePort service, but it would involve network tunneling via the remote VM that's not really a programming-oriented problem. – David Maze Sep 05 '22 at 22:37
  • But minikube is running on VM at `10.99.1.173` and not my laptop. How can I access it using `localhost`? What is the solution in this case? – Maha Sep 05 '22 at 23:01
  • can you show me your deployment.yml? – sidharth vijayakumar Sep 06 '22 at 01:58
  • As you are using Minikube to deploy your application, have you used this command ? `minikube service -n --url` in your case the command would be `minikube service afsa-ui-loadbalancer --url` this will give you a response which will be http://: try to check if this works for you. – sidharth vijayakumar Sep 06 '22 at 02:02
  • `minikube service afsa-ui-loadbalancer --url` command outputs `http://192.168.49.2:31000` – Maha Sep 06 '22 at 09:38

0 Answers0