Created
August 12, 2021 19:58
-
-
Save ilya-korotya/6ecdc19a9ff92c1e0478a00968b07762 to your computer and use it in GitHub Desktop.
k8s configuration for local dynamodb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: dynamodb | |
labels: | |
app: dynamodb | |
spec: | |
selector: | |
matchLabels: | |
app: dynamodb | |
template: | |
metadata: | |
labels: | |
app: dynamodb | |
spec: | |
containers: | |
- name: dynamodb | |
image: amazon/dynamodb-local | |
imagePullPolicy: IfNotPresent | |
ports: | |
- containerPort: 8000 | |
readinessProbe: | |
tcpSocket: | |
port: 8000 | |
initialDelaySeconds: 10 | |
periodSeconds: 10 | |
livenessProbe: | |
tcpSocket: | |
port: 8000 | |
initialDelaySeconds: 40 | |
periodSeconds: 20 | |
volumeMounts: | |
- mountPath: /home/dynamodblocal/data | |
name: data | |
- name: dynamodb-interface | |
image: amazon/aws-cli | |
env: | |
- name: AWS_ACCESS_KEY_ID | |
value: "DUMMYIDEXAMPLE" | |
- name: AWS_SECRET_ACCESS_KEY | |
value: "DUMMYEXAMPLEKEY" | |
- name: AWS_REGION | |
value: "us-east-1" | |
command: [ "/bin/bash", "-c", "sleep 360d" ] | |
volumes: | |
- name: data | |
hostPath: | |
path: /tmp/docker/dynamodb | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: dynamodb-local | |
labels: | |
app: dynamodb-local | |
spec: | |
type: ClusterIP | |
ports: | |
- name: dynamodb-local | |
port: 8000 | |
selector: | |
app: dynamodb | |
--- | |
# Migration job | |
# I used JOB instead of initContainer. | |
# Because JOB lets you run migrations once while cluster running. | |
# initContainer will run migration script each time when pod died and up again. | |
apiVersion: batch/v1 | |
kind: Job | |
metadata: | |
name: dynamodb-migration | |
spec: | |
template: | |
spec: | |
containers: | |
- name: dynamodb-wait-database | |
image: amazon/aws-cli | |
command: ["/bin/bash", "-c", "sleep 60"] | |
- name: dynamodb-migration | |
image: amazon/aws-cli | |
env: | |
- name: AWS_ACCESS_KEY_ID | |
value: "DUMMYIDEXAMPLE" | |
- name: AWS_SECRET_ACCESS_KEY | |
value: "DUMMYEXAMPLEKEY" | |
- name: AWS_REGION | |
value: "us-east-1" | |
command: | |
- /bin/bash | |
- -c | |
- "aws dynamodb create-table --table-name id-token-store \ | |
--key-schema AttributeName=Token,KeyType=HASH \ | |
--attribute-definitions AttributeName=Token,AttributeType=S \ | |
--provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 \ | |
--endpoint-url http://dynamodb-local:8000 && \ | |
aws dynamodb update-time-to-live --table-name id-token-store \ | |
--time-to-live-specification Enabled=true,AttributeName=Claims.Expiry \ | |
--endpoint-url http://dynamodb-local:8000" | |
restartPolicy: OnFailure | |
backoffLimit: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment