OpenShift Service Mesh essentials — Part IV — Features: Routing

OpenShift Service Mesh essentials — Part IV — Features: Routing

See how using advanced routing you can modify the behaviour of your application without including API gateways or writing code in your app. In this series of articles, we will dig into the OpenShift Service Mesh world. ... OpenShift Service Mesh essentials — Part IV — Features: Routing ...

In this article, we are going to start configuring the Service Mesh to better understand one of its main benefits that we talked about at that moment: the advanced routing. You can use this capability to modify the behavior of your application without having to include external pieces as an API gateway or additional code in your microservices.

I will touch on some of the Control Plane and Data Plane concepts that we already reviewed, so if you didn't read the previous articles I encourage you to do it:

Deploying the example application

I’m going to use the same classic example application that you will find in the Istio documentation: Bookinfo

This application is composed of four main pieces: The product page (landing page), the Reviews which have three different versions (stars changes, from none on v1 to red stars on v3), Details, and Rating.

Image for post

You can double-check the deployment YAML here but those ones do not include the sidecar injection annotations that we require in OpenShift. In order to do it easier, I will create a single object that defines the whole application, that’s useful because you can only create one object at a time using the “+” button on the Web Console. We have two options here to include multiple objects in a single one, use kind: List or kind: Template.

The only one that will work in the “+” button will be Template so that’s the one that I will use, but remember, that when you create a template using this technique, you will need to “provision” that template as a second step.

First, take a look at the YAML object (you will see how I included some additional annotations and labels to make the app look prettier on the Developer Console) and then check the steps below.

kind: Template
apiVersion: template.openshift.io/v1
metadata:
  name: bookinfo-app
objects:
  ##############################
  ## Details service
  ##############################
- apiVersion: v1
  kind: Service
  metadata:
    name: details
    labels:
      app: details
      service: details
  spec:
    ports:
    - port: 9080
      name: http
    selector:
      app: details

- apiVersion: v1
  kind: ServiceAccount
  metadata:
    name: bookinfo-details
    labels:
      account: details
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: details-v1
    labels:
      app: details
      version: v1
      app.openshift.io/runtime: ruby
      app.kubernetes.io/part-of: Details
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: details
        version: v1
    template:
      metadata:
        annotations:
          sidecar.istio.io/inject: "true"
        labels:
          app: details
          version: v1
      spec:
        serviceAccountName: bookinfo-details
        containers:
        - name: details
          image: maistra/examples-bookinfo-details-v1:1.1.0
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9080
##############################
  ## Ratings service
  ##############################
- apiVersion: v1
  kind: Service
  metadata:
    name: ratings
    labels:
      app: ratings
      service: ratings
  spec:
    ports:
    - port: 9080
      name: http
    selector:
      app: ratings

- apiVersion: v1
  kind: ServiceAccount
  metadata:
    name: bookinfo-ratings
    labels:
      account: ratings

- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: ratings-v1
    labels:
      app: ratings
      version: v1
      app.openshift.io/runtime: nodejs
      app.kubernetes.io/part-of: Ratings
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: ratings
        version: v1
    template:
      metadata:
        annotations:
          sidecar.istio.io/inject: "true"
        labels:
          app: ratings
          version: v1
      spec:
        serviceAccountName: bookinfo-ratings
        containers:
        - name: ratings
          image: maistra/examples-bookinfo-ratings-v1:1.1.0
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9080
##############################
  ## Reviews service
  ##############################
- apiVersion: v1
  kind: Service
  metadata:
    name: reviews
    labels:
      app: reviews
      service: reviews
  spec:
    ports:
    - port: 9080
      name: http
    selector:
      app: reviews

- apiVersion: v1
  kind: ServiceAccount
  metadata:
    name: bookinfo-reviews
    labels:
      account: reviews

- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: reviews-v1
    labels:
      app: reviews
      version: v1
      app.openshift.io/runtime: java
      app.kubernetes.io/part-of: Reviews
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: reviews
        version: v1
    template:
      metadata:
        annotations:
          sidecar.istio.io/inject: "true"
        labels:
          app: reviews
          version: v1
      spec:
        serviceAccountName: bookinfo-reviews
        containers:
        - name: reviews
          image: maistra/examples-bookinfo-reviews-v1:1.1.0
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9080

- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: reviews-v2
    labels:
      app: reviews
      version: v2
      app.openshift.io/runtime: java
      app.kubernetes.io/part-of: Reviews
    annotations:
      app.openshift.io/connects-to: ratings-v1
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: reviews
        version: v2
    template:
      metadata:
        annotations:
          sidecar.istio.io/inject: "true"
        labels:
          app: reviews
          version: v2
      spec:
        serviceAccountName: bookinfo-reviews
        containers:
        - name: reviews
          image: maistra/examples-bookinfo-reviews-v2:1.1.0
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9080

- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: reviews-v3
    labels:
      app: reviews
      version: v3
      app.openshift.io/runtime: java
      app.kubernetes.io/part-of: Reviews
    annotations:
      app.openshift.io/connects-to: ratings-v1
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: reviews
        version: v3
    template:
      metadata:
        annotations:
          sidecar.istio.io/inject: "true"
        labels:
          app: reviews
          version: v3
      spec:
        serviceAccountName: bookinfo-reviews
        containers:
        - name: reviews
          image: maistra/examples-bookinfo-reviews-v3:1.1.0
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9080
##############################
  ## Productpage services
  ##############################
- apiVersion: v1
  kind: Service
  metadata:
    name: productpage
    labels:
      app: productpage
      service: productpage
  spec:
    ports:
    - port: 9080
      name: http
    selector:
      app: productpage

- apiVersion: v1
  kind: ServiceAccount
  metadata:
    name: bookinfo-productpage
    labels:
      account: productpage

- apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: productpage-v1
    labels:
      app: productpage
      version: v1
      app.openshift.io/runtime: python
      app.kubernetes.io/part-of: ProductPage
    annotations:
      app.openshift.io/connects-to: reviews-v1,reviews-v2,reviews-v3,details-v1 
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: productpage
        version: v1
    template:
      metadata:
        annotations:
          sidecar.istio.io/inject: "true"
        labels:
          app: productpage
          version: v1
      spec:
        serviceAccountName: bookinfo-productpage
        containers:
        - name: productpage
          image: maistra/examples-bookinfo-productpage-v1:1.1.0
          imagePullPolicy: IfNotPresent
          ports:
          - containerPort: 9080

kubernetes openshift routing service-mesh istio

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

50+ Useful Kubernetes Tools for 2020 - Part 2

Our original Kubernetes tool list was so popular that we've curated another great list of tools to help you improve your functionality with the platform.

OpenShift Service Mesh Essentials  — The Why and What of it

In this series of articles, we will dig into the OpenShift Service Mesh world. In this post we will go through some introductory questions like “Why someone would need a Service Mesh?“, “Do I really need it?”, “How is the OpenShift Service Mesh architecture?”.

Open Service Mesh — Microsoft’s SMI based Open Source Service Mesh Implementation

Microsoft’s Open Service Mesh is an SMI-compliant, lightweight service mesh being run as an open source project. Backed by service-mesh…

OpenShift Service Mesh essentials — Part II — Control Plane

In this second article, we will go through the preparation and deployment of the OpenShift Service Mesh Control Plane.

A Kubernetes Service Mesh Tool Comparison for 2020

Just as tech is revised and upgraded, so too should a tool comparison be. Service meshes act as the substrate to connect microservices, find the one for you.