I can\'t connect to my app running with nginx ingress (Docker Desktop win 10).
The nginx-ingress controller pod is running, the app is healthy, and I have created an
On Windows the Kubernetes cluster is running in a VM. Try to access ingress on that VM-s IP address instead of localhost
.
I have managed to create Ingress resource in Kubernetes on Docker in Windows.
Steps to reproduce:
From Powershell with administrator access run below command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
System could ask you to reboot your machine.
Install Docker application with all the default options and enable Kubernetes
Install kubectl .
Run this commands:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud-generic.yaml
Restart your machine. From a cmd
prompt running as admin, do:
net stop http
Stop the listed services using services.msc
Use: netstat -a -n -o -b
and check for other processes listening on port 80.
Below is simple deployment with pods that will reply to requests:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
spec:
selector:
matchLabels:
app: hello
version: 2.0.0
replicas: 3
template:
metadata:
labels:
app: hello
version: 2.0.0
spec:
containers:
- name: hello
image: "gcr.io/google-samples/hello-app:2.0"
env:
- name: "PORT"
value: "50001"
Apply it by running command:
$ kubectl apply -f file_name.yaml
For pods to be able for you to communicate with them you need to create a service.
Example below:
apiVersion: v1
kind: Service
metadata:
name: hello-service
spec:
type: NodePort
selector:
app: hello
version: 2.0.0
ports:
- name: http
protocol: TCP
port: 80
targetPort: 50001
Apply this service definition by running command:
$ kubectl apply -f file_name.yaml
Below is simple Ingress resource using service created above:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-ingress
spec:
rules:
- host: kubernetes.docker.internal
http:
paths:
- path: /
backend:
serviceName: hello-service
servicePort: http
Take a look at:
spec:
rules:
- host: hello-test.internal
hello-test.internal
will be used as the hostname
to connect to your pods.
Apply your Ingress resource by invoking command:
$ kubectl apply -f file_name.yaml
I found this Github link that will allow you to connect to your Ingress resource by hostname
.
To achieve that add a line 127.0.0.1 hello-test.internal
to your C:\Windows\System32\drivers\etc\hosts
file and save it.
You will need Administrator privileges to do that.
Edit: The newest version of Docker Desktop for Windows already adds a hosts file entry:
127.0.0.1 kubernetes.docker.internal
Display the information about Ingress resources by invoking command:
kubectl get ingress
It should show:
NAME HOSTS ADDRESS PORTS AGE
hello-ingress hello-test.internal localhost 80 6m2s
Now you can access your Ingress resource by opening your web browser and typing
http://kubernetes.docker.internal/
The browser should output:
Hello, world!
Version: 2.0.0
Hostname: hello-84d554cbdf-2lr76
Hostname: hello-84d554cbdf-2lr76
is the name of the pod that replied.
If this solution is not working please check connections with the command:
netstat -a -n -o
(with Administrator privileges) if something is not using port 80.
I had good hopes of find an answer here but unfortunately these instructions have suffered from link rot - the mandatory and cloud-generic manifests can no longer be found at these addresses. Besides: I wouldn't advise anyone to use hyper-v anymore for using Docker on Windows - WSL is the way forward I think.
I have been trying for a while now to get a working set-up locally, but unfortunately in vain. Even the minikube ingress addon isn't an option because this cannot be used with the minikube 'none'-driver that allows direct interaction with docker desktop. Basically any other tutorial I find on the web uses the now-defunct manifest URLs...
Any suggestions would be highly appreciated.
i was facing similar issue while deploying ingress-nginx controller using the manual steps mentioned for bareMetal node at ingress-nginx-deploy however was facing an issue , however referred to the link Github link mentioned by @RMorrisey which leads to other threads where they have mentioned to install ingress-nginx using the steps mentioned for mac and it worked without making cny changes to host file , etc