Building and testing Kubernetes module
=========================================

The instructions provide a guidance on how to build and test Ignite Kubernetes IP finder in Kubernetes environment.

To test the IP finder you have to build the whole Apache Ignite project, package the binary as a Docker image and
feed the image to your kubernetes environment.

Building Apache Ignite
=========================

Use the command below to assemble an Apache Ignite binary:
    mvn clean package -Prelease -Dignite.edition=apache-ignite-lgpl -DskipTests

Note, if you alter the build instruction somehow make sure to update the files under 'config' folder if needed.

Installing Docker and Minikube
==============================

Install Docker and Minikube for testing purpose in your development environment.

Once this is done, make sure that Minikube sees Docker images registered locally:
    eval $(minikube docker-env)

Start Minikube:
    minikube start --vm-driver=xhyve

Assembling Apache Ignite Docker Image
=====================================

Create a folder for all the files to be placed in the Docker image and copy the following there:
    - Apache Ignite binary in a zip form built at the step above.
    - Dockerfile from `ignite-kubernetes/config/Dockerfile`.
    - Ignite configuration with enabled Kubernetes IP finder from `ignite-kubernetes/config/example-kube.xml`.
    - The executable file that will start an Ignite node process from `ignite-kubernetes/config/run.sh`

Go to the folder and execute a command below to prepare the image:
    docker build -t ignite-kube:v1 .

Creating containerized Ignite pods and Ignite lookup service
============================================================

Start the Kubernetes service that is used for IP addresses lookup. Use `ignite-kubernetes/config/ignite-service.yaml`:
	kubectl create -f {path_to}/ignite-service.yaml

Create and deploy Ignite pods using `ignite-kubernetes/config/ignite-deployment.yaml` configuration:
    kubectl create -f {path_to}/ignite-deployment.yaml

Make sure that the pods were deployed and running properly:
    kubectl get pod
    kubectl logs {pod name}

Increase or decrease number of Ignite pods checking that Kubernetes IP finder works as expected:
    kubectl scale --replicas=4 -f {path_to}/ignite-deployment.yaml

Docker Image Redeployment
=========================

If you need to redeploy the docker image after it gets updated and you prefer not to change the image version then
delete a current Kubernetes Ignite deployment (don't delete the service):
    kubectl delete deployment ignite-cluster

After that you are free to build and deploy an updated docker image using the same commands as listed above.
