Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

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

October 15, 2020
James Falkner
Related topics:
SecurityJavaArtificial intelligenceKubernetesQuarkus

    The release of Red Hat Data Grid 8.1 offers new features for securing applications deployed on Red Hat OpenShift. Naturally, I wanted to check them out for Quarkus. Using the Quarkus Data Grid extension made that easy to do.

    Data Grid is an in-memory, distributed, NoSQL datastore solution based on Infinispan. Since it manages your data, Data Grid should be as secure as possible. For this reason, it uses a default property realm that requires HTTPS and automatically enforces user authentication on remote endpoints. As an additional layer of security on OpenShift, Data Grid presents certificates signed by the OpenShift Service Signer. In practice, this means that Data Grid is as secure as possible out of the box, requiring encrypted connections and authentication from the first request. Data Grid generates a default set of credentials (which, of course, you can override), but unauthenticated access is denied.

    In this article, I show you how to configure a Quarkus application with Data Grid and deploy it on OpenShift.

    Getting started with Data Grid 8.1

    OpenShift's Data Grid Operator makes it easy to deploy Data Grid in a variety of configurations. The Operator also manages Data Grid's security, storage, upgrade, and logging capabilities. Once you've deployed the Data Grid Operator from the OpenShift OperatorHub, it exposes custom resources (called Infinispan Cluster and Infinispan Cache), which Data Grid uses to provision the caches on an existing cluster.

    In the next sections, we'll deploy a three-node Data Grid cluster, configure a sample Quarkus application to securely connect to Data Grid, then deploy and verify our application on OpenShift.

    Deploy a three-node Data Grid cluster

    To deploy a three-node Data Grid cluster, just add the following custom resource to any OpenShift project (note that my project name for this example is dgdemo):

    apiVersion: infinispan.org/v1
    kind: Infinispan
    metadata:
      name: example-infinispan
      namespace: dgdemo
    spec:
      replicas: 3
      expose:
        type: LoadBalancer
    

    After you've added the custom resource, Data Grid deploys the nodes and sets up the networking. The setup includes a Kubernetes service that resolves to the cluster members. The Kubernetes service support HTTPS using the OpenShift Service Signer.

    Using signed certificates to connect Data Grid and Quarkus

    When your applications access Data Grid, they'll do so through the Kubernetes service, so they will be subject to its certificates. It's possible to use an annotated ConfigMap to simplify the process of injecting these certificates into a pod. However, because we're using Java, we'll need the certificates in a format that Java applications can consume, so JKS or PKCS12.

    We'll use the signed certificates when our Quarkus application initiates a TLS handshake with Data Grid. We need to manually extract and convert them to JKS format before mounting them in our application's running pods.

    Extract the certificates

    To generate the Java keystore, we first need to extract the certificates from the OpenShift Service Signer's certificate authority. We can then use the JDK's keytool to generate the keystore file. Using the oc, openssl, and keytool command-line interfaces (CLIs), enter the following:

    $ oc get secrets/signing-key -n openshift-service-ca -o template='{{index .data "tls.crt"}}' | openssl base64 -d -A > /tmp/server.crt
    $ keytool -importcert -keystore /tmp/server.jks -storepass password -file /tmp/server.crt -trustcacerts -noprompt
    

    This series of commands grabs the Base64-encoded certificate content, then uses the keytool format to a file /tmp/server.jks with the passphrase: password.

    Create a secret

    Next, we need to consume the certificates in our Quarkus application namespace (dgdemo). We'll create a secret, clientcerts, whose contents are set to the contents of our certificate file. Here's the command to do it:

    $ oc create secret generic clientcerts -n dgdemo --from-file=clientcerts=/tmp/server.jks
    

    Configure the Quarkus application

    We've created our secret named clientcerts and set its value as the content of our server.jks. Next, we need to configure our Quarkus application to mount the secret at a given mount point, read the contents, and use the certificates whenever it connects to Data Grid.

    I created a sample application for this part of the demonstration. Open it, and you'll see that I've already installed both the infinispan-client and openshift extensions. This is a simple application that responds to the GET /infinispan endpoint with the value of the Data Grid entry under the key of hello. As you might guess, the entry is "Hello World, Infinispan is up!"

    You can find the configuration in src/main/resources/application.properties. I'll also show it here:

    # The DNS name and port of the Service fronting Data Grid
    quarkus.infinispan-client.server-list=example-infinispan:11222
    
    # Auth info, including server name and super secret password for the developer
    quarkus.infinispan-client.auth-server-name=example-infinispan
    quarkus.infinispan-client.auth-realm=default
    
    # DG user credentials. You'll need to change these
    quarkus.infinispan-client.auth-username=developer
    quarkus.infinispan-client.auth-password=I@TIR7awMPvYATGl
    quarkus.infinispan-client.sasl-mechanism=PLAIN
    quarkus.infinispan-client.client-intelligence=BASIC
    
    # Where the application can read the trust store from when it runs
    quarkus.infinispan-client.trust-store=/mnt/clientcerts
    
    # trust store password
    quarkus.infinispan-client.trust-store-password=password
    
    # trust store type
    quarkus.infinispan-client.trust-store-type=jks
    
    # which secret to mount and where to mount it
    quarkus.openshift.mounts.my-volume.path=/mnt
    quarkus.openshift.secret-volumes.my-volume.secret-name=clientcerts
    
    # instructs quarkus to build and deploy to kubernetes/openshift, and
    # create an ingress Route, and to trust the Kubernetes API since we're using self-signed,
    quarkus.container-image.build=true
    quarkus.kubernetes.deploy=true
    quarkus.openshift.expose=true
    quarkus.kubernetes-client.trust-certs=true
    quarkus.kubernetes.deployment-target=openshift
    

    Get the secret

    Our application will use the values of quarkus.infinispan-client.auth-username and quarkus.infinispan-client.auth-password as the credentials to talk to Data Grid. Enter the following command to discover the autogenerated username of developer and its associated password:

    $ oc get secret/example-infinispan-generated-secret -o template='{{index .data "identities.yaml"}}' | openssl base64 -d -A
    

    Take the username and password and insert them into your theapplication.propeties file.

    With all of that in place, we're ready to deploy!

    Deploy to OpenShift

    All we have to do now is log into OpenShift and switch to our demo project, then build and deploy. In this case, the Quarkus OpenShift plugin does most of the work for us; we just enter:

    $ oc project dgdemo
    $ mvn clean package
    

    It will take a minute or so to build and deploy. After the build is done, the application should deploy and show up in the OpenShift developer console, as shown in Figure 1.

    The OpenShift developer console shows the Quarkus application and its build status.
    Data Grid Quarkus app in OpenShift Developer Console
    Figure 1: The Quarkus application with Data Grid in the OpenShift developer console.

    Test the application

    Before we test the application, let's take a look at its log file:

    $ oc logs -n dgdemo dc/infinispan-client-quickstart
    __  ____  __  _____   ___  __ ____  ______
     --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
     -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
    --\___\_\____/_/ |_/_/|_/_/|_|\____/___/
    2020-10-01 22:53:32,096 INFO  [org.inf.SECURITY] (HotRod-client-async-pool-1-1) ISPN000947: Using Java SSL Provider
    2020-10-01 22:53:37,612 INFO  [org.inf.HOTROD] (main) ISPN004021: Infinispan version: Infinispan 'Corona Extra' 11.0.3.Final
    2020-10-01 22:53:37,863 INFO  [InfinispanClientApp] (main) Create or get cache named mycache with the default configuration
    2020-10-01 22:53:37,909 INFO  [io.quarkus] (main) infinispan-client-quickstart 1.0-SNAPSHOT on JVM (powered by Quarkus 1.8.0.Final) started in 1.676s. Listening on: http://0.0.0.0:8080
    2020-10-01 22:53:37,909 INFO  [io.quarkus] (main) Profile prod activated.
    2020-10-01 22:53:37,909 INFO  [io.quarkus] (main) Installed features: [cdi, infinispan-client, kubernetes, resteasy]
    

    That looks healthy. Now, let's test it with curl:

    $ curl http://$(oc get route -n dgdemo infinispan-client-quickstart -o jsonpath="{.spec.host}")/infinispan
    Hello World, Infinispan is up!
    

    Yes, we got the expected value showing that the connection was successful.

    Verify the value in the Data Grid 8.1 web console

    As our final step, let's use the new Data Grid 8.1 web console to verify the value. To get to it, you can discover the URL with:

    $ echo http://$(oc get service/example-infinispan-external
     jsonpath='{.status.loadBalancer.ingress[0].hostname}'):11222
    

    This command outputs the URL, which you can then copy and paste into your browser. You can use the credentials that you specified earlier to log in. Then, find the mycache cache, and search for entries using the key hello, as shown in Figure 2.

    The Data Grid web console shows the The application's key and value.
    Data Grid Web Console
    Figure 2: The application's key and value in the new Data Grid web console.

    Wrap up

    Red Hat Data Grid delivers many features for hybrid cloud deployments on OpenShift. In this article, you've seen how to use a default configuration to securely connect your Quarkus applications to Data Grid and deploy them on OpenShift.

    While the default configuration is considered to be as secure as possible, there are many other features to explore. Examples include cross-data center asynchronous replication on OpenShift and autoscaling to dynamically expand and contract clusters sizes.

    Whether you choose the default configuration or need to explore additional security features, Red Hat Data Grid is a valuable solution for large datasets across large clouds.

    Last updated: October 14, 2020

    Recent Posts

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    • Best Practice Configuration and Tuning for Linux and Windows VMs

    • Red Hat UBI 8 builders have been promoted to the Paketo Buildpacks organization

    • Using eBPF in Red Hat products

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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