I tried to setup a simple minikube cluster with ingress.
After following this tutorial: https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
my actions:
minkube start
minikube addons enable ingress
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web --type=NodePort --port=8080
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml
- add entry to hosts file
I'm unable to curl hello-world.info
from PowerShell (also I'm unable to curl $(minikube ip)
if no host is specified in .yaml file), but it works from inside docker container cli:
# curl hello-world.info
Hello, world!
Version: 1.0.0
Hostname: web-79d88c97d6-pw565
Am I right thinking that docker is not forwarding my request to the minikube container?
Docker inspect tab:
Environment
CONTAINER
docker
PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Mounts
/VAR
/var/lib/docker/volumes/minikube/_data
/LIB/MODULES
/lib/modules
Ports
22/tcp
127.0.0.1:0
2376/tcp
127.0.0.1:0
32443/tcp
127.0.0.1:0
5000/tcp
127.0.0.1:0
8443/tcp
127.0.0.1:0
ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- host: hello-world.info
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
number: 8080
PS D:\> kubectl get ing
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress <none> hello-world.info 192.168.49.2 80 22m
minikube version: v1.18.1
minikube docker image: gcr.io/k8s-minikube/kicbase v0.0.18
system: Windows 10
edit
I also tried to create a NodePort type service on clean minikube so I could access it with cluserIP:servicePort but same thing happens. I can access it on minikube after doing minikube ssh
(IP:servicePort or 127.0.0.1:servicePort) so the service works just fine, but I'm unable to curl it from outside of docker.
edit2
Now I tried some forwarding. the below command allows me to access the 'web' service on 127.0.0.1:8080
PS D:\> kubectl port-forward service/web 8080
Forwarding from 127.0.0.1:8080 -> 8080
I suppose its similar to doing minikube service web
, but this can't be done for ingress.
minikube tunnel
seams to do nothing for me
edit3
I can verify that the ingress is working by creating 2 services:
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web --type=NodePort --port=8080
kubectl create deployment web2 --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web2 --type=NodePort --port=8080
and point path to it - ingress.yaml:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- path: /web1
pathType: Prefix
backend:
service:
name: web
port:
number: 8080
- path: /web2
pathType: Prefix
backend:
service:
name: web2
port:
number: 8080
docker cli:
# curl 127.0.0.1/web2
Hello, world!
Version: 1.0.0
Hostname: web2-5b669f8984-5tgpn
# curl 127.0.0.1/web1
Hello, world!
Version: 1.0.0
Hostname: web-79d88c97d6-8h6dq
By looking at the hostnames you can see that different pods respond. But I still can't access the ingress from outside of docker