Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying two HTTPRoutes gets 404 from one of them #3591

Closed
nak3 opened this issue Apr 18, 2021 · 0 comments · Fixed by #3598
Closed

Deploying two HTTPRoutes gets 404 from one of them #3591

nak3 opened this issue Apr 18, 2021 · 0 comments · Fixed by #3598
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor.

Comments

@nak3
Copy link
Member

nak3 commented Apr 18, 2021

What steps did you take and what happened:

1. Deploy operator and gateway(node port)

$ kubectl apply -f examples/operator/operator.yaml 
$ kubectl apply -f examples/gateway/gateway-nodeport.yaml 

2. Create two Kuard svc&deploy (Kuard1 and Kuard2)

kuard1

cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: kuard1
  name: kuard1
  namespace: projectcontour
spec:
  replicas: 3
  selector:
    matchLabels:
      app: kuard1
  template:
    metadata:
      labels:
        app: kuard1
    spec:
      containers:
      - image: gcr.io/kuar-demo/kuard-amd64:1
        name: kuard
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: kuard1
  name: kuard1
  namespace: projectcontour
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: kuard1
  sessionAffinity: None
  type: ClusterIP
EOF

kuard2

cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: kuard2
  name: kuard2
  namespace: projectcontour
spec:
  replicas: 3
  selector:
    matchLabels:
      app: kuard2
  template:
    metadata:
      labels:
        app: kuard2
    spec:
      containers:
      - image: gcr.io/kuar-demo/kuard-amd64:1
        name: kuard
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: kuard2
  name: kuard2
  namespace: projectcontour
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8080
  selector:
    app: kuard2
  sessionAffinity: None
  type: ClusterIP
EOF

3. Deploy two HTTPRoute for kuard1 and kuard2

cat <<EOF | kubectl apply -f -
apiVersion: networking.x-k8s.io/v1alpha1
kind: HTTPRoute
metadata:
  labels:
    app: kuard
  name: kuard1
  namespace: projectcontour
spec:
  gateways:
    allow: SameNamespace
  hostnames:
  - kuard1.projectcontour.io
  rules:
  - forwardTo:
    - port: 80
      serviceName: kuard1
---
apiVersion: networking.x-k8s.io/v1alpha1
kind: HTTPRoute
metadata:
  labels:
    app: kuard
  name: kuard2
  namespace: projectcontour
spec:
  gateways:
    allow: SameNamespace
  hostnames:
  - kuard2.projectcontour.io
  rules:
  - forwardTo:
    - port: 80
      serviceName: kuard2
EOF

4. Access to the URL. (kuard1 or kuar2 gets 404).

$ curl -H "Host: kuard1.projectcontour.io" 172.20.0.3:30080 -o /dev/null -w '%{http_code}\n' -s
200
$ curl -H "Host: kuard2.projectcontour.io" 172.20.0.3:30080 -o /dev/null -w '%{http_code}\n' -s
404

NOTE Sometimes (it's very rare on my end though) it works, so you can remove HTTPRoutes and retry step-3.

5. If working HTTPRoute (kuard1 above case), curl to kuard2 started working.

$ kubectl delete httproute -n projectcontour kuard1
httproute.networking.x-k8s.io "kuard1" deleted

$ curl -H "Host: kuard2.projectcontour.io" 172.20.0.3:30080 -o /dev/null -w '%{http_code}\n' -s
200

What did you expect to happen:

In step-4, both get 200.

Environment:

Contour version: HEAD (deployed by projectcontour/contour-operator@4209811)

@nak3 nak3 added kind/bug Categorizes issue or PR as related to a bug. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor. labels Apr 18, 2021
@stevesloka stevesloka self-assigned this Apr 20, 2021
stevesloka added a commit to stevesloka/contour that referenced this issue Apr 20, 2021
When processing through HTTPRoutes to validate if they match the configured Gateway,
any additional HTTPRoutes would not get processed after the first one. This was
due to an unneeded "break" in the code stopping execution for valid routes.

Fixes projectcontour#3591

Signed-off-by: Steve Sloka <slokas@vmware.com>
stevesloka added a commit that referenced this issue Apr 20, 2021
When processing through HTTPRoutes to validate if they match the configured Gateway,
any additional HTTPRoutes would not get processed after the first one. This was
due to an unneeded "break" in the code stopping execution for valid routes.

Fixes #3591

Signed-off-by: Steve Sloka <slokas@vmware.com>
knative-prow-robot pushed a commit to knative-extensions/net-gateway-api that referenced this issue Apr 21, 2021
Since this broker issue projectcontour/contour#3591
was solved, we can run multiple tests now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants