Access/update virtual service and destination rule using Kubernetes REST API

Hi,
Are the Istio objects exposed through Kubernetes API server and accessible through REST client? If yes, where can I find the API reference or examples?

For example, I’m accessing deployment and pod information through
curl --request GET --url http://localhost:8080/apis/apps/v1/namespaces/kube-system/deployments
curl --request GET --url http://localhost:8080/api/v1/namespaces/default/pods

I would like to know whether similar API access is available for Istio virtual services and destination rules.
This access is needed for me to update the virtual service and destination rules in a dynamic way from the application running within the cluster.

Thanks,
Raj

1 Like

I was able to access and update the virtual services as given below:

curl --request GET --url http://localhost:8080/apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices
curl --request GET --url http://localhost:8080/apis/networking.istio.io/v1alpha3/namespaces/default/destinationrules

curl --request PATCH -H “Content-Type: application/json-patch+json” --data “[{“op”: “add”, “path”: “/spec/http/-”, “value”: {“name”: “v4”, “match”: [{ “label”: { “exact”: “v4” } }], “route”: [{ “destination”: { “host”: “test-service.default.svc.cluster.local”, “subset”: “v4” } }]}}]” --url http://localhost:8080/apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/test-vs

During the patch, the application can decide the header to match dynamically (based on the application traffic management requirement) and update the destination rules and virtual services.

Hope this is useful, if someone is looking for similar traffic management strategy.

1 Like