Why can't I Access a Service Exposed from Minikube on Windows?

4/19/2020

I'm new to Kubernetes. I successfully created a deployment with 2 replicas of my Angular frontend application, but when I expose it with a service and try to access the service with 'minikube service service-name', the browser can't show me the application.

This is my docker file

FROM registry.gitlab.informatica.aci.it/ccsc/images/nodejs/10_15

LABEL maintainer="d.vaccaro@informatica.aci.it" name="assistenza-fo" version="v1.0.0" license=""

WORKDIR /usr/src/app

ARG PRODUCTION_MODE="false"

ENV NODE_ENV='development'
ENV HTTP_PORT=4200

COPY package*.json ./

RUN if [ "${PRODUCTION_MODE}" = "true" ] || [ "${PRODUCTION_MODE}" = "1" ]; then \
    echo "Build di produzione"; \
    npm ci --production ; \
    else \
    echo "Build di sviluppo"; \
    npm ci ; \
fi

RUN npm audit fix

RUN npm install -g @angular/cli

COPY dockerize /usr/local/bin

RUN chmod +x /usr/local/bin/dockerize

COPY . .

EXPOSE 4200

CMD ng serve --host 0.0.0.0

pod description

Name:           assistenza-fo-674f85c547-bzf8g
Namespace:      default
Priority:       0
Node:           minikube/172.17.0.2
Start Time:     Sun, 19 Apr 2020 12:41:06 +0200
Labels:         pod-template-hash=674f85c547
                run=assistenza-fo
Annotations:    <none>
Status:         Running
IP:             172.18.0.6
Controlled By:  ReplicaSet/assistenza-fo-674f85c547
Containers:
  assistenza-fo:
    Container ID:   docker://ef2bfb66d22dea56b2dc0e49e875376bf1edff369274015445806451582703a0
    Image:          registry.gitlab.informatica.aci.it/apra/sta-r/assistenza/assistenza-fo:latest
    Image ID:       docker-pullable://registry.gitlab.informatica.aci.it/apra/sta-r/assistenza/assistenza-fo@sha256:8d02a3e69d6798c1ac88815ef785e05aba6e394eb21f806bbc25fb761cca5a98
    Port:           4200/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sun, 19 Apr 2020 12:41:08 +0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-zdrwg (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  default-token-zdrwg:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-zdrwg
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

my deployment description

Name:                   assistenza-fo
Namespace:              default
CreationTimestamp:      Sun, 19 Apr 2020 12:41:06 +0200
Labels:                 run=assistenza-fo
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               run=assistenza-fo
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  run=assistenza-fo
  Containers:
   assistenza-fo:
    Image:        registry.gitlab.informatica.aci.it/apra/sta-r/assistenza/assistenza-fo:latest
    Port:         4200/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   assistenza-fo-674f85c547 (2/2 replicas created)
Events:          <none>

and my service description

Name:                     assistenza-fo
Namespace:                default
Labels:                   run=assistenza-fo
Annotations:              <none>
Selector:                 run=assistenza-fo
Type:                     LoadBalancer
IP:                       10.97.3.206
Port:                     <unset>  4200/TCP
TargetPort:               4200/TCP
NodePort:                 <unset>  30375/TCP
Endpoints:                172.18.0.6:4200,172.18.0.7:4200
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

When i run the command

minikube service assistenza-fo

I get the following output:

|-----------|---------------|-------------|-------------------------|
| NAMESPACE |     NAME      | TARGET PORT |           URL           |
|-----------|---------------|-------------|-------------------------|
| default   | assistenza-fo |        4200 | http://172.17.0.2:30375 |
|-----------|---------------|-------------|-------------------------|
* Opening service default/assistenza-fo in default browser...

but Chrome prints out: "unable to reach the site" for timeout.

Thank you

EDIT

I create again the service, this time as a NodePort service. Still not working. This is the service description:

Name:                     assistenza-fo
Namespace:                default
Labels:                   run=assistenza-fo
Annotations:              <none>
Selector:                 run=assistenza-fo
Type:                     NodePort
IP:                       10.107.46.43
Port:                     <unset>  4200/TCP
TargetPort:               4200/TCP
NodePort:                 <unset>  30649/TCP
Endpoints:                172.18.0.7:4200,172.18.0.8:4200
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
-- Yanosh
kubernetes
minikube
service
windows

1 Answer

4/22/2020

I was able to reproduce your issue.

It's actually a bug on latest version of Minikube for Windows running Docker Driver: --driver=docker

In order to make it work, download the beta version from the website:

C:\Kubernetes>rename minikube-windows-amd64.exe minikube.exe

C:\Kubernetes>dir
22/04/2020  21:10    <DIR>          .
22/04/2020  21:10    <DIR>          ..
22/04/2020  21:04        55.480.832 minikube.exe
22/04/2020  20:05               489 nginx.yaml
               2 File(s)     55.481.321 bytes
  • If you haven't yet, stop and uninstall the older version, then start Minikube with the new binary:
C:\Kubernetes>minikube.exe start --driver=docker
* minikube v1.10.0-beta.0 on Microsoft Windows 10 Pro 10.0.18363 Build 18363
* Using the docker driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Restarting existing docker container for "minikube" ...
* Preparing Kubernetes v1.18.0 on Docker 19.03.2 ...
  - kubeadm.pod-network-cidr=10.244.0.0/16
* Enabled addons: dashboard, default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube"

C:\Kubernetes>kubectl get all
NAME                        READY   STATUS    RESTARTS   AGE
pod/nginx-76df748b9-t6q59   1/1     Running   1          78m

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
service/kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP        85m
service/nginx-svc    NodePort    10.100.212.15   <none>        80:31027/TCP   78m

NAME                    READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx   1/1     1            1           78m

NAME                              DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-76df748b9   1         1         1       78m
  • Minikube is now running on version v1.10.0-beta.0, now you can run the service as intended (and note the command will be unavailable because it will be tunneling the connection:

enter image description here

  • The browser will open automatically and your service will be available:

enter image description here

If you have any doubts let me know in the comments.

-- willrof
Source: StackOverflow