I'm trying to configure istio VirtualService so that I can open the kubevious dashboard (https://github.com/kubevious/kubevious) through it.
I have the following setup:
resource "kubernetes_manifest" "kubevious" {
provider = kubernetes-alpha
manifest = {
apiVersion = "networking.istio.io/v1alpha3"
kind = "VirtualService"
metadata = {
name = "kubevious"
namespace = "kubevious"
}
spec = {
gateways = [
"istio-system/space-gateway"
]
hosts = [
"*"
]
http = [
{
match = [
{
uri = {
prefix = "/kubevious"
}
}
]
rewrite = {
uri = "/"
}
route = [
{
destination = {
host = "kubevious-ui-svc.kubevious.svc.cluster.local"
}
}
]
},
{
match = [
{
uri = {
prefix = "/static"
}
},
{
uri = {
prefix = "/socket"
}
},
{
uri = {
regex: "^.*\\.(ico|png|jpg)$"
}
}
]
route = [
{
destination = {
host = "kubevious-ui-svc.kubevious.svc.cluster.local"
}
}
]
}
]
}
}
}
kubevious website is opening (albeit with some socket errors which I guess are related to kubevious).
I have one issue with this approach. What if I want to host more websites which have static content? Currently everything that goes to %istio_ingress_ip%/static will be forwarded to kubevious. Any other way to configure it so that i.e. when I invoke %istio_ingress_ip%/kubevious, it will resolve the static content to %istio_ingress_ip%/kubevious/static?
What if I want to host more websites which have static content?
AFAIK you should specify hosts for that, instead of *
For example let's say you have 2 static sites, example.com and sample.com, then you create 2 hosts in your virtual service.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: example-vs
spec:
hosts:
- example.com <----
http:
- match:
- uri:
prefix: /example
- uri:
prefix: /static
- uri:
prefix: /socket
- uri:
regex: "^.*\\.(ico|png|jpg)$"
route:
- destination:
host: example.default.svc.cluster.local
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: sample-vs
spec:
hosts:
- sample.com <----
http:
- match:
- uri:
prefix: /sample
- uri:
prefix: /static
- uri:
prefix: /socket
- uri:
regex: "^.*\\.(ico|png|jpg)$"
route:
- destination:
host: sample.default.svc.cluster.local
Additional resources:
Any other way to configure it so that i.e. when I invoke %istio_ingress_ip%/kubevious, it will resolve the static content to %istio_ingress_ip%/kubevious/static?
There are few resources worth to check about rewrite in istio.