Skip to content

Commit 8b4f396

Browse files
committed
Kubernetes rework in progress
1 parent 0511b12 commit 8b4f396

29 files changed

+321
-403
lines changed

kubernetes/README.md

+93-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,94 @@
1-
# OpenEMR Kubernetes Orchestrations
2-
- [Minikube](minikube): OpenEMR Kubernetes orchestration on Minikube. Creates 5 instances of OpenEMR with 1 instance of MariaDB, Redis, and phpMyAdmin.
1+
# Overview
2+
OpenEMR Kubernetes orchestration. Creates 2 instances of OpenEMR with 1 instance of MariaDB, Redis, and phpMyAdmin. Would not consider it 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 docker. If wish to use the most recent codebase rather than 6.0.0 docker, then can change from openemr/openemr:6.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).
3+
4+
(Quick note: Development in progress, minikube not required for deployment. :8080 for http, :8090 for https, grab the NodePort for phpmyadmin)
35

6+
# Use
7+
1. Install (and then start) Kubernetes with Minikube: https://kubernetes.io/docs/setup/learning-environment/minikube/
8+
- If you want to set up the base services(e.g. git, docker, docker-compose, openemr-cmd, minikube and kubectl) easily, please try [openemr-env-installer](https://github.com/openemr/openemr-devops/tree/master/utilities/openemr-env-installer)
9+
2. To start OpenEMR orchestration:
10+
```bash
11+
bash kub-up
12+
```
13+
3. Can see pod progress with following command:
14+
```bash
15+
kubectl get pod
16+
```
17+
- It will look something like this:
18+
```console
19+
NAME READY STATUS RESTARTS AGE
20+
mysql-565f988976-np9zs 1/1 Running 0 133m
21+
openemr-5f6db6c87c-8xgzq 1/1 Running 0 133m
22+
openemr-5f6db6c87c-bfktf 1/1 Running 0 133m
23+
openemr-5f6db6c87c-bwzdr 1/1 Running 0 133m
24+
openemr-5f6db6c87c-qn5ll 1/1 Running 0 133m
25+
openemr-5f6db6c87c-znq8h 1/1 Running 0 133m
26+
phpmyadmin-78968d6cfb-cdfmq 1/1 Running 0 133m
27+
redis-74cc9d667-5ltbq 1/1 Running 0 133m
28+
```
29+
4. Can see the service listing with following command:
30+
```bash
31+
kubectl get svc
32+
```
33+
- It will look something like this:
34+
```console
35+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
36+
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 151m
37+
mysql ClusterIP 10.109.255.180 <none> 3306/TCP 147m
38+
openemr NodePort 10.104.48.53 <none> 8080:31314/TCP,8090:30613/TCP 147m
39+
phpmyadmin NodePort 10.97.77.18 <none> 8081:30571/TCP 147m
40+
redis ClusterIP 10.98.24.148 <none> 6379/TCP 147m
41+
```
42+
5. Can get the link to go to OpenEMR with following command (use the top link for http and bottom link for https):
43+
```bash
44+
minikube service openemr --url
45+
```
46+
- It will look something like this:
47+
```console
48+
http://192.168.99.100:31314
49+
http://192.168.99.100:30613
50+
```
51+
6. Can get the link to go to phpMyAdmin with following command:
52+
```bash
53+
minikube service phpmyadmin --url
54+
```
55+
- It will look something like this:
56+
```console
57+
http://192.168.99.100:30571
58+
```
59+
7. Some cool replicas stuff. The OpenEMR docker pods are run as a replica set (since it is set to 5 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.
60+
- First. lets list the replica set like this:
61+
```bash
62+
kubectl get rs
63+
```
64+
- It will look something like this (note OpenEMR has 5 desired and 5 current replicas going):
65+
```console
66+
NAME DESIRED CURRENT READY AGE
67+
mysql-64449b8cf7 1 1 1 4m5s
68+
openemr-5f6db6c87c 5 5 5 4m5s
69+
phpmyadmin-78968d6cfb 1 1 1 4m5s
70+
redis-74cc9d667 1 1 1 4m5s
71+
```
72+
- Second, lets decrease OpenEMR's replicas from 5 to 2 (ie. pretend in an environment where don't need to expend resources of offering 5 replicas, perhaps after hours)
73+
```bash
74+
kubectl scale deployment.v1.apps/openemr --replicas=2
75+
```
76+
- It will return the following:
77+
```console
78+
deployment.apps/openemr scaled
79+
```
80+
- Now, there are only 2 replicas of OpenEMR instead of 5. Enter the `kubectl get rs` and `kubectl get pod` to see what happened.
81+
- Third, lets increase OpenEMR's replicas from 2 to 10 (ie. pretend in an environment where a huge number of OpenEMR users are using the system at the same time)
82+
```bash
83+
kubectl scale deployment.v1.apps/openemr --replicas=10
84+
```
85+
- It will return the following:
86+
```console
87+
deployment.apps/openemr scaled
88+
```
89+
- Now, there are 10 replicas of OpenEMR instead of 2. Enter the `kubectl get rs` and `kubectl get pod` to see what happened.
90+
- 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.
91+
8. To stop and remove OpenEMR orchestration (this will delete everything):
92+
```bash
93+
bash kub-down
94+
```

kubernetes/kub-down

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
kubectl delete \
4+
-f mysql/secret.yaml \
5+
-f mysql/deployment.yaml \
6+
-f mysql/service.yaml \
7+
-f redis/deployment.yaml \
8+
-f redis/service.yaml \
9+
-f phpmyadmin/deployment.yaml \
10+
-f phpmyadmin/service.yaml \
11+
-f volumes/letsencrypt.yaml \
12+
-f volumes/ssl.yaml \
13+
-f volumes/website.yaml \
14+
-f openemr/secret.yaml \
15+
-f openemr/deployment.yaml \
16+
-f openemr/service.yaml

kubernetes/kub-down.bat

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off
2+
kubectl delete ^
3+
-f mysql/secret.yaml ^
4+
-f mysql/deployment.yaml ^
5+
-f mysql/service.yaml ^
6+
-f redis/deployment.yaml ^
7+
-f redis/service.yaml ^
8+
-f phpmyadmin/deployment.yaml ^
9+
-f phpmyadmin/service.yaml ^
10+
-f volumes/letsencrypt.yaml ^
11+
-f volumes/ssl.yaml ^
12+
-f volumes/website.yaml ^
13+
-f openemr/secret.yaml ^
14+
-f openemr/deployment.yaml ^
15+
-f openemr/service.yaml
16+

kubernetes/kub-up

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
kubectl apply \
4+
-f mysql/secret.yaml \
5+
-f mysql/deployment.yaml \
6+
-f mysql/service.yaml \
7+
-f redis/deployment.yaml \
8+
-f redis/service.yaml \
9+
-f phpmyadmin/deployment.yaml \
10+
-f phpmyadmin/service.yaml \
11+
-f volumes/letsencrypt.yaml \
12+
-f volumes/ssl.yaml \
13+
-f volumes/website.yaml \
14+
-f openemr/secret.yaml \
15+
-f openemr/deployment.yaml \
16+
-f openemr/service.yaml

kubernetes/kub-up.bat

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@echo off
2+
kubectl apply ^
3+
-f mysql/secret.yaml ^
4+
-f mysql/deployment.yaml ^
5+
-f mysql/service.yaml ^
6+
-f redis/deployment.yaml ^
7+
-f redis/service.yaml ^
8+
-f phpmyadmin/deployment.yaml ^
9+
-f phpmyadmin/service.yaml ^
10+
-f volumes/letsencrypt.yaml ^
11+
-f volumes/ssl.yaml ^
12+
-f volumes/website.yaml ^
13+
-f openemr/secret.yaml ^
14+
-f openemr/deployment.yaml ^
15+
-f openemr/service.yaml

kubernetes/minikube/README.md

-107
This file was deleted.

kubernetes/minikube/docker-compose.yml

-54
This file was deleted.

kubernetes/minikube/kub-down

-12
This file was deleted.

kubernetes/minikube/kub-down.bat

-13
This file was deleted.

kubernetes/minikube/kub-up

-13
This file was deleted.

kubernetes/minikube/kub-up.bat

-12
This file was deleted.

0 commit comments

Comments
 (0)