Skip to content

Commit eb8e75b

Browse files
committed
initial fixups by claude
Generated-By: Claude
1 parent a43fe31 commit eb8e75b

6 files changed

Lines changed: 37 additions & 17 deletions

File tree

kubernetes/README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@
22
OpenEMR Kubernetes orchestration. Orchestration included OpenEMR, MariaDB, Redis, and phpMyAdmin.
33
- OpenEMR - 3 deployment replications of OpenEMR are created. Replications can be increased/decreased. Ports for both http and https.
44
- MariaDB - 2 statefulset replications of MariaDB (1 primary/master with 1 replica/slave) are created. Replications can be increased/decreased which will increase/decrease number of replica/slaves. Connections are encrypted over the wire (ssl is enforced by default; X509 can be enforced by following pertinent comments in following scripts: 2 places in mysql/configmap.yaml, 2 places in openemr/deployment.yaml, 1 place in phpmyadmin/configmap.yaml, 1 place in phpmyadmin/deployment.yaml).
5-
- Redis - Configured to support failover. There is 1 master and 2 slaves (no read access on slaves) for a statefulset, 3 sentinels for another statefulset, and then 2 proxies deployment. The proxies ensure that redis traffic is always directed towards master. The proxy replications can be increased/decreased. However the primary/slaves and sentinels would require script changes if wish to increase/decrease replicates for these since these are hard-coded several place in the scripts. There are 3 users/passwords (`default` (defaultpassword), `replication` (replicationpassword), `admin` (adminpassword)) used in this redis scheme, and the passwords should be set to something else if use this scheme in production. The main place the passwords are set is in redis/configmap-acl.yaml script. Other places where passwords are used include the following: `replication` in redis/configmap-main.yaml, `admin` in redis/configmap-pipy.yaml, `admin` in redis/statefulset-sentinel.yaml, `admin` in redis/healthcheck-haproxy.yaml. The `default` is the typical worker/app/client user. Connections are encrypted over the wire (ssl is enforced by default; X509 can be enforced by following pertinent comments in following scripts: 2 places in openemr/deployment.yaml, 1 place in redis/configmap-main.yaml, 1 place in redis/healthcheck-haproxy.yaml, 1 place in redis/statefulset-redis.yaml, 2 places in redis/statefulset-sentinel.yaml).
5+
- Redis - Configured to support failover. There is 1 master and 2 slaves (no read access on slaves) for a statefulset and 3 sentinels for another statefulset. OpenEMR connects directly to Redis with mTLS (mutual TLS / X509 client certificate verification) by default. The primary/slaves and sentinels would require script changes if wish to increase/decrease replicates for these since these are hard-coded several places in the scripts. There are 3 users/passwords (`default` (defaultpassword), `replication` (replicationpassword), `admin` (adminpassword)) used in this redis scheme, and the passwords should be set to something else if use this scheme in production. The main place the passwords are set is in redis/configmap-acl.yaml script. Other places where passwords are used include the following: `replication` in redis/configmap-main.yaml, `admin` in redis/statefulset-sentinel.yaml. The `default` is the typical worker/app/client user. See the **Redis Connection Security** section below for details on the default mTLS configuration and how to downgrade to TLS-only or plain TCP.
66
- phpMyAdmin - There is 1 deployment instance of phpMyAdmin. Ports for both http and https.
77

8+
## Redis Connection Security
9+
By default, Redis connections use **mTLS (mutual TLS)** with X509 client certificate verification. All certificates are managed by cert-manager. To downgrade the connection security:
10+
11+
### Downgrade to TLS (encrypted, no client certs)
12+
1. `redis/configmap-main.yaml`: Change `tls-auth-clients yes` to `tls-auth-clients no`
13+
2. `redis/statefulset-redis.yaml`: Change `REDISX509=true` to `REDISX509=false`
14+
3. `redis/statefulset-sentinel.yaml`: Change `REDISX509=true` to `REDISX509=false` and change `tls-auth-clients yes` to `tls-auth-clients no`
15+
4. `openemr/deployment.yaml`: Remove the `REDIS_X509` environment variable and remove the `tls.crt` (redis-cert) and `tls.key` (redis-key) items from the `redis-openemr-client-certs` volume
16+
17+
### Downgrade to TCP (no encryption)
18+
Perform all the TLS downgrade steps above, then additionally:
19+
1. `redis/configmap-main.yaml`: Remove all `tls-*` lines, change `port 0` to `port 6379`, and remove `tls-port 6379`
20+
2. `redis/statefulset-redis.yaml`: Remove the `TLSPARAMETERS` variable and its usage in redis-cli commands, and remove the `redis-certs` volume and volumeMount
21+
3. `redis/statefulset-sentinel.yaml`: Remove the `TLSPARAMETERS` variable and its usage in redis-cli commands, remove the `sentinel-certs` volume and volumeMount, and remove all `tls-*` lines from the sentinel config generation
22+
4. `openemr/deployment.yaml`: Remove the `REDIS_TLS` environment variable and remove the entire `redis-openemr-client-certs` volume and volumeMount
23+
5. `certs/redis.yaml`, `certs/redis-openemr-client.yaml`, `certs/sentinel.yaml`: These cert-manager Certificate resources can be removed entirely
24+
6. `kub-up` and `kub-down` (and `.bat` variants): Remove the redis/sentinel cert references
25+
826
Would not consider this production quality, but will be a good working, starting point, and hopefully open the door to a myriad of other kubernetes based solutions. Note this is supported by 7.0.0 and higher dockers. If wish to use the most recent development codebase, then can change from openemr/openemr:7.0.3 to openemr/openemr:dev (in the openemr/deployment.yaml script), which is built nightly from the development codebase. If you wish to build dynamically from a branch/tag from a github repo or other git repo, then can change from openemr/openemr:7.0.3 to openemr/openemr:flex (in the openemr/deployment.yaml script) (note this will take much longer to start up (probably at least 10 minutes and up to 90 minutes) and is more cpu intensive since each instance of OpenEMR will download codebase and build separately).
927

1028
# Use
@@ -49,8 +67,6 @@ Would not consider this production quality, but will be a good working, starting
4967
pod/redis-0 1/1 Running 0 111s
5068
pod/redis-1 1/1 Running 0 77s
5169
pod/redis-2 1/1 Running 0 55s
52-
pod/redisproxy-744b7749dc-c6pkw 1/1 Running 0 111s
53-
pod/redisproxy-744b7749dc-k8rzp 1/1 Running 0 111s
5470
pod/sentinel-0 1/1 Running 0 111s
5571
pod/sentinel-1 1/1 Running 0 34s
5672
pod/sentinel-2 1/1 Running 0 30s
@@ -61,18 +77,15 @@ Would not consider this production quality, but will be a good working, starting
6177
service/openemr LoadBalancer 10.96.6.51 <pending> 8080:32561/TCP,8090:32468/TCP 111s
6278
service/phpmyadmin NodePort 10.96.64.163 <none> 8081:32195/TCP,8091:31981/TCP 111s
6379
service/redis ClusterIP None <none> 6379/TCP 111s
64-
service/redisproxy ClusterIP None <none> 6379/TCP 111s
6580
service/sentinel ClusterIP None <none> 5000/TCP 111s
6681
6782
NAME READY UP-TO-DATE AVAILABLE AGE
6883
deployment.apps/openemr 3/3 3 3 111s
6984
deployment.apps/phpmyadmin 1/1 1 1 111s
70-
deployment.apps/redisproxy 2/2 2 2 111s
7185
7286
NAME DESIRED CURRENT READY AGE
7387
replicaset.apps/openemr-7889cf48d8 3 3 3 111s
7488
replicaset.apps/phpmyadmin-f4d9bfc69 1 1 1 111s
75-
replicaset.apps/redisproxy-744b7749dc 2 2 2 111s
7689
7790
NAME READY AGE
7891
statefulset.apps/mysql-sts 2/2 111s
@@ -117,7 +130,6 @@ Would not consider this production quality, but will be a good working, starting
117130
NAME DESIRED CURRENT READY AGE
118131
openemr-7889cf48d8 3 3 3 9m22s
119132
phpmyadmin-f4d9bfc69 1 1 1 9m22s
120-
redisproxy-744b7749dc 2 2 2 9m22s
121133
```
122134
- Second, lets increase OpenEMR's replicas from 3 to 10 (ie. pretend in an environment where a huge number of OpenEMR users are using the system at the same time)
123135
```bash

kubernetes/certs/sentinel.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ spec:
2020
organizations:
2121
- sentinel
2222
commonName: sentinel
23+
dnsNames:
24+
- sentinel-0.sentinel
25+
- sentinel-1.sentinel
26+
- sentinel-2.sentinel
27+
- sentinel-0.sentinel.default.svc.cluster.local
28+
- sentinel-1.sentinel.default.svc.cluster.local
29+
- sentinel-2.sentinel.default.svc.cluster.local
2330
issuerRef:
2431
name: ca-issuer
2532
kind: Issuer

kubernetes/openemr/deployment.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ spec:
5252
value: "defaultpassword"
5353
- name: REDIS_TLS
5454
value: "yes"
55-
# uncomment below if using redis x509
5655
- name: REDIS_X509
5756
value: "yes"
57+
# To downgrade redis connection security:
58+
# tls (no client certs): remove REDIS_X509 above and remove redis cert/key volume mounts below
59+
# tcp (no encryption): also remove REDIS_TLS above and remove redis ca volume mount below
5860
- name: SWARM_MODE
5961
value: "yes"
6062
- name: FORCE_DATABASE_SSL_CONNECT
@@ -107,7 +109,6 @@ spec:
107109
items:
108110
- key: ca.crt
109111
path: redis-ca
110-
# uncomment below if using redis x509
111112
- key: tls.crt
112113
path: redis-cert
113114
- key: tls.key

kubernetes/redis/configmap-main.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ data:
3131
tls-cert-file /certs/tls.crt
3232
tls-key-file /certs/tls.key
3333
tls-ca-cert-file /certs/ca.crt
34-
tls-auth-clients no
35-
# uncomment below (and comment line above) if using redis x509
36-
#tls-auth-clients yes
34+
tls-auth-clients yes
3735
tls-replication yes
38-
36+
3937
# port, each redis nodes will be used (only use tls)
4038
port 0
4139
tls-port 6379
40+
41+
# To downgrade redis connection security:
42+
# tls (no client certs): change "tls-auth-clients yes" to "tls-auth-clients no"
43+
# tcp (no encryption): remove all tls lines above and change "port 0" to "port 6379" and remove "tls-port 6379"
4244
# More configurations are optional, if not provided, redis will consider default values ------
4345
# ------ More details on configuration : https://redis.io/docs/manual/config/ ------

kubernetes/redis/statefulset-redis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ spec:
2020
command: [ "sh", "-c" ]
2121
args:
2222
- |
23-
# Set below to true if using redis x509
23+
# To downgrade to tls (no client certs): change to false
2424
REDISX509=true
2525
TLSPARAMETERS="--tls --cacert /certs/ca.crt"
2626
if $REDISX509; then

kubernetes/redis/statefulset-sentinel.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
args:
2222
- |
2323
REDIS_PASSWORD=adminpassword
24-
# Set below to true if using redis x509
24+
# To downgrade to tls (no client certs): change to false
2525
REDISX509=true
2626
nodes=redis-0.redis,redis-1.redis,redis-2.redis
2727
TLSPARAMETERS="--tls --cacert /certs/ca.crt"
@@ -56,8 +56,6 @@ spec:
5656
tls-cert-file /certs/tls.crt
5757
tls-key-file /certs/tls.key
5858
tls-ca-cert-file /certs/ca.crt
59-
tls-auth-clients no
60-
# uncomment below (and comment line above) if using redis x509
6159
tls-auth-clients yes
6260
tls-replication yes
6361
sentinel monitor mymaster $MASTER 6379 2

0 commit comments

Comments
 (0)