All Products
Search
Document Center

Alibaba Cloud Service Mesh:Use ASM SDK to manage Istio resources in code

Last Updated:Sep 12, 2023

Custom resources are extensions of the Kubernetes API. Istio supports custom resources such as virtual services and Istio gateways in addition to Kubernetes-native resources. After you integrate the Service Mesh (ASM) SDK for a programming language, you can manage Istio custom resources in your code. This topic describes how to use ASM SDK to manage Istio resources in code.

Prerequisites

Use YAML files to create a virtual service and an Istio gateway

  1. Create a virtualService.yaml file that contains the following code:

    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
  2. Create a gateway.yaml file that contains the following code:

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

Manage Istio resources

After the virtual service and Istio gateway are created, you can integrate the ASM SDK for a programming language. Then, you can manage Istio resources in your code.

Programming language

References

Java

Use the SDK for Java to manage Istio resources

Go

Use the SDK for Go to manage Istio resources