/ignite-kubernetes-essentials-training

Project for the Apache Ignite and Kubernetes Training Course

Primary LanguageJavaApache License 2.0Apache-2.0

Apache Ignite and Kubernetes Training Course

This project is used for hands-on exercises of the Apache Ignite and Kubernetes: Deployment and Orchestration Strategies training course. That's a free two-hour training session for developers, architects, and DevOps engineers who need to deploy and orchestrate Apache Ignite in a Kubernetes environment.

Check the schedule a join one of our upcoming sessions. All the courses are delivered by seasoned Ignite community members.

Setting Up Environment

This project uses GridGain Community Edition version 8.8.27

  1. Install Docker Desktop and kubectl tool. We tested with version 4.18.0.
  2. Enable Kubernetes in Docker Desktop's settings
  3. Java Developer Kit, version 11 or later
  4. Apache Maven 3.0 or later
  5. Your favorite IDE, such as IntelliJ IDEA, or Eclipse, or a simple text editor.

Clone The Project

  1. Clone this project or download it as an archive:
    git clone https://github.com/GridGain-Demos/ignite-kubernetes-essentials-training.git

Setup Kubernetes Dashboard

  1. Change into dashboard directory
    cd {project_root}/ignite-kubernetes-essentials-training/k8dashboard
  2. Apply the Metrics Server configuration
    kubectl apply -f metrics-server.yaml
  3. Apply the Dashboard configuration
    kubectl apply -f k8ui.yaml
  4. Create the Service Account
    kubectl apply -f service-account.yaml
  5. Apply the Cluster Role Binding
    kubectl apply -f cluster-role-binding.yaml
  6. Create token
 kubectl -n kubernetes-dashboard create token admin-user
  1. Run the proxy
    kubectl proxy
  2. Open Dashboard in browser http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login
  3. Paste the token you got in 4.

Set Up Kubernetes for Ignite

Start the Ignite Kubernetes Service that is used inter-node communication needs:

  1. Navigate to the project's config folder:

    cd {project_root}/ignite-kubernetes-essentials-training/config
  2. Create a namespace for the training course:

    kubectl create namespace ignite-namespace
  3. Start the Ignite Kubernetes service

    kubectl create -f ignite-service.yaml
  4. Confirm the service is running:

    kubectl get services -n ignite-namespace

Next, create a Cluster Role and Service Accounts:

  1. Create a service account:
    kubectl create sa ignite -n ignite-namespace
  2. Create a Cluster Role:
    kubectl create -f cluster-role.yaml

Start Ignite Cluster

  1. Create a ConfigMap with persistent configuration:

    kubectl create configmap ignite-cfg-persistent -n ignite-namespace --from-file=persistent/ignite-node-cfg.xml
  2. Start the cluster:

    kubectl create -f persistent/ignite-cluster.yaml
  3. Confirm the Ignite pods are running:

    kubectl get pods -n ignite-namespace
  4. Double check with Ignite logs that a 2-node cluster was created:

    kubectl logs ignite-cluster-0 -n ignite-namespace
  5. Attach your cluster to GridGain Control Center by going to https://portal.gridgain.com/ and providing the cluster's token ID from the logs.

  6. Active the persistent cluster with Control Center https://portal.gridgain.com/clusters/list

Load Sample Database

  1. Connect to the first cluster pod via bash:
    kubectl exec --stdin --tty ignite-cluster-0 -n ignite-namespace -- /bin/bash
  2. Go to the bin folder:
    cd bin/
  3. Connect to the cluster via SQLLine tool:
    ./sqlline.sh -u jdbc:ignite:thin://127.0.0.1/
  4. Load the World database:
    !run ../examples/sql/world.sql
  5. Quit from SQLLine:
    !q
  6. Quit from bash:
    exit
  7. Refresh the Storage Metrics dashboard on the Control Center side to confirm that the data was loaded.

Connect With External Applications

In this section, you're connecting to the K8 Ignite cluster with external APIs and applications (those that are not deployed in the same K8 environment).

Query Data With Ignite REST API

  1. Open up your preferred browser and check the cluster state via the Ignite REST API:

    http://localhost:8080/ignite?cmd=state

    Note, the localhost is the external-IP of the Ignite Kubernetes Service.

  2. Select the count of Cities:

    http://localhost:8080/ignite?cmd=qryfldexe&pageSize=10&cacheName=City&qry=SELECT%20count(*)%20From%20City

    Note, on Windows workstation due to Hyper-V or WSL above port 8080 may be blocked. A workaround is to install k8slens and it will create a port forwarding to 8080 via a local_port on localhost. Then invoke the Ignite REST API as http://localhost:<local_port>/ignite?cmd=......

Run Java Thin Client

  1. Build the project
mvn clean package
  1. Execute the thin client class
java -cp target/ignite-kubernetes-essentials-training-1.0-SNAPSHOT.jar com.gridgain.example.SampleThinClient

Note, the thin client tries to connect to your Ignite cluster on 10800 port. On Windows workstation that port is not automatically selected and so in k8slens create a port forwarding to 10800 by setting local_port to 10800 on localhost.

Deploy Thick Client in kubernetes

  1. Create the Docker image
docker build -t ignite-thick-client .
  1. Create the client Kubernetes Service

    kubectl apply -f config/ignite-client-service.yaml
  2. Create the thick client pods

 kubectl apply -f config/thick-client.yaml
  1. Open up your preferred browser and check the REST API:
    http://localhost:8088/cities

Note, as was the case in Ignite REST API above, on Windows workstation due to Hyper-V or WSL above port 8088 may be blocked. Use k8slens to create a port forwarding to 8080 via a local_port on localhost. Then invoke the Ignite REST API as http://localhost:<local_port>/cities

Clear Project Resources

  1. Remove all the resources associated with this project:
    kubectl delete namespace ignite-namespace
  2. Remove the ClusterRole:
    kubectl delete clusterrole ignite -n ignite-namespace
  3. Remove the ClusterRole binding:
    kubectl delete clusterrolebinding ignite -n ignite-namespace

Note, use this command if the termination of an Ignite pod is stuck: kubectl delete pod ignite-cluster-1 --grace-period=0 --force -n ignite-namespace