Skip to content

Commit 954e32a

Browse files
committed
demo updates
1 parent 751bd80 commit 954e32a

File tree

6 files changed

+131
-1
lines changed

6 files changed

+131
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Redis Connect Samples with Hashicorp Vault
2+
3+
## Notes
4+
1. The injected credentials file must be named as follows: `redisconnect_credentials_jobmanager.properties` and `redisconnect_credentials_[redis|postgresql]_<job_name>.properties`.
5+
6+
2. The following role (or similar) is required in Vault for Redis Connect to connect with the source database:
7+
```
8+
vault write database/roles/redis-connect \
9+
db_name=aws-postgres \
10+
creation_statements="CREATE ROLE \"{{name}}\" WITH REPLICATION LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; \
11+
GRANT SELECT ON ALL TABLES IN SCHEMA public TO \"{{name}}\"; \
12+
ALTER USER \"{{name}}\" WITH SUPERUSER;" \
13+
default_ttl="24h" \
14+
max_ttl="24h"
15+
```
16+
17+
## Diagram
18+
19+
!["Redis Connect in K8s with Vault"](redis_connect_k8s_oracle.png)
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: redis-connect # deployment name
5+
labels:
6+
app: redis-connect # deployment label
7+
8+
spec:
9+
replicas: 2 # replicas for HA
10+
selector:
11+
matchLabels:
12+
app: redis-connect # which pods is the deployment managing, as defined by the pod template
13+
template: # pod template
14+
metadata:
15+
labels:
16+
app: redis-connect
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_oracle-job"
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+
source.username={{ .Data.username }}
26+
source.password={{ .Data.password }}
27+
target.username=asdf
28+
target.password=asdf
29+
jobmanager.username=asdf
30+
jobmanager.password=asdf
31+
{{- end }}
32+
spec:
33+
serviceAccountName: redis-connect
34+
affinity:
35+
podAntiAffinity:
36+
requiredDuringSchedulingIgnoredDuringExecution:
37+
- labelSelector:
38+
matchExpressions:
39+
- key: app
40+
operator: In
41+
values:
42+
- redis-connect # must match Deployment:metadata:labels:app
43+
topologyKey: "kubernetes.io/hostname"
44+
containers:
45+
- name: redis-connect # Container name
46+
image: redislabs/redis-connect:latest
47+
# The following `command` can be leveraged for troubleshooting
48+
# command: ["/bin/bash", "-c", "echo $REDISCONNECT_JAVA_OPTIONS; /opt/redislabs/redis-connect/bin/redisconnect.sh start; while true; do sleep 30; done;"]
49+
command: ["/opt/redislabs/redis-connect/bin/redisconnect.sh", "start"]
50+
imagePullPolicy: Always # IfNotPresent # Always pull image
51+
resources:
52+
limits:
53+
cpu: "4000m"
54+
memory: "2048Mi"
55+
requests:
56+
cpu: "500m"
57+
memory: "256Mi"
58+
ports:
59+
- containerPort: 8282 # exposed container port to the REST API
60+
protocol: TCP
61+
env:
62+
- name: REDISCONNECT_LOGBACK_CONFIG
63+
value: "/opt/redislabs/redis-connect/config/logback.xml"
64+
# value: "/opt/redislabs/redis-connect/config/fromconfigmap/logback.xml"
65+
- name: REDISCONNECT_JOB_MANAGER_CONFIG_PATH
66+
value: "/opt/redislabs/redis-connect/config/fromconfigmap"
67+
- name: REDISCONNECT_JAVA_OPTIONS
68+
value: "-Xms1g -Xmx2g"
69+
- name: REDISCONNECT_EXTLIB_DIR
70+
value: "/opt/redislabs/redis-connect/extlib"
71+
volumeMounts:
72+
- name: config-volume
73+
mountPath: /opt/redislabs/redis-connect/config/fromconfigmap # must match env:REDISCONNECT_CONFIG in this file.
74+
- name: custom-stage-volume
75+
mountPath: /opt/redislabs/redis-connect/extlib # Redis Connect expects the custom stage jars here
76+
volumes:
77+
- name: config-volume
78+
configMap:
79+
name: redis-connect-config
80+
items:
81+
- key: jobmanager.properties
82+
value: jobmanager.properties
83+
# #### uncomment the following six lines if you have custom
84+
# transformation implementation and replace the jar with
85+
# your own.
86+
# ####
87+
- name: custom-stage-volume
88+
configMap:
89+
name: redis-connect-custom-stage
90+
items: # define as many custom stages as you have here
91+
- key: redis-connect-custom-stage-demo-1.0-SNAPSHOT.jar
92+
path: redis-connect-custom-stage-demo-1.0-SNAPSHOT.jar
93+
# - name: tmpfsdir
94+
# emptyDir: # node-ephemeral volume
95+
# medium: Memory
96+
# - name: redis-connect-pv
97+
# persistentVolumeClaim:
98+
# claimName: redis-connect-pvc
99+
---
100+
# RedisConnect service with name 'redis-connect-api-service'
101+
apiVersion: v1
102+
kind: Service
103+
metadata:
104+
name: redis-connect-api-service # name should not be 'redis-connect'
105+
spec:
106+
type: ClusterIP
107+
ports:
108+
- port: 80
109+
targetPort: 8282
110+
selector:
111+
app: redis-connect-api-service
456 KB
Loading

examples/postgres/k8s-docs/vault/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ vault write database/roles/redis-connect \
1616

1717
## Diagram
1818

19-
!["Redis Connect in K8s with Vault"](redis-connect-k8s.png)
19+
!["Redis Connect in K8s with Vault"](redis_connect_k8s_postgres.png)
-510 KB
Binary file not shown.
458 KB
Loading

0 commit comments

Comments
 (0)