Skip to content

Commit 04dd9b2

Browse files
committed
hopefully finishing touches on kubernetes
1 parent 32916c0 commit 04dd9b2

File tree

5 files changed

+59
-46
lines changed

5 files changed

+59
-46
lines changed

kubernetes/README.md

+53-41
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ OpenEMR Kubernetes orchestration. Orchestration included OpenEMR, MariaDB, Redis
55
- 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` (nopass), `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 kubernetes/redis/configmap-acl.yaml script. Other places where passwords are used include the following: `replication` in kubernetes/redis/configmap-main.yaml, `admin` in kubernetes/redis/configmap-pipy.yaml, `admin` in kubernetes/redis/statefulset-sentinel.yaml. The `default` is the typical worker/app/client user, which will plan to assign a password when OpenEMR docker is updated to support redis username/password.
66
- phpMyAdmin - There is 1 deployment instance of phpMyAdmin.
77

8-
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 6.0.0 and higher dockers. If wish to use the most recent development codebase, then can change from openemr/openemr:7.0.0 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).
8+
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.0 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.0 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).
99

1010
(Quick note: Development in progress, minikube or kind not required for deployment. :8080 for http, :8090 for https, grab the NodePort for phpmyadmin)
1111

12-
You should drop down to one OpenEMR instance-node before trying to pull in an updated image.
13-
14-
TODO (optimizing some things). Add support for redis password in the OpenEMR dockers; then add password to the default user in the redis acl (it is now set to work without a password); then turn on protected mode in redis config.
15-
1612
# Use
1713
1. Install (and then start) Kubernetes with Minikube or Kind or other.
1814
- For Minikube or other, can find online documentation.
@@ -39,36 +35,53 @@ TODO (optimizing some things). Add support for redis password in the OpenEMR doc
3935
```bash
4036
bash kub-up
4137
```
42-
3. Can see pod progress with following command:
43-
```bash
44-
kubectl get pod
45-
```
46-
- It will look something like this:
47-
```console
48-
NAME READY STATUS RESTARTS AGE
49-
mysql-565f988976-np9zs 1/1 Running 0 133m
50-
openemr-5f6db6c87c-8xgzq 1/1 Running 0 133m
51-
openemr-5f6db6c87c-bfktf 1/1 Running 0 133m
52-
openemr-5f6db6c87c-bwzdr 1/1 Running 0 133m
53-
openemr-5f6db6c87c-qn5ll 1/1 Running 0 133m
54-
openemr-5f6db6c87c-znq8h 1/1 Running 0 133m
55-
phpmyadmin-78968d6cfb-cdfmq 1/1 Running 0 133m
56-
redis-74cc9d667-5ltbq 1/1 Running 0 133m
57-
```
58-
4. Can see the service listing with following command:
38+
3. Can see overall progress with following command:
5939
```bash
60-
kubectl get svc
40+
kubectl get all
6141
```
62-
- It will look something like this:
42+
- It will look something like this when completed:
6343
```console
64-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
65-
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 151m
66-
mysql ClusterIP 10.109.255.180 <none> 3306/TCP 147m
67-
openemr NodePort 10.104.48.53 <none> 8080:31314/TCP,8090:30613/TCP 147m
68-
phpmyadmin NodePort 10.97.77.18 <none> 8081:30571/TCP 147m
69-
redis ClusterIP 10.98.24.148 <none> 6379/TCP 147m
44+
NAME READY STATUS RESTARTS AGE
45+
pod/mysql-sts-0 1/1 Running 0 111s
46+
pod/mysql-sts-1 1/1 Running 0 91s
47+
pod/openemr-7889cf48d8-9jdfl 1/1 Running 0 111s
48+
pod/openemr-7889cf48d8-qphrw 1/1 Running 0 111s
49+
pod/openemr-7889cf48d8-zlx9f 1/1 Running 0 111s
50+
pod/phpmyadmin-f4d9bfc69-rx82d 1/1 Running 0 111s
51+
pod/redis-0 1/1 Running 0 111s
52+
pod/redis-1 1/1 Running 0 77s
53+
pod/redis-2 1/1 Running 0 55s
54+
pod/redisproxy-744b7749dc-c6pkw 1/1 Running 0 111s
55+
pod/redisproxy-744b7749dc-k8rzp 1/1 Running 0 111s
56+
pod/sentinel-0 1/1 Running 0 111s
57+
pod/sentinel-1 1/1 Running 0 34s
58+
pod/sentinel-2 1/1 Running 0 30s
59+
60+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
61+
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 3m40s
62+
service/mysql ClusterIP None <none> 3306/TCP 111s
63+
service/openemr LoadBalancer 10.96.6.51 <pending> 8080:32561/TCP,8090:32468/TCP 111s
64+
service/phpmyadmin NodePort 10.96.64.163 <none> 8081:31466/TCP 111s
65+
service/redis ClusterIP None <none> 6379/TCP 111s
66+
service/redisproxy ClusterIP None <none> 6379/TCP 111s
67+
service/sentinel ClusterIP None <none> 5000/TCP 111s
68+
69+
NAME READY UP-TO-DATE AVAILABLE AGE
70+
deployment.apps/openemr 3/3 3 3 111s
71+
deployment.apps/phpmyadmin 1/1 1 1 111s
72+
deployment.apps/redisproxy 2/2 2 2 111s
73+
74+
NAME DESIRED CURRENT READY AGE
75+
replicaset.apps/openemr-7889cf48d8 3 3 3 111s
76+
replicaset.apps/phpmyadmin-f4d9bfc69 1 1 1 111s
77+
replicaset.apps/redisproxy-744b7749dc 2 2 2 111s
78+
79+
NAME READY AGE
80+
statefulset.apps/mysql-sts 2/2 111s
81+
statefulset.apps/redis 3/3 111s
82+
statefulset.apps/sentinel 3/3 111s
7083
```
71-
5. Getting the url link to OpenEMR:
84+
4. Getting the url link to OpenEMR:
7285
- If using minikube, can get the link to go to OpenEMR with following command (use the top link for http and bottom link for https):
7386
```bash
7487
minikube service openemr --url
@@ -78,11 +91,11 @@ TODO (optimizing some things). Add support for redis password in the OpenEMR doc
7891
http://192.168.99.100:31314
7992
http://192.168.99.100:30613
8093
```
81-
- If using kind, then can use the 3***** port shown in step 4 above with the ip address obtained from following command:
94+
- If using kind, then can use the 3***** port shown in step 3 (at `service/openemr`) above with the ip address obtained from following command:
8295
```bash
8396
docker inspect kind-control-plane | grep "IPAddress"
8497
```
85-
6. Getting the url link to phpMyAdmin:
98+
5. Getting the url link to phpMyAdmin:
8699
- If using minikube, can get the link to go to phpMyAdmin with following command:
87100
```bash
88101
minikube service phpmyadmin --url
@@ -91,22 +104,21 @@ TODO (optimizing some things). Add support for redis password in the OpenEMR doc
91104
```console
92105
http://192.168.99.100:30571
93106
```
94-
- If using kind, then can use the 3***** port shown in step 4 above with the ip address obtained from following command:
107+
- If using kind, then can use the 3***** port shown in step 3 (at `service/phpmyadmin`) above with the ip address obtained from following command:
95108
```bash
96109
docker inspect kind-control-plane | grep "IPAddress"
97110
```
98-
7. Some cool replicas stuff with OpenEMR. The OpenEMR docker pods are run as a replica set (since it is set to 3 replicas in this OpenEMR deployment script). Gonna cover how to view the replica set and how to change the number of replicas on the fly in this step.
111+
6. Some cool replicas stuff with OpenEMR. The OpenEMR docker pods are run as a replica set (since it is set to 3 replicas in this OpenEMR deployment script). Gonna cover how to view the replica set and how to change the number of replicas on the fly in this step.
99112
- First. lets list the replica set like this:
100113
```bash
101114
kubectl get rs
102115
```
103116
- It will look something like this (note OpenEMR has 3 desired and 3 current replicas going):
104117
```console
105118
NAME DESIRED CURRENT READY AGE
106-
mysql-64449b8cf7 1 1 1 4m5s
107-
openemr-5f6db6c87c 3 3 3 4m5s
108-
phpmyadmin-78968d6cfb 1 1 1 4m5s
109-
redis-74cc9d667 1 1 1 4m5s
119+
openemr-7889cf48d8 3 3 3 9m22s
120+
phpmyadmin-f4d9bfc69 1 1 1 9m22s
121+
redisproxy-744b7749dc 2 2 2 9m22s
110122
```
111123
- 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)
112124
```bash
@@ -127,7 +139,7 @@ TODO (optimizing some things). Add support for redis password in the OpenEMR doc
127139
```
128140
- Now, there are 5 replicas of OpenEMR instead of 10. Enter the `kubectl get rs` and `kubectl get pod` to see what happened.
129141
- This is just a quick overview of scaling. Note we just did manual scaling in the example above, but there are also options of automatic scaling for example depending on cpu use etc.
130-
8. Some cool replicas stuff with MariaDB. 2 statefulset replications of MariaDB (1 primary/master with 1 replica/slave) are created by default. The number of replicas can be increased or decreased.
142+
7. Some cool replicas stuff with MariaDB. 2 statefulset replications of MariaDB (1 primary/master with 1 replica/slave) are created by default. The number of replicas can be increased or decreased.
131143
- Increase replicas (after this command will have the 1 primary/master with 3 replicas/slaves).
132144
```bash
133145
kubectl scale sts mysql-sts --replicas=4
@@ -136,7 +148,7 @@ TODO (optimizing some things). Add support for redis password in the OpenEMR doc
136148
```bash
137149
kubectl scale sts mysql-sts --replicas=3
138150
```
139-
9. To stop and remove OpenEMR orchestration (this will delete everything):
151+
8. To stop and remove OpenEMR orchestration (this will delete everything):
140152
```bash
141153
bash kub-down
142154
```

kubernetes/openemr/deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ spec:
4848
value: "admin"
4949
- name: REDIS_SERVER
5050
value: "redisproxy"
51+
- name: REDIS_PASSWORD
52+
value: "defaultpassword"
5153
- name: SWARM_MODE
5254
value: "yes"
5355
image: openemr/openemr:7.0.0

kubernetes/redis/configmap-acl.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ data:
66
users.acl: |
77
user admin on >adminpassword ~* &* +@all
88
user replication on >replicationpassword +psync +replconf +ping
9-
user default on nopass ~* &* +@all -@dangerous
9+
user default on >defaultpassword ~* &* +@all -@dangerous

kubernetes/redis/configmap-main.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ data:
1717
#appendfilename "appendonly.aof"
1818
1919
# Enabled ACL based auth.
20-
# TODO - support protected mode after have support for a redis password in the openemr docker
21-
# then can set password for the default user in the acl conf
22-
protected-mode no
20+
protected-mode yes
2321
2422
# This is used by the replics nodes to communicate with master to replicate the data.
2523
# we are using a user called "replication" for this, and the a strong pwd for the same is given in masterauth
2624
masterauth replicationpassword
2725
masteruser replication
2826
29-
# this is the second ConfiMap will be mounted to. it has the list of uses needed.
27+
# this is the second ConfigMap will be mounted to. it has the list of users needed.
3028
aclfile /conf/acl/users.acl
3129
3230
# port, each redis nodes will be used

kubernetes/redis/configmap-pipy.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ data:
3636
unhealthy_nodes.remove(_target),
3737
data = resp.shift(40).toString().split('\r\n'),
3838
role = data[3].split(':')[1],
39+
config.debug && console.log(`Role is ${role} for ${_target}`),
3940
role === 'master' && unhealthy_master.remove(_target)
4041
))()
4142
})

0 commit comments

Comments
 (0)