Deploy a Microservice into Istio service mesh

Deploy a Microservice into Istio service mesh

Reading Time: 3 minutes Service mesh is a dedicated infrastructure layer for handling service to service communication. Basically, it's a way to control how different micro services deployed on kubernetes will manage secure communication and traffic between them with lot's of cross-cutting concerns like logging, security, etc.

Before going to deploy the service into istio let’s first understand what is service mesh.

The service mesh is a dedicated infrastructure layer for handling service to service communication.

Basically, it’s a way to control how different micro services deployed on Kubernetes will manage secure communication and traffic between them with lots of cross-cutting concerns like logging, security, etc.

Istio service mesh comes with lot’s of feature like –

  • circuit-breaking
  • load balancing
  • service discovery
  • number of retries

we will not talk about the feature here, Let’s jump over to how we can deploy here so we categories the deployment process in 3 phases.

  • Download and install Istio on cluster
  • Deploy the micro-service
  • Setup the Gateway

Download and install Istio on cluster

For downloading the latest version we can refer to the release page. Just download the tar.gz file and unzip it. In the directory, we will find istioctl client which we can use

  • To customise the configuration of service mesh istio
  • Retrieve the information about proxy configuration ..

Now set the istioctl client to your machine path and for installation we need to choose the configuration profile. There are a set of configuration profiles, we are going to use a demo profile which enables the components according to default settings.

use the following command for installing the demo configuration profile.

istioctl install --set profile=demo

As we know, istio automatically injects Envoy sidecar proxies using mutating webhook admission controllers when we deploy services in a particular namespace. To enable this feature we need to enable the istio-injection in a particular namespace where we will deploy the application.

kubectl label namespace default istio-injection=enabled

This image has an empty alt attribute; its file name is image.png

Deploy the micro-service

Now let’s deploy the sample application by applying the following yaml file.

apiVersion: v1
kind: Service
metadata:
  name: sample
  namespace: default
  labels:
    app: sample
spec:
  selector:
    app: sample
  ports:
    - name: http
      port: 8081
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sample
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sample
      version: 'v1'
  template:
    metadata:
      labels:
        app: sample
        version: 'v1'
    spec:
      initContainers:
        - name: init-ds
          image: busybox:latest
          command:
            - '/bin/sh'
            - '-c'
            - |
              while true
              do
                if [ $? -eq 0 ]; then
                  echo "DB is UP"
                  break
                fi
                echo "DB is not yet reachable;sleep for 10s before retry"
                sleep 10
              done
      containers:
        - name: sample-app
          image: lokesh/bundle123:latest
          imagePullPolicy: Always
          env:
            - name: SPRING_PROFILES_ACTIVE
              value: prod
            - name: SPRING_SLEUTH_PROPAGATION_KEYS
              value: 'x-request-id,x-ot-span-context'
            - name: JAVA_OPTS
              value: ' -Xmx256m -Xms256m'
          resources:
            requests:
              memory: '256Mi'
              cpu: '50m'
            limits:
              memory: '512Mi'
              cpu: '1'
          ports:
            - name: http
              containerPort: 8081
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: sample
spec:
  hosts:
    - "*"
  gateways:
    - sample-gateway
  http:
    - match:
        - uri:
            exact: /getStudents
        - uri:
            exact: /accounts/create
        - uri:
            exact: /istio/auth
        - uri:
            prefix: /getTeacher
      route:
        - destination:
            host: sample
            port:
              number: 8081

devops microservices scala tech blogs deploy microservice istio service mesh

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

The Service Mesh in the Microservices World - DZone Microservices

In this article, take a look at the service mesh in the microservices world. The software industry has come a long journey and throughout this journey, Software Architecture has evolved a lot. Starting with 1-tier (Single-node), 2-tier (Client/ Server), 3-tier, and Distributed are some of the Software Architectural patterns we saw in this journey.

From Service Mess to Service Mesh

For teams to monitor, support, and to maintain these services is becoming a challenge so most enterprises have invested in some kind of microservices management tool.

Explaining Microservices and Service Mesh with Istio

Learn more about the benefits and components of service mesh when used with microservices, and take a deep dive into Istio. Application builds when broken down into multiple smaller service components, are known as microservices. When compared to the traditional Monolithic way, a Microservice Architecture treats each microservice as a standalone entity/module

Explaining Microservices and Service Mesh with Istio

Learn more about the benefits and components of service mesh when used with microservices, and take a deep dive into Istio. Application builds when broken down into multiple smaller service components, are known as microservices. When compared to the traditional Monolithic way, a Microservice Architecture treats each microservice as a standalone entity/module

Explaining Microservices and Service Mesh with Istio

Learn more about the benefits and components of service mesh when used with microservices, and take a deep dive into Istio.