All Products
Search
Document Center

Alibaba Cloud Service Mesh:Manage Istio resources programmatically with ASM SDK

Last Updated:Mar 11, 2026

Istio extends the Kubernetes API with custom resources such as VirtualService and Gateway. The Alibaba Cloud Service Mesh (ASM) SDK lets you create, query, update, and delete these resources directly in Java or Go code.

Prerequisites

Before you begin, make sure that you have:

Define a VirtualService and a Gateway

Before you integrate the SDK, define the Istio resources that route external traffic to the Bookinfo application.

VirtualService

Create a file named virtualService.yaml:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: bookinfo
spec:
  hosts:
  - "*"
  gateways:
  - bookinfo-gateway
  http:
  - match:
    - uri:
        exact: /productpage
    - uri:
        prefix: /static
    - uri:
        exact: /login
    - uri:
        exact: /logout
    - uri:
        prefix: /api/v1/products
    route:
    - destination:
        host: productpage
        port:
          number: 9080

This VirtualService routes incoming HTTP requests to the productpage service on port 9080. It matches five URI patterns -- the product page itself, static assets, login and logout endpoints, and the products API.

Gateway

Create a file named gateway.yaml:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: bookinfo-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"

This Gateway binds to the ingress gateway on port 80 and accepts HTTP traffic from all hosts. The VirtualService references this Gateway by name (bookinfo-gateway).

Integrate the ASM SDK

With the VirtualService and Gateway defined, use the ASM SDK to manage these resources in code.

Language

Guide

Java

Use the SDK for Java to manage Istio resources

Go

Use the SDK for Go to manage Istio resources