dman
dman

Reputation: 11064

Can not access web app on the network running kubernetes and minikube

I have a docker container which runs a basic front end angular app. I have verified it runs with no issues and I can successfully access the web app in the browser with docker run -p 5901:80 formbuilder-stand-alone-form.

I am able to successfully deploy it with minikube and kubernetes on my cloud dev server

apiVersion: v1
kind: Service
metadata:
  name: stand-alone-service

spec:
  selector:        
    app: stand-alone-form
  
  ports:
    - protocol: TCP
      port: 5901
      targetPort: 80
  
  type: LoadBalancer
---
apiVersion: apps/v1

kind: Deployment

metadata:
  name: stand-alone-form-app
  labels:               
    app: stand-alone-form
spec:                   
  replicas: 1           
  
  selector:
    matchLabels:
      app: stand-alone-form

  template:
    metadata:
      labels:
        app: stand-alone-form
    
    spec:
      containers:
      - name: stand-alone-form-pod
        image: formbuilder-stand-alone-form
        imagePullPolicy: Never
        ports:                
        - containerPort: 80
one@work ...github/stand-alone-form-builder-hhh/form-builder-hhh (main)
% kubectl get pods
NAME                                    READY   STATUS    RESTARTS   AGE
stand-alone-form-app-6d4669f569-vsffc   1/1     Running   0          6s
one@work ...github/stand-alone-form-builder-hhh/form-builder-hhh (main)
% kubectl get deployments
NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
stand-alone-form-app   1/1     1            1           8s
one@work ...github/stand-alone-form-builder-hhh/form-builder-hhh (main)
% kubectl get services   
NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubernetes            ClusterIP      10.96.0.1       <none>        443/TCP          5d7h
stand-alone-service   LoadBalancer   10.96.197.197   <pending>     5901:30443/TCP   21s

However, I am not able to access it with the url:

one@work ...github/stand-alone-form-builder-hhh/form-builder-hhh
%  minikube service stand-alone-service 
|-----------|---------------------|-------------|---------------------------|
| NAMESPACE |        NAME         | TARGET PORT |            URL            |
|-----------|---------------------|-------------|---------------------------|
| default   | stand-alone-service |        5901 | http://192.168.49.2:30443 |
|-----------|---------------------|-------------|---------------------------|

In this example, http://192.168.49.2:30443/ gives me a dead web page.

I disabled all my iptables for troubleshooting.

Any idea how to access the front end web app? I was thinking I might have the selectors wrong but sure.

UPDATE: Here is the requested new outputs:

one@work ...github/stand-alone-form-builder-hhh/form-builder-hhh (main)
% kubectl describe service stand-alone-service
Name:                     stand-alone-service
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=stand-alone-form
Type:                     LoadBalancer
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.96.197.197
IPs:                      10.96.197.197
LoadBalancer Ingress:     10.96.197.197
Port:                     <unset>  5901/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  30443/TCP
Endpoints:                172.17.0.2:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
one@work ...github/stand-alone-form-builder-hhh/form-builder-hhh (main)
% minikube tunnel
Password: 
Status: 
    machine: minikube
    pid: 237498
    route: 10.96.0.0/12 -> 192.168.49.2
    minikube: Running
    services: [stand-alone-service]
    errors: 
        minikube: no errors
        router: no errors
        loadbalancer emulator: no errors

Note: I noticed with the tunnel I do have a external IP for the loadbalancer now:

one@work ...github/stand-alone-form-builder-hhh/form-builder-hhh (main)
% kubectl get service   
NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
kubernetes            ClusterIP      10.96.0.1       <none>          443/TCP          5d11h
stand-alone-service   LoadBalancer   10.98.162.179   10.98.162.179   5901:31596/TCP   3m10s

Upvotes: 0

Views: 861

Answers (1)

TheQueenIsDead
TheQueenIsDead

Reputation: 945

It looks like your LoadBalancer hasn't quite resolved correctly, as the External-IP is still marked as <pending>

According to Minikube, this happens when the tunnel is missing: https://minikube.sigs.k8s.io/docs/handbook/accessing/#check-external-ip

Have you tried running minikube tunnel in a separate command window?

Upvotes: 3

Related Questions