How was the cluster created?
k3d cluster create -p "8080:80@loadbalancer"What did you do afterwards?
I try to apply the following yaml to expose whale-service on localhost:8080/whale by ingress, but it fail
apiVersion: apps/v1
kind: Deployment
metadata:
name: whale-nginx
spec:
replicas: 1
selector:
matchLabels:
app: whale-nginx
template:
metadata:
labels:
app: whale-nginx
spec:
containers:
- name: whale
image: hcwxd/blue-whale
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: whale-service
spec:
type: NodePort
selector:
app: whale-nginx
ports:
- port: 3000
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: whale-ingress
spec:
rules:
- http:
paths:
- path: /whale
backend:
serviceName: whale-service
servicePort: 3000
However, I get
curl -L localhost:8080/whale
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /whale</pre>
</body>
</html>
Then, I change path: /whale to path: / and then curl -L localhost:8080 will return the correct response.
What should I change to correctly expose ingress on subpath?
System Version: macOS 10.15.6 (19G73)
Kernel Version: Darwin 19.6.0
Boot Volume: Macintosh HD
k3dk3d version v3.1.2
k3s version v1.18.9-k3s1 (default)
Client: Docker Engine - Community
Cloud integration 0.1.18
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 16:58:31 2020
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:07:04 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Hello, you might want to remove the /whale from your path before calling the service (the ingress does not remove it, it's just a rule match). Check the traefik annotations regarding rewrite-path : traefik.ingress.kubernetes.io/rewrite-target: /
@fabricev Thanks! It helps me a lot!
Hi @kafai97 , thanks for opening this issue.
And thanks a lot @fabricev for helping out here! 馃檪
Most helpful comment
Hello, you might want to remove the /whale from your path before calling the service (the ingress does not remove it, it's just a rule match). Check the traefik annotations regarding rewrite-path : traefik.ingress.kubernetes.io/rewrite-target: /