Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Accessing Red Hat Data Grid in Red Hat OpenShift Container Platform 4

July 18, 2024
Francisco De Melo Junior
Related topics:
ContainersDatabasesGoHelmJavaJava MicroservicesOperators
Related products:
Red Hat Data GridRed Hat OpenShift Container Platform

Share:

    Red Hat Data Grid is a stable product for in-memory distributing caching solutions. In Red Hat OpenShift Container Platform, Data Grid can be installed via Data Grid Operator or Helm Charts can be used to deploy Data Grid 8 and have containers deployed running Data Grid. Those pods can then join together in a cluster—therefore having clustering capabilities.

    Given the deployment of the Data Grid cluster as described above and with the pods deployed, the next step is to access the Data Grid cluster. 

    When accessing the clustering within the OpenShift Container Platform cluster—i.e., when the application access is done inside OpenShift Container Platform—the communication can be via internal service. However, if the application is outside OpenShift Container Platform, Data Grid must expose a service or route to enable the connection, which can be done in a few ways: via Route,  LoadBalancer, and NodePort. 

    Below, these options are described in the context of Data Grid Operator and Data Grid Helm charts, respectively. Parts of this article are derived from this solution: Data Grid 8 Operator Exposition Route vs NodePort vs LoadBalancer in OpenShift 4 

    Application inside OpenShift Container Platform

    The internal service can be used if a hotrod application is deployed in OpenShift Container Platform, either in the same namespace or in another namespace. The internal service won't be accessible outside the OpenShift Container Platform environment.

    The options are either to deploy with the automatically created certificate, use a custom certificate, or do not use the certificate.

    Example:

    When deploying any trivial clustering the internal service will be created:

    $ oc get svc
    NAME                                             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)     AGE
    example-infinispan                               ClusterIP   172.??.???.???   <none>        11222/TCP   7m28s
    example-infinispan-admin                         ClusterIP   None             <none>        11223/TCP   7m28s
    example-infinispan-ping                          ClusterIP   None             <none>        8888/TCP    7m28s
    infinispan-operator-controller-manager-service   ClusterIP   172.??.???.???   <none>        443/TCP     22m

    And then it can be fetched such as:

     oc get service infinispan-test -o go-template --template='{{.metadata.name}}.{{.metadata.namespace}}.svc.cluster.local{{println}}'

    For more details and an excellent example see this blog post, by Alexander Barbosa. 

    Application outside OpenShift Container Platform

    Data Grid Operator setup

    Given a hotrod application deployed outside OpenShift Container Platform, the Data Grid must be exposed in the Infinispan CustomResource, and can be of three types: Route, (service type) LoadBalancer, and NodePort. 

    Route

    By setting Data Grid Infinispan CR to expose the type Route, on the spec.expose.Type: Route a Route will be created and another service to interact with the application: 

    Example:

    kind: Infinispan
    ...
    spec:
    ...
      expose:
        type: Route
      service:
        type: DataGrid

    Given a route is created, the user can get this route via oc get route:

    $ oc get route
    NAME                        HOST/PORT                                                                                 PATH   SERVICES           PORT    TERMINATION   WILDCARD
    dg-cluster-route-external   example.openshift.org          dg-cluster-route   11222   passthrough   None

    LoadBalancer

    By setting Data Gridto expose the type Route, on the spec.expose.Type: LoadBalancer a service of type LoadBalancer is created. This is a service with a type LoadBalancer, and the OpenShift Container Platform infrastructure must provide the LoadBalancer, as not all providers will have this feature.

    Example:

    kind: Infinispan
    ...
    spec:
    ...
      expose:
        type: LoadBalancer
      service:
        type: DataGrid

    Given a service is created, the user can get the route via oc get svc:

    $ oc get svc
    NAME                     TYPE           CLUSTER-IP       EXTERNAL-IP                                                              PORT(S)           AGE
    dg-cluster-lb            ClusterIP      127.0.0.1   <none>                                                                   11222/TCP         30m
    dg-cluster-lb-admin      ClusterIP      127.0.0.1    <none>                                                                   11223/TCP         30m
    dg-cluster-lb-external   LoadBalancer   127.0.0.1     example.amazonaws.com   11222:30436/TCP   30m
    dg-cluster-lb-ping       ClusterIP      None             <none>                                                                   8888/TCP          30m

    In case the provider does not have that feature, e.g., in case you are running OpenShift on bare metal that does not have a LoadBalancer implementation available, the following error message will appear:

    LoadBalancer expose type is not supported on the target platform

    NodePort

    By setting Data Grid to expose the type Route, on the spec.expose.Type: NodePort a service of type NodePort is created.

    Example:

    kind: Infinispan
    ...
    spec:
    ...
      expose:
        type: NodePort
      service:
        type: DataGrid

    Given a service is created, the user can get the route via oc get svc:

    $ oc get svc
    NAME                     TYPE           CLUSTER-IP       EXTERNAL-IP                                                              PORT(S)           AGE
    dg-cluster-lb            ClusterIP      127.0.0.1   <none>                                                                   11222/TCP         30m
    dg-cluster-lb-admin      ClusterIP      127.0.0.1    <none>                                                                   11223/TCP         30m
    dg-cluster-lb-external   NodePort   127.0.0.1     example.amazonaws.com   11222:30436/TCP   30m
    dg-cluster-lb-ping       ClusterIP      None             <none>                                                                   8888/TCP          30m

    Data Grid Helm Charts

    For Data Grid the options are the same: deploy.expose.type.

    Summary

    Below I summarized in the table below the comparison of each one.

    Comparison Table

    Table 1: Comparison of expose
    Type of exposeHow to set it up in Data Grid OperatorHow to set it up in Data Grid Helm ChartsImplications
    NodePortspec.expose.Type: NodePortdeploy.expose.type NodePortData Grid Operator will create a service of type NodePort
    LoadBalancerspec.expose.Type: LoadBalancerdeploy.expose.type LoadBalancerData Grid Operator will create a service of type LoadBalancer
    Routespec.expose.Type: Routedeploy.expose.type RouteData Grid Operator will create a service of type ClusterIP and a HaProxy's Route

    Conclusion

    Above I described the approaches to access Data Grid deployed in OpenShift Container Platform 4, which include NodePort, LoadBalancer, and Routing exposition. Each method provides some feature/functionality but has its disadvantages as well.

    The usage of Route for example, although very simple in OpenShift Container Platform 4 and provides load balancing, will require the limitations/boundaries of OpenShift Container Platform 4's Ingress controller and therefore HaProxy to be respected.

    This is important because, in scenarios of externalization for Data Grid, HaProxy might overwrite the cookies that are created by an application externalizing to Data Grid given its default template the original cookie is not preserved. Regarding HaProxy configurations, it is usually configured via annotations, and not all features have annotations ready available. For haproxy-config.template customization, this is currently not possible in OpenShift Container Platform 4, but perhaps it will be added later.

    Moreover, the fact that HaProxy is the middleman, has implications in terms of settings but also SNI validations, where although an OpenShift Container Platform 4 route created by Data Grid is passthrough, the Route will impose SNI and there is a default cert being used so encryption settings might need to be considered.

    On the other hand, the usage of service type LoadBalancer does not provide full load balancing capabilities such as HaProxy, but it requires the underneath OpenShift Container Platform infrastructure to provide this feature. NodePort is basic and does not provide load balancing to get external traffic directly to the Data Grid Cluster. 

    Finally, in terms of deployment, both Data Grid Operator and Helm Charts provide an easy approach to deploy the specific Ingress method at the choice of the user with a simple setting: 

    • Infinispan Custom Resource in the case of DG Operator deployment
    • The values YAML in the case of Helm Charts deployment.

    Additional resources

    To learn more about Data Grid 8.4 see its main page. And for Data Grid Operator see its main guide. Finally, Data Grid 8 Operator Exposition Route vs NodePort vs LoadBalancer in OpenShift 4 brings other interesting topics about externalization using Route vs LoadBalancer vs NodePort. 

    For any other specific inquiries, please open a case with Red Hat support. Our global team of experts can help you with any issues.

    Special thanks to Alexander Barbosa for his input and contributions throughout those years in Data Grid.

    Related Posts

    • Securely connect Quarkus and Red Hat Data Grid on Red Hat OpenShift

    • Using Red Hat Data Grid to power a multi-cloud real-time game

    • Build embedded cache clusters with Quarkus and Red Hat Data Grid

    • Red Hat Data Grid on Three Clouds (the details behind the demo)

    Recent Posts

    • How to integrate vLLM inference into your macOS and iOS apps

    • How Insights events enhance system life cycle management

    • Meet the Red Hat Node.js team at PowerUP 2025

    • How to use pipelines for AI/ML automation at the edge

    • What's new in network observability 1.8

    What’s up next?

    Red Hat Data Grid is an in-memory, distributed, NoSQL datastore solution that boosts application performance, provides greater deployment flexibility, and minimizes the overhead of standing up new applications. Download the Cache configuration in Red Hat Data Grid cheat sheet for a quick reference for creating and configuring Data Grid caches, complete with configuration examples.

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue

    OSZAR »