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

Generating route fails for wildcard hosts due to invalid name #3311

Closed
1 task done
robinmanuelthiel opened this issue Dec 30, 2022 · 5 comments · Fixed by #3312
Closed
1 task done

Generating route fails for wildcard hosts due to invalid name #3311

robinmanuelthiel opened this issue Dec 30, 2022 · 5 comments · Fixed by #3312
Labels
bug Something isn't working
Milestone

Comments

@robinmanuelthiel
Copy link

robinmanuelthiel commented Dec 30, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The following ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: wildcard-domain
  annotations:
    konghq.com/strip-path: 'true'
    konghq.com/preserve-host: 'true'
spec:
  ingressClassName: 'kong'
  rules:
  - host: '*.foo.com'
    http:
      paths:
      - path: /
        pathType: ImplementationSpecific
        backend:
          service:
            name: foo-service
            port:
              number: 80

tries to generate a route object that looks like this

{
  "protocols": [
    "http",
    "https"
  ],
  "paths": [
    "/"
  ],
  "methods": null,
  "sources": null,
  "hosts": [
    "*.foo.com"
  ],
  "name": "sbc-dev.wildcard-domain.foo-service.*.foo.com.80", // <-- invalid due to the asterisk (*)
  "created_at": 1672412759,
  "updated_at": 1672412759,
  "headers": null,
  "request_buffering": true,
  "response_buffering": true,
  "https_redirect_status_code": 426,
  "tags": null,
  "destinations": null,
  "preserve_host": true,
  "regex_priority": 0,
  "strip_path": true,
  "snis": null,
  "service": {
    "id": "cf59b775-dcf7-52e1-add6-ce91f55acba9"
  },
  "path_handling": "v0",
  "id": "f37b8676-2de6-567b-9cf6-90d9d1bcb5cb"
}

This won't be accepted by the Admin API giving the following error (from the kong-proxy logs):

time="2022-12-30T15:26:23Z" level=error msg="could not update kong admin" error="posting new config to /config: HTTP status 400 (message: \"declarative config is invalid: {services={{routes={[2]={name=\\\"invalid value 'sbc-dev.subscriptions-ingress.subscriptions-spaceblocks-subscriptions-main.*.subscriptions.eu1.dev.spaceblocks.cloud.80': the only accepted ascii characters are alphanumerics or ., -, _, and ~\\\"}}}}}\")" subsystem=dataplane-synchronizer

Expected Behavior

The route should be generated successfully.

Steps To Reproduce

See above. Pls note, that the service and ingress resource are in the same namespace, which is different from the kong namespace

Kong Ingress Controller version

v3.1

Kubernetes version

No response

Anything else?

1.23

@robinmanuelthiel robinmanuelthiel added the bug Something isn't working label Dec 30, 2022
@robinmanuelthiel
Copy link
Author

It might have worked in the past, as this user here reported a successful route generation of a similar Ingress object: https://discuss.konghq.com/t/workaround-kubernetes-ingress-to-allow-wildcard-hosts/5015

@robinmanuelthiel
Copy link
Author

robinmanuelthiel commented Dec 30, 2022

Looks like the new combined routes feature is root of this problem.

My current solution is to downgrade to version 2.7 (Helm Chart Version 2.13.1), which does not have the CombinedRoutes feature flag enabled.

@randmonkey
Copy link
Contributor

Looks like the new combined routes feature is root of this problem.

My current solution is to downgrade to version 2.7 (Helm Chart Version 2.13.1), which does not have the CombinedRoutes feature flag enabled.

You can also turn off CombinedRoutes by setting CONTROLLER_FEATURE_GATES=CombinedRoutes=false in 2.8.0. It is verified OK to use wildcard hosts.

@robinmanuelthiel
Copy link
Author

You can also turn off CombinedRoutes by setting CONTROLLER_FEATURE_GATES=CombinedRoutes=false in 2.8.0. It is verified OK to use wildcard hosts.

Thanks, is there a straight-forward way to set this via Helm?

@randmonkey
Copy link
Contributor

randmonkey commented Jan 3, 2023

You can also turn off CombinedRoutes by setting CONTROLLER_FEATURE_GATES=CombinedRoutes=false in 2.8.0. It is verified OK to use wildcard hosts.

Thanks, is there a straight-forward way to set this via Helm?

It could be configured by ingressController.env.feature_gates.
Add such section in values.yaml:

ingressController:
  env:
    feature_gates: "CombinedRoutes=false"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants