Skip to content

Commit a533b45

Browse files
committed
Adding Vault examples
1 parent 20b3e88 commit a533b45

File tree

4 files changed

+260
-0
lines changed

4 files changed

+260
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Redis Connect Samples with Hashicorp Vault
2+
3+
## Notes
4+
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: redis-connect-postgres-stage # deployment name
5+
labels:
6+
app: redis-connect-postgres-stage # deployment label
7+
spec:
8+
backoffLimit: 10 # try this many times before declaring failure
9+
template: # pod template
10+
metadata:
11+
labels:
12+
app: redis-connect-postgres-stage
13+
annotations:
14+
vault.hashicorp.com/agent-inject: "true"
15+
vault.hashicorp.com/agent-pre-populate-only: "true"
16+
vault.hashicorp.com/role: "redis-connect"
17+
vault.hashicorp.com/secret-volume-path: "/vault/secrets"
18+
vault.hashicorp.com/agent-inject-file-redis-connect: "redisconnect_credentials_RedisConnect-postgres"
19+
vault.hashicorp.com/agent-inject-secret-redis-connect: 'database/creds/redis-connect'
20+
vault.hashicorp.com/agent-inject-template-redis-connect: |
21+
{{ with secret "database/creds/redis-connect" -}}
22+
sourceUsername={{ .Data.username }}
23+
sourcePassword={{ .Data.password }}
24+
targetUsername=asdf
25+
targetPassword=asdf
26+
jobConfigUsername=asdf
27+
jobConfigPassword=asdf
28+
metricsUsername=asdf
29+
metricsPassword=asdf
30+
{{- end }}
31+
spec:
32+
serviceAccountName: redis-connect
33+
restartPolicy: OnFailure
34+
containers:
35+
- name: redis-connect-postgres # Container name
36+
image: redislabs/redis-connect-postgres:latest #repo/image:tag
37+
# The following `command` can be leveraged for troubleshooting
38+
# command: ["/bin/bash", "-c", "/opt/redislabs/redis-connect-postgres/bin/redisconnect.sh stage; while true; do sleep 30; done;"]
39+
command: ["/opt/redislabs/redis-connect-postgres/bin/redisconnect.sh", "stage"]
40+
imagePullPolicy: Always # IfNotPresent # Always pull image
41+
resources:
42+
limits:
43+
cpu: "1000m"
44+
memory: "256Mi"
45+
requests:
46+
cpu: "1000m"
47+
memory: "256Mi"
48+
ports:
49+
- containerPort: 8282 # exposed container port to the REST API
50+
protocol: TCP
51+
env:
52+
- name: REDISCONNECT_LOGBACK_CONFIG
53+
value: "/opt/redislabs/redis-connect-postgres/config/logback.xml"
54+
- name: REDISCONNECT_CONFIG
55+
value: "/opt/redislabs/redis-connect-postgres/config/fromconfigmap"
56+
- name: REDISCONNECT_REST_API_ENABLED
57+
value: "false"
58+
- name: REDISCONNECT_REST_API_PORT
59+
value: "8282"
60+
- name: REDISCONNECT_JAVA_OPTIONS
61+
value: "-Xms256m -Xmx1g -Dredis.connect.credentials.rotation.eventlistener.enabled=true \
62+
-Dredis.connect.credentials.filename=/vault/secrets/redisconnect_credentials_RedisConnect-postgres \
63+
-DsourceUsername=sourceUsername -DsourcePassword=sourcePassword \
64+
-DjobConfigUsername=jobConfigUsername -DjobConfigPassword=jobConfigPassword \
65+
-DtargetUsername=targetUsername -DtargetPassword=targetPassword \
66+
-DmetricsUsername=metricsUsername -DmetricsPassword=metricsPassword"
67+
volumeMounts:
68+
- name: config-volume
69+
mountPath: /opt/redislabs/redis-connect-postgres/config/fromconfigmap # must match env:REDISCONNECT_CONFIG
70+
# - name: custom-stage-volume
71+
# mountPath: /opt/redislabs/redis-connect-postgres/extlib # Redis Connect expects the custom stage jars here
72+
volumes:
73+
- name: config-volume
74+
configMap:
75+
name: redis-connect-postgres-config
76+
items:
77+
- key: JobConfig.yml
78+
path: JobConfig.yml
79+
- key: JobManager.yml
80+
path: JobManager.yml
81+
- key: Setup.yml
82+
path: Setup.yml
83+
- key: env.yml
84+
path: env.yml
85+
- key: mapper1.yml
86+
path: mappers/mapper1.yml
87+
# #### uncomment the following six lines if you have custom
88+
# transformation implementation and replace the jar with
89+
# your own.
90+
# ####
91+
#- name: custom-stage-volume
92+
#configMap:
93+
#name: redis-connect-postgres-config
94+
#items: # define as many custom stages as you have here
95+
#- key: redis-connect-custom-stage-demo-1.0-SNAPSHOT.jar
96+
#path: redis-connect-custom-stage-demo-1.0-SNAPSHOT.jar
97+
---
98+
# RedisConnect service with name 'redis-connect-service'
99+
# apiVersion: v1
100+
# kind: Service
101+
# metadata:
102+
# name: redis-connect-service # name should not be 'redis-connect'
103+
# spec:
104+
# type: ClusterIP
105+
# ports:
106+
# - port: 80
107+
# targetPort: 8282
108+
# selector:
109+
# app: redis-connect
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: redis-connect-postgres # deployment name
5+
labels:
6+
app: redis-connect-postgres # deployment label
7+
8+
spec:
9+
replicas: 1 # replicas for HA
10+
selector:
11+
matchLabels:
12+
app: redis-connect-postgres # which pods is the deployment managing, as defined by the pod template
13+
template: # pod template
14+
metadata:
15+
labels:
16+
app: redis-connect-postgres
17+
annotations:
18+
vault.hashicorp.com/agent-inject: "true"
19+
vault.hashicorp.com/role: "redis-connect"
20+
vault.hashicorp.com/secret-volume-path: "/vault/secrets"
21+
vault.hashicorp.com/agent-inject-file-redis-connect: "redisconnect_credentials_RedisConnect-postgres"
22+
vault.hashicorp.com/agent-inject-secret-redis-connect: 'database/creds/redis-connect'
23+
vault.hashicorp.com/agent-inject-template-redis-connect: |
24+
{{ with secret "database/creds/redis-connect" -}}
25+
sourceUsername={{ .Data.username }}
26+
sourcePassword={{ .Data.password }}
27+
targetUsername=asdf
28+
targetPassword=asdf
29+
jobConfigUsername=asdf
30+
jobConfigPassword=asdf
31+
metricsUsername=asdf
32+
metricsPassword=asdf
33+
{{- end }}
34+
spec:
35+
serviceAccountName: redis-connect
36+
affinity:
37+
podAntiAffinity:
38+
requiredDuringSchedulingIgnoredDuringExecution:
39+
- labelSelector:
40+
matchExpressions:
41+
- key: app
42+
operator: In
43+
values:
44+
- redis-connect-postgres # must match Deployment:metadata:labels:app
45+
topologyKey: "kubernetes.io/hostname"
46+
containers:
47+
- name: redis-connect-postgres # Container name
48+
image: redislabs/redis-connect-postgres:latest
49+
# The following `command` can be leveraged for troubleshooting
50+
command: ["/bin/bash", "-c", "echo $REDISCONNECT_JAVA_OPTIONS; /opt/redislabs/redis-connect-postgres/bin/redisconnect.sh start; while true; do sleep 30; done;"]
51+
# command: ["/opt/redislabs/redis-connect-postgres/bin/redisconnect.sh", "start"]
52+
imagePullPolicy: Always # IfNotPresent # Always pull image
53+
resources:
54+
limits:
55+
cpu: "4000m"
56+
memory: "2048Mi"
57+
requests:
58+
cpu: "500m"
59+
memory: "256Mi"
60+
ports:
61+
- containerPort: 8282 # exposed container port to the REST API
62+
protocol: TCP
63+
env:
64+
- name: REDISCONNECT_LOGBACK_CONFIG
65+
value: "/opt/redislabs/redis-connect-postgres/config/logback.xml"
66+
# value: "/opt/redislabs/redis-connect-postgres/config/fromconfigmap/logback.xml"
67+
- name: REDISCONNECT_CONFIG
68+
value: "/opt/redislabs/redis-connect-postgres/config/fromconfigmap"
69+
- name: REDISCONNECT_REST_API_ENABLED
70+
value: "false"
71+
- name: REDISCONNECT_REST_API_PORT
72+
value: "8282"
73+
- name: REDISCONNECT_JAVA_OPTIONS
74+
value: "-Xms256m -Xmx1g -Dredis.connect.credentials.rotation.eventlistener.enabled=true \
75+
-Dredis.connect.credentials.filename=/vault/secrets/redisconnect_credentials_RedisConnect-postgres \
76+
-DsourceUsername=sourceUsername -DsourcePassword=sourcePassword \
77+
-DjobConfigUsername=jobConfigUsername -DjobConfigPassword=jobConfigPassword \
78+
-DtargetUsername=targetUsername -DtargetPassword=targetPassword \
79+
-DmetricsUsername=metricsUsername -DmetricsPassword=metricsPassword"
80+
volumeMounts:
81+
- name: config-volume
82+
mountPath: /opt/redislabs/redis-connect-postgres/config/fromconfigmap # must match env:REDISCONNECT_CONFIG in this file.
83+
# - name: custom-stage-volume
84+
# mountPath: /opt/redislabs/redis-connect-postgres/extlib # Redis Connect expects the custom stage jars here
85+
volumes:
86+
- name: config-volume
87+
configMap:
88+
name: redis-connect-postgres-config
89+
items:
90+
- key: JobConfig.yml
91+
path: JobConfig.yml
92+
- key: JobManager.yml
93+
path: JobManager.yml
94+
- key: Setup.yml
95+
path: Setup.yml
96+
- key: env.yml
97+
path: env.yml
98+
- key: mapper1.yml
99+
path: mappers/mapper1.yml
100+
# #### uncomment the following six lines if you have custom
101+
# transformation implementation and replace the jar with
102+
# your own.
103+
# ####
104+
#- name: custom-stage-volume
105+
#configMap:
106+
#name: redis-connect-postgres-config
107+
#items: # define as many custom stages as you have here
108+
#- key: redis-connect-custom-stage-demo-1.0-SNAPSHOT.jar
109+
#path: redis-connect-custom-stage-demo-1.0-SNAPSHOT.jar
110+
# - name: tmpfsdir
111+
# emptyDir: # node-ephemeral volume
112+
# medium: Memory
113+
# - name: redis-connect-postgres-pv
114+
# persistentVolumeClaim:
115+
# claimName: redis-connect-postgres-pvc
116+
---
117+
# RedisConnect service with name 'redis-connect-service'
118+
# apiVersion: v1
119+
# kind: Service
120+
# metadata:
121+
# name: redis-connect-api-service # name should not be 'redis-connect'
122+
# spec:
123+
# type: ClusterIP
124+
# ports:
125+
# - port: 80
126+
# targetPort: 8282
127+
# selector:
128+
# app: redis-connect-api-service
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
connections:
2+
- id: jobConfigConnection
3+
type: Redis
4+
url: redis://<redis_jobconfig_service>:14000
5+
- id: targetConnection
6+
type: Redis
7+
url: redis://<redis_target_service>:14001
8+
- id: metricsConnection
9+
type: Redis
10+
url: redis://<redis_metrics_service>:14002
11+
- id: RDBConnection
12+
type: RDB
13+
name: RedisConnect # database pool name
14+
database: <database_name> # database name
15+
url: "jdbc:postgresql://<your_db_hostname>:5432/<database_name>"
16+
host: <your_db_hostname>
17+
port: 5432
18+
heartbeat.interval.ms: 10000
19+
heartbeat.action.query: "INSERT INTO heartbeat (id, ts) VALUES (1, NOW()) ON CONFLICT(id) DO UPDATE SET ts=EXCLUDED.ts;"

0 commit comments

Comments
 (0)