cppforlife / knctl

Knative CLI
Apache License 2.0
163 stars 34 forks source link

Add support for custom routing #31

Open drnic opened 6 years ago

drnic commented 6 years ago

Knative/Istio supports custom host/path routing:

Would be lovely for this to be nicely handled by knctl.

drnic commented 6 years ago

WIP, I tried adding simple.knative.starkandwayne.com to the existing virtualservice but a) the route never worked; and b) within a few seconds knative re-wrote the virtualservice to remove my appended /spec/hosts item.

kubectl patch virtualservices.networking.istio.io -n my-simple-app --type json --patch '[{"op": "add", "path": "/spec/hosts/-", "value": "simple.knative.starkandwayne.com"}]' simple-app
drnic commented 6 years ago

Sweet, the following worked:

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: simple-app-entry-route
  namespace: my-simple-app
spec:
  gateways:
  - knative-shared-gateway.knative-serving.svc.cluster.local
  hosts:
  - simple.knative.starkandwayne.com
  http:
  - match:
    - uri:
        prefix: "/"
    rewrite:
      authority: simple-app.my-simple-app.svc.cluster.local
    route:
    - destination:
        host: knative-ingressgateway.istio-system.svc.cluster.local
      weight: 100
$ curl simple-app.my-simple-app.knative.starkandwayne.com
<h1>Built from Git repo using Buildpack template</h1>
$ curl simple.knative.starkandwayne.com
<h1>Built from Git repo using Buildpack template</h1>
drnic commented 6 years ago

Draft blog post which sets up two routes to two apps https://starkandwayne.com/blog/p/8a1e05ef-b2f8-4ac3-93cd-d2421ddddeca/ (will be published in a couple weeks)

cppforlife commented 6 years ago

very nice! one concern i have is how to make sure istio doesnt creep in too much into knctl since knative community is in the midst of making routing (istio) pluggable.

cppforlife commented 6 years ago

i am marking this feature request as blocked on public api from knative.