How to do it…

Go through the following steps to set up a canary deployment:

  1. Open the message-service project we've worked on in the previous recipes. Add the following Dockerfile file to the root directory of the project:
FROM openjdk:8-jdk-alpineVOLUME /tmpEXPOSE 8082ARG JAR_FILE=build/libs/message-service-1.0-SNAPSHOT.jarADD ${JAR_FILE} app.jarENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
  1. In order for Kubernetes to know whether the service is running, we need to add a liveness probe endpoint. Open the MessageController.java file and add a method to respond to GET requests at the /ping path:
package com.packtpub.microservices.ch09.message.controllers;import com.packtpub.microservices.ch09.message.MessageRepository; ...

Get Microservices Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.