To port the DJ App to App Mesh, you will need create a mesh as well as the various mesh components. You’ll also apply labels to the prod
namespace to affiliate your new mesh with it, and to enable automatic sidecar injection for pods within it.
Kubernetes application objects that run within App Mesh must be defined as Virtual Nodes
. This provides App Mesh an abstraction to objects such as Kubernetes Deployments and Services, and provides endpoints for communication and routing configuration.
App Mesh also provides the Virtual Service
construct which allows you to specify a logical service path for application traffic. In this example, they send traffic to Virtual Routers
, which then route traffic to the Virtual Nodes
.
In the image below you see DJ App running within App Mesh. Each of the services (dj
, metal-v1
, and jazz-v1
) has a virtual node defined, and each music category has a virtual service (metal
and jazz
). These virtual services send traffic to virtual routers within the mesh, which in turn specify routing rules. This drives traffic to their respective virtual nodes and ultimately to the service endpoints within Kubernetes.
You’ll find the YAML which specify these resources in the application repo’s 2_meshed_application
directory.
Looking at the YAML, you can see we’ve added the required labels to the prod
namespace and specified our mesh named dj-app
.
Included are the specifications for the App Mesh resources shown in the image above. For example, here is the dj
service’s VirtualNode
specification.
Note that it uses a podSelector
to identify which Pods
are members of this virtual node, as well as a pointer to the dj Service
.
There are also VirtualService
and VirtualRouter
specifications for each of the music categories, establishing traffic routing to their respective endpoints. This is accomplished by adding Route
s which point to the jazz-v1
and metal-v1
virtual nodes.
Shown here is the jazz virtual service and virtual router.
With the basic constructs understood, it’s time to create the mesh and its resources.