Kubernetes - padogrid/padogrid GitHub Wiki

◀️ PadoGrid-Pods :link: Docker ▶️


In addition to PadoGrid Vagrant VM pods described in the previous section, PadoGrid also includes Kubernetes support for running data grids in containers on minikube, GKE, minishift, OpenShift Local (CRC), and OpenShift. Instead of using Helm charts, PadoGrid provides kustomization support for dynamically patching and customizing your Kubernetes environment. It includes configuration files for deploying a data grid cluster, custom metrics API, Prometheus adapter, and HPA (Horizontal Pod Autoscaler).

PadoGrid maintains containers at docker.io. The PadoGrid container stores workspaces in the /opt/padogrid/workspaces directory, which you can mount to a persistent volume as needed.

1. Docker Hub

PadoGrid Docker images are available at the following links at Docker Hub:

2. Environment Variables

The following environment variables are supported by the configuration file, padogrid.yaml.

Environment Variable Default Description
HAZELCAST_CLUSTER_NAME dev Hazelcast cluster name.
HAZELCAST_SERVICE hazelcast The Kubernets service for the perf_test app for connecting to the Hazelcast cluster.
NAMESPACE <Kubernetes namespace> Kubernetes namespace set by the configuration file.
PADOGRID_HTTPS_ENABLED false JupyterLab protocol. "false" for HTTP, "true" for HTTPS.
PADOGRID_SERVICE_NAME padogrid PadoGrid service name.

Except for PADOGRID_HTTPS_ENABLED, you can change the environment varaiable values at any time from the PadoGrid pod. For example, the per_test app uses NAMESPACE, HAZELCAST_SERVICE, and HAZELCAST_CLUSTER_NAME to determine the connection endpoint. See Ingesting Data for details.

2.1. PadoGrid Hazelcast Dashboard (PHD) Environment Variables

The padogrid/padogrid-grafana container image currently includes only Hazelcast dashboards. It is an installer container that terminates upon installation of PHD to the specified Grafana instance. It supports the following environment variables. Please see Docker Hub for instructions on running the PHD container.

Env Variable Default Description
PADOGRID_GRAFANA_PROTOCOL http http or https
PADOGRID_GRAFANA_HOST localhost Grafana host name or address
PADOGRID_GRAFANA_PORT 3000 Grafana port number
PADOGRID_GRAFANA_USER_NAME admin Grafana user with admin privileges
PADOGRID_GRAFANA_PASSWORD admin Grafana user password
PADOGRID_GRAFANA_LABEL job Prometheus label to filter. Allowed values are job, namespace, or service. For Prometheus running on Kubernetes, this environment variable should be set to namespace or service. All others should be set to job.
PADOGRID_GRAFANA_EDITABLE false By default, all PHD dashboards are in the read-only mode. Set this enviroment variable to true to make the dashboards editable.
PADOGRID_GRAFANA_DATASOURCE_REGEX /.*/ By default, PHD includes all Prometheus data source instances defined in Grafana. Set this environment variable to a regex expression to filter data sources. The regex expression must be enclosed in forward-slashes, e.g., /.*/.

✏️ The subsequent sections are for the main container image only.

3. Running PadoGrid on Kubernetes

3.1. Run PadoGrid

You can run PadoGrid in Kubernetes using one of the following options.

  1. Using padogrid.yaml:
kubectl apply -f https://raw.githubusercontent.com/padogrid/padogrid/develop/padogrid-deployment/src/main/resources/common/k8s/padogrid.yaml
  1. Using container image:
# kubctl
kubectl run padogrid --image=docker.io/padogrid/padogrid

3.2. Login to PadoGrid

You can login to PadoGrid using one of the following options.

  1. To login to PadoGrid via JupyerLab:
kubectl port-forward svc/padogrid 8888:8888
  1. To login directly to the PadoGrid pod:
# kubctl
kubectl exec -it padogrid -- bash

3.3. Delete PadoGrid

You can delete PadoGrid using one of the following options.

  1. To delete the PadoGrid deployment via padogrid.yaml:
kubectl apply -f https://raw.githubusercontent.com/padogrid/padogrid/develop/padogrid-deployment/src/main/resources/common/k8s/padogrid.yaml
  1. To delete the PadoGrid pod:
# kubctl
kubectl delete pod paodgrid

4. Running PadoGrid on OpenShift

PadoGrid runs as a non-root user (padogrid/1001). To run a non-root user container on OpenShift, we need to add the project's default user to the nonroot SSC (Security Context Constraints).

# Create project
oc new-project padogrid

# Add the nonroot SCC to the 'default' user in the 'padogrid' project
oc adm policy add-scc-to-user nonroot system:serviceaccount:padogrid:default

4.1. Run PadoGrid

You can run PadoGrid on OpenShift using one of the following options.

  1. Using padogrid.yaml:
oc apply -f https://raw.githubusercontent.com/padogrid/padogrid/develop/padogrid-deployment/src/main/resources/common/k8s/padogrid.yaml
  1. Using container image:
# oc
oc run padogrid --image=docker.io/padogrid/padogrid

4.2. Login to PadoGrid

You can login to PadoGrid using one of the following options.

  1. To login to PadoGrid via JupyerLab:
oc expose svc padogrid --port 8888

View the exposed route:

oc get route

Output:

NAME       HOST/PORT                            PATH   SERVICES   PORT   TERMINATION   WILDCARD
padogrid   padogrid-padogrid.apps-crc.testing          padogrid   8888                 None

The HOST/PORT column shows the JupyterLab address.

  1. To login directly to the PadoGrid pod:
oc get pods

Output:

NAME                        READY   STATUS    RESTARTS   AGE
padogrid-556797b799-57cg4   1/1     Running   0          4m4s

Login:

# Login to padogrid pod
oc exec -it padogrid-556797b799-57cg4 -- bash

4.3. Delete PadoGrid

You can delete PadoGrid using one of the following options.

  1. To delete the PadoGrid deployment via padogrid.yaml:
kubectl apply -f https://raw.githubusercontent.com/padogrid/padogrid/develop/padogrid-deployment/src/main/resources/common/k8s/padogrid.yaml
  1. To delete the PadoGrid pod:
# kubctl
kubectl delete pod paodgrid

# oc
oc delete pod padogrid

5. Deploying PadoGrid on OpenShift

PadoGrid runs using the fixed user, padogrid. If you deploy PadoGrid using oc new-app, then you would need to create a service account to allow the container to use the fixed userid as shown in the example below.

  1. Deploy Padogrid:
oc new-app padogrid/padogrid
oc get deployment

Output:

NAME       READY   UP-TO-DATE   AVAILABLE   AGE
padogrid   1/1     1            1           36m
  1. Add a service account:
# Create a new service account:
oc create serviceaccount myserviceaccount

# Modify the deployment configuration for the application to use the new service account.
oc patch deployment/padogrid --patch \
   '{"spec":{"template":{"spec":{"serviceAccountName": "myserviceaccount"}}}}'

# Add the myserviceacount service account to the anyuid SCC to run using
#    a fixed userid in the container.
oc adm policy add-scc-to-user anyuid -z myserviceaccount
  1. Redeploy PadoGrid:
oc rollout restart deployment/padogrid
oc get pods

Output:

NAME                        READY   STATUS    RESTARTS   AGE
padogrid-766755f547-cl24k   1/1     Running   0          29m
  1. With the service account added, when you login to the PadoGrid pod, your userid will be padogrid.
oc exec -it padogrid-766755f547-cl24k -- bash

# From the padogrid pod:
whami

Output:

padogrid

6. Ingesting Data

If you have a Hazelcast cluster running in the same namespace (project) as PadoGrid, then you can run the perf_test app as follows.

export NAMESPACE=<Kubernetes namespace/project>
export HAZELCAST_SERVICE=<Hazelcast Kubernetes service>
# Default cluster name is "dev".
export HAZELCAST_CLUSTER_NAME=<cluster name>
create_app
cd_app perf_test; cd bin_sh
./test_ingestion -run

◀️ PadoGrid-Pods :link: Docker ▶️