Installing AWS DynamoDB Local on Kubernetes Cluster

A guide to setting up DynamoDB locally for development and testing

Featured image

Image Reference



Overview

Following our previous exploration of AWS DynamoDB, this guide focuses on installing DynamoDB locally in a Kubernetes cluster.

The source Docker image can be found at: dynamodb-local

For a comprehensive understanding of DynamoDB concepts, please refer to our previous post: What is AWS DynamoDB?


Installation Methods

DynamoDB can be installed in two ways:

  1. In-Memory (Stateless)
  2. Data Storage (Stateful)

Comparison of Installation Methods

Feature In-Memory Method Data Storage Method
Data Persistence Data is lost when DynamoDB Local stops Data persists on disk
Configuration No -dbPath parameter needed Requires -dbPath parameter
Performance Faster due to no disk I/O Slightly slower due to disk writes
Use Case Temporary testing Persistent data testing


In-Memory Installation

Deployment configuration:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: stateless-dynamodb
  name: stateless-dynamodb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: stateless-dynamodb
  template:
    metadata:
      labels:
        app: stateless-dynamodb
    spec:
      containers:
      - image: amazon/dynamodb-local:2.5.3
        name: dynamodb-local
        ports:
        - containerPort: 8000
        volumeMounts:
        - name: dynamodb-data
          mountPath: /home/dynamodblocal/data
      volumes:
      - name: dynamodb-data
        persistentVolumeClaim:
          claimName: stateless-dynamodb-pvc

Pod logs for In-Memory setup:

Initializing DynamoDB Local with the following configuration:
Port: 8000
InMemory: true
Version: 2.5.3
DbPath: null
SharedDb: false
shouldDelayTransientStatuses: false
CorsParams: null


Data Storage Installation

Deployment configuration:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: stateful-dynamodb
  name: stateful-dynamodb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: stateful-dynamodb
  template:
    metadata:
      labels:
        app: stateful-dynamodb
    spec:
      containers:
      - image: amazon/dynamodb-local:2.5.3
        name: dynamodb-local
        command: ["java", "-jar", "DynamoDBLocal.jar", "-sharedDb", "-dbPath", "/home/dynamodblocal/data"]
        ports:
        - containerPort: 8000
        volumeMounts:
        - name: dynamodb-data
          mountPath: /home/dynamodblocal/data
      volumes:
      - name: dynamodb-data
        persistentVolumeClaim:
          claimName: stateful-dynamodb-pvc

Pod logs for Data Storage setup:

Initializing DynamoDB Local with the following configuration:
Port: 8000
InMemory: false
Version: 2.5.3
DbPath: /home/dynamodblocal/data
SharedDb: true
shouldDelayTransientStatuses: false
CorsParams: null



References