Testing traffic routing
In the real world, canary deployments are regularly used to release a feature to a subset of users. In this scenario, we are artificially routing 75% of traffic to the new version of the checkout service. Completing the checkout procedure multiple times with different objects in the cart should present the users with the 2 version of the application.
First lets use Kubernetes exec to check that the Lattice service URL works from the UI pod. We'll obtain this from an annotation on the HTTPRoute resource:
{"status":"ok","info":{},"error":{},"details":{}}Now we have to point the UI service to the VPC Lattice service endpoint by patching the ConfigMap for the UI component:
- Kustomize Patch
- ConfigMap/ui
- Diff
apiVersion: v1
kind: ConfigMap
metadata:
name: ui
namespace: ui
data:
ENDPOINTS_CHECKOUT: "${CHECKOUT_ROUTE_DNS}"
apiVersion: v1
data:
ENDPOINTS_CHECKOUT: ${CHECKOUT_ROUTE_DNS}
RETAIL_UI_ENDPOINTS_CARTS: http://carts.carts.svc:80
RETAIL_UI_ENDPOINTS_CATALOG: http://catalog.catalog.svc:80
RETAIL_UI_ENDPOINTS_CHECKOUT: http://checkout.checkout.svc:80
RETAIL_UI_ENDPOINTS_ORDERS: http://orders.orders.svc:80
kind: ConfigMap
metadata:
name: ui
namespace: ui
apiVersion: v1
data:
+ ENDPOINTS_CHECKOUT: ${CHECKOUT_ROUTE_DNS}
RETAIL_UI_ENDPOINTS_CARTS: http://carts.carts.svc:80
RETAIL_UI_ENDPOINTS_CATALOG: http://catalog.catalog.svc:80
RETAIL_UI_ENDPOINTS_CHECKOUT: http://checkout.checkout.svc:80
RETAIL_UI_ENDPOINTS_ORDERS: http://orders.orders.svc:80
Make this configuration change:
Now restart the UI component pods:
Lets try to access our application using the browser. A LoadBalancer type service named ui-nlb is provisioned in the ui namespace from which the application's UI can be accessed.
k8s-ui-uinlb-647e781087-6717c5049aa96bd9.elb.us-west-2.amazonaws.com
Access this in your browser and try to checkout multiple times (with different items in the cart):
You'll notice that the checkout now uses the "Lattice checkout" pods about 75% of the time: