This repository provides an example of Kubernetes active/standby deployment solution for HA mission critical applications.
The following applications need to be installed. Besides the versions used to test the project.
- Minikube (1.24.0)
- Redis (6.2.0)
- Docker (20.10.8)
- Clone or download this repository
- Create container images
./buildContainers.sh- Start minikube with 4 nodes and docker driver
minikube start -n 4 --driver=docker- Apply cluster configuration
pushd k8s; \
kubectl apply -f rbac.yaml; \
kubectl apply -f app.yaml; \
kubectl apply -f service.yaml; \
kubectl apply -f audit.yaml; \
popd- Access the web interface
minikube service app-serviceOn the web browser execute start application command:
http://server-address:port/start
the status is now running.
Delete the active pod:
kubectl get pods --show-labels
kubectl delete pod `<name of the active pod>Wait for the standby pod to take over:
kubectl get pods --show-labelsOn the web browser execute state application command:
http://server-address:port/start
Note the state is kept as running but the pod name is different. The standby pod has taken over.
To see the audit function fixing pod state inconsistencies change the standby pod to active.
kubectl label pods --overwrite `<standby pod>` mode=activeIf you are more confortable using UI start the Minikube dashboard:
minikube dashboard