1
votes

I am not being able to get Minikube Nginx Ingress running on my local machine using minikube. It just times out. I followed this tutorial and this one also.

Minikube version:

v1.8.1 (commit cbda04cf6bbe65e987ae52bb393c10099ab62014)

Cluster info:

// Client Version: 
{
    Major: "1",
    Minor: "17",
    GitVersion: "v1.17.1",
    GitCommit: "d224476cd0730baca2b6e357d144171ed74192d6",
    GitTreeState: "clean",
    BuildDate: "2020-01-14T21:04:32Z",
    GoVersion: "go1.13.5",
    Compiler: "gc",
    Platform: "windows/amd64"
}
// Server Version: version.Info
{
    Major: "1",
    Minor: "17",
    GitVersion: "v1.17.3",
    GitCommit: "06ad960bfd03b39c8310aaf92d1e7c12ce618213",
    GitTreeState: "clean",
    BuildDate: "2020-02-11T18:07:13Z",
    GoVersion: "go1.13.6",
    Compiler: "gc",
    Platform: "linux/amd64"
}

There must be something wrong with my local environment, but I don't know how to debug it. This is how my current environment looks like so far:

apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes-first
spec:
  type: ClusterIP
  ports:
  - port: 80
    targetPort: 8080
    name: http
  selector:
    app: hello-kubernetes-first
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-kubernetes-first
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello-kubernetes-first
  template:
    metadata:
      labels:
        app: hello-kubernetes-first
    spec:
      containers:
      - name: hello-kubernetes
        image: paulbouwer/hello-kubernetes:1.5
        ports:
        - containerPort: 8080
        env:
        - name: MESSAGE
          value: Hello from the first deployment!
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: hello-kubernetes-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: hw1.com
    http:
      paths:
      - backend:
          serviceName: hello-kubernetes-first
          servicePort: 80

System pods

~\Desktop\kubernetes> kubectl get pods -n kube-system                                                                                                                                                              NAME                                        READY   STATUS    RESTARTS   AGE
coredns-6955765f44-8zxgw                    1/1     Running   6          12d
coredns-6955765f44-jr9xq                    1/1     Running   7          12d
etcd-m01                                    1/1     Running   1          3h48m
kube-apiserver-m01                          1/1     Running   1          3h48m
kube-controller-manager-m01                 1/1     Running   597        12d
kube-proxy-mnhcl                            1/1     Running   7          12d
kube-scheduler-m01                          1/1     Running   596        12d
nginx-ingress-controller-6fc5bcc8c9-z7m2b   1/1     Running   6          27h
storage-provisioner                         1/1     Running   11         12d

C:\Windows\System32\drivers\etc\hosts

172.17.186.182 hw1.com

minikube IP

~\Desktop\kubernetes> minikube IP
172.17.186.182
2

2 Answers

2
votes

You are using ClusterIP in your Service definition and from the looks of your output, you are running minikube on Windows.

From your Windows CMD you won't be able to get to a ClusterIP since it runs in a VM (Virtual Machine). You can confirm this by running:

minikube ssh

Then in the VM:

curl 172.17.186.182

You can try exposing your service using a NodePort on the VM. This will be a port externally available from your VM, but it won't be 80 as Kubernetes allocates the configurable range of 30000-32767. You could manually change this in the kube-apiserver using the --service-node-port-range portRange option if you'd like.

apiVersion: v1
kind: Service
metadata:
  name: hello-kubernetes-first
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
    name: http
  selector:
    app: hello-kubernetes-first

Get the NodePort from your Windows CMD (example):

kubectl get svc
NAME                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
hello-kubernetes-first   NodePort    10.102.234.222   <none>        80:31181/TCP   3m51s
kubernetes               ClusterIP   10.96.0.1        <none>        443/TCP        138d

The NodePort above is 31181

Next, you have to use the IP for eth0 in your VM:

minikube ssh
$ ifconfig eth0

Then back on your Windows CMD:

curl <ip-from-eth0-above>:31181
0
votes

check if the ingress addon is enabled with:

minikube addons list

if not, enable it:

minikube addons enable ingress