Virtual Service Route Controller
Construct Istio VirtualService
resource from some components.
✍ This is study about custom controller.
Usage
- Create
VirtualServiceBase
resource.
$ cat <<EOF | kubectl apply -f -
apiVersion: virtualservicecomponent.shibataka000.com/v1alpha1
kind: VirtualServiceBase
metadata:
name: virtualservicebase-sample
spec:
gateways:
- gateway
hosts:
- '*'
EOF
- Create
HTTPRouteBinding
resources.
$ cat <<EOF | kubectl apply -f -
apiVersion: virtualservicecomponent.shibataka000.com/v1alpha1
kind: HTTPRouteBinding
metadata:
name: httproutebinding-sample-1
spec:
virtualServiceBaseRef:
apiVersion: virtualservicecomponent.shibataka000.com/v1alpha1
kind: VirtualServiceBase
name: virtualservicebase-sample
namespace: default
httpRoute:
match:
- headers:
key:
exact: mysubset-1
route:
- destination:
host: myhost
subset: mysubset-1
EOF
$ cat <<EOF | kubectl apply -f -
apiVersion: virtualservicecomponent.shibataka000.com/v1alpha1
kind: HTTPRouteBinding
metadata:
name: httproutebinding-sample-2
spec:
virtualServiceBaseRef:
apiVersion: virtualservicecomponent.shibataka000.com/v1alpha1
kind: VirtualServiceBase
name: virtualservicebase-sample
namespace: default
httpRoute:
match:
- headers:
key:
exact: mysubset-2
route:
- destination:
host: myhost
subset: mysubset-2
EOF
- VirtualServiceRouteController construct
VirtualService
resource from VirtualServiceBase
and HTTPRouteBinding
. You can see created resource as follows.
$ kubectl get virtualservices.networking.istio.io virtualservicebase-sample -o yaml
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: virtualservicebase-sample
namespace: default
spec:
gateways:
- gateway
hosts:
- '*'
http:
- match:
- headers:
key:
exact: mysubset-1
route:
- destination:
host: myhost
subset: mysubset-1
- match:
- headers:
key:
exact: mysubset-2
route:
- destination:
host: myhost
subset: mysubset-2
Requirement
Install
- Deploy Istio to your kubernetes cluster. See Setup more details.
- Deploy VirtualServiceRouteController and CRDs to your kubernetes cluster.
TBD