Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

🌌 Kubernetes Rolling Update + Database Parallel Change

Notifications You must be signed in to change notification settings

clnnn/expand-contract-db-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expand-Contract Pattern applied in Rolling Upgrade Deployment

Technologies used

  • Java 11
  • Maven
  • Quarkus framework
  • Docker
  • Kubernetes
  • Jib
  • HTML/CSS/JS
  • Weave Scope visualisation & monitoring tool
  • PostgreSQL
  • Flyway

Techniques used

Architecture

Application Architecture

Packaging and running the example in a kubernetes cluster

  1. Start minikube with the following addons:
minikube start --addons registry, ingress
  1. Forward the image registry port:
kubectl port-forward --namespace kube-system registry-<id> 5000:5000
  1. Run the deployment script:
./minikube-deploy.sh
  1. Get ngnix IP from ADDRESS column using:
kubectl get ingress -n custom
  1. Map customer.domain to the IP provided by step above to etc/hosts

  2. Access the application on http://customer.domain

Expand/Contract demo explanation

Beside master branch you have 3 additional branches that represent 3 backward compatible database versions.

The problem:

You need to split name column into two separate columns, first name and last name and to maintain backward compatibility with the previous version.

Solution:

Migration version Branch State What happens to the database?
V1.0 demo/v1_starting_state Starting Create a customer table that contains an ID and a name
V2.0 demo/v2_expand_state Expand Append first_name and last_name column. Bidirectional synchronization using triggers between name and (first_name, last_name)
V3.0 demo/v3_contract_state Contract After all clients migrated to V2.0, in this state you can remove the old column name and also the synchronization triggers.