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
An ASM instance is created. For more information, see Create an ASM instance.
A Container Service for Kubernetes (ACK) cluster is added to your ASM instance. For more information, see Add a cluster to an ASM instance.
A Bookinfo application is deployed in the ACK cluster that is added to your ASM instance. For more information, see Deploy an application in an ASM instance.
An ingress gateway service is deployed in the ACK cluster that is added to your ASM instance. For more information, see Create an ingress gateway service.
Use YAML files to create a virtual service and an Istio gateway
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
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 | |
Go |