This document outlines running bahmni kubernetes cluster using minikube for local development. Minikube in general is not recomeded for Production usage (while technically possible) - for the biggest reason that it runs a single node kubernetes cluster and would result in a single point of failure (even if it could handle managing and scaling pods).
Docker: Getting started
Kubernetes components
Understand Minikube
Helm Quick Start
Install docker
Install minikube >=1.25.2
Install Helm-3
Increase resources of your docker to a memory of atleast 8GB. (Mac / Windows)
You can also run minikube without using docker. Look here.
You can also run minikube without using docker. Look here.
minikube start --driver=docker --memory 7000 --cpus=4 |
you should see
๐ minikube v1.25.2 on Darwin 10.15.7 โจ Using the docker driver based on user configuration ๐ Starting control plane node minikube in cluster minikube ๐ Pulling base image ... ๐ฅ Creating docker container (CPUs=4, Memory=7000MB) ...\ |
Ingress would act as a controller to route between various applicaitons
minikube addons enable ingress
MacOS / Linux
sudo vi /etc/hosts # bahmni kubernetes nginx-ingress 127.0.0.1 bahmni.k8s # bahmni crater kubernetes nginx-ingress 127.0.0.1 payments-bahmni.k8s |
Windows
Press the Windows key. Type Notepad in the search field. In the search results, right-click Notepad and select Run as administrator. From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts Make the necessary changes to the file. Select File > Save to save your changes. |
minikube tunnel runs as a process, creating a network route on the host to the
service CIDR of the cluster using the clusterโs IP address as a gateway. The
tunnel command exposes the external IP directly to any program running on the
host operating system.
sudo minikube tunnel --alsologtostderr -v=1
Run this in a separate terminal and keep it open
Run this in a separate terminal and keep it open
helm install --repo https://charts.bitnami.com/bitnami openmrsdb mysql --set auth.rootPassword=root --set image.tag=5.7 |
We have notice some local connection issues while provisioning mysql via community helm chart. You could alternatively use the |
kubectl apply -f db/openmrsdb.yaml |
To uninstall or delete use
kubectl delete -R -f db/. |
helm install db-setup db-setup --repo https://bahmni.github.io/helm-charts --devel --wait --wait-for-jobs --atomic --timeout 1m \ --set DB_HOST=openmrsdb \ --set DB_ROOT_USERNAME=root \ --set DB_ROOT_PASSWORD=root \ --set databases.openmrs.DB_NAME=openmrs \ --set databases.openmrs.USERNAME=openmrs-user \ --set databases.openmrs.PASSWORD=password \ --set databases.crater.DB_NAME=crater \ --set databases.crater.USERNAME=crater-user \ --set databases.crater.PASSWORD=password \ --set databases.reports.DB_NAME=bahmni_reports \ --set databases.reports.USERNAME=reports-user \ --set databases.reports.PASSWORD=password |
This command takes a while to complete. Once it is completed run the following command to remove database root credentials from the cluster.
helm uninstall db-setup |
You can connect to your local mysql db using
kubectl run mysql-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mysql:5.7 --namespace default --env MYSQL_ROOT_PASSWORD=root --command -- bash |
followed by
mysql -h mysql.default.svc.cluster.local -uroot -proot |
Clone the helm-umbrella-chart repository and run below commands on your terminal (read the notes below if you need to toggle on/off certain services in the cluster)
helm dependency update helm upgrade bahmni-local . --values=values/local.yaml --install |
Toggle on the services in local.yaml based on your local setup requirements. Add any missing environment variables either in local.yaml or --set
. Check helm upgrade ...
for list of variable needed by each service.
To uninstall a release use helm uninstall [release name]
which will uninstall all the resources under that release e.g. helm uninstall db-setup
Minikube runs in a VM (such as docker) and wont see your local built docker images. If you need to use your local docker images to be picked up while provisioning the pods on minikube you can use eval $(minikube docker-env)
to actually configure your environment to utilise minikube's docker daemon for docker images. docs
Toggle on the services in local.yaml based on your local setup requirements. Add any missing environment variables either in local.yaml or --set
. Check helm upgrade ...
for list of variable needed by each service.
To uninstall a release use helm uninstall [release name]
which will uninstall all the resources under that release e.g. helm uninstall db-setup
Minikube runs in a VM (such as docker) and wont see your local built docker images. If you need to use your local docker images to be picked up while provisioning the pods on minikube you can use eval $(minikube docker-env)
to actually configure your environment to utilise minikube's docker daemon for docker images. docs
Your local might be setup to query cloud K8s clusters e.g. aws. You need to ensure that you are in the minikube context for local development. Minikube bootstrap should take care of updating the kubectl current-context. You can verify and update the context using |
//verify current context $ kubectl config current-context (or) $ kubectl config view --minify //Update current context to minikube $ minikube update-context |
Once the pods and services are running you can access it from the browser on
Bahmni EMR --> https://bahmni.k8s/bahmni/home
OpenMRS --> https://bahmni.k8s/openmrs
Crater --> https://payments-bahmni.k8s/