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

Configure Cryostat RBAC mapping in Cryostat Operator 2.2.0

December 15, 2022
Thuan Vo
Related topics:
JavaKubernetes
Related products:
Red Hat build of CryostatRed Hat OpenShift Container Platform

Share:

    Cryostat is a container-native JVM application that provides a secure API for profiling and monitoring containers with JDK Flight Recorder (JFR). When deployed on Kubernetes or the Red Hat OpenShift Container Platform, Cryostat uses a permission configuration that maps Kubernetes resources to Cryostat-managed resources to authorize users to perform certain actions, such as creating a recording or viewing discovered targets.

    Table 1 outlines definitions that represent Cryostat-managed resources:

    Table 1. Cryostat-managed resource definitions
    Resource Definition
    CERTIFICATE SSL certificates that connect to JVM applications with enabled encryption.
    CREDENTIALS Stored credentials for targets with JMX enabled authentication.
    RECORDING Recordings created for JVM applications.
    REPORT Report content generated from recordings.
    RULE Automated rules that start recordings on matching targets as they become available to Cryostat in a non-interactive way.
    TARGET Discovered JVM applications to monitor.
    TEMPLATE Event templates to configure recordings.

    By default, Cryostat sets the following role-based access control (RBAC) mapping configuration:

    TARGET=pods,services
    RECORDING=pods,pods/exec,cryostats.operator.cryostat.io
    CERTIFICATE=pods,cryostats.operator.cryostat.io
    CREDENTIALS=pods,cryostats.operator.cryostat.io
    

    Note: Cryostat-managed resources (i.e., those on the left side) that are not specified are implicitly granted full access.

    However, a single set of mappings does not always fit all. For example, you might want to use a custom resource in this mapping. Therefore, since Cryostat Operator 2.2.0, we allow this mapping to be configurable via the Cryostat custom resource.

    Prerequisites

    To get started, you will need to install Cryostat Operator 2.2.0 on an OpenShift cluster. These steps outlined in this article assume a local OpenShift cluster with Red Hat OpenShift Local (formerly Red Hat CodeReady Containers).

    Step 1: Define a ConfigMap with permission mappings

    To set up custom mapping, the user must define a ConfigMap that is compatible with the defaults above. For example, create a ConfigMap as follows:

    $ cat <<EOF | oc apply -f - 
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: auth-properties
    data:  
      auth.properties: |
        TARGET=pods,deployments.apps
        RECORDING=pods,pods/exec
        CERTIFICATE=deployments.apps,pods,cryostats.operator.cryostat.io
        CREDENTIALS=cryostats.operator.cryostat.io
    EOF
    

    Note: Using a Secret in mapping can fail with access denied due to security protection against escalations. Find more details about this issue here.

    Step 2: Define a ClusterRole for OAuth token scope

    If a custom mapping is specified, a ClusterRole must exist and should contain permissions for all Kubernetes objects listed in custom permission mapping. For example, define the manifest auth_clusterrole.yml:

    $ cat <<EOF | oc apply -f -
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
     name: additional-oauth-client
    rules:
    - apiGroups:
      - operator.cryostat.io
      resources:
      - cryostats
      verbs:
      - create
      - patch
      - delete
      - get
    - apiGroups:
      - ""
      resources:
      - pods
      - pods/exec
      verbs:
      - create
      - patch
      - delete
      - get
    - apiGroups:
      - apps
      resources:
      - deployments
      verbs:
      - create
      - patch
      - delete
      - get
    EOF

    Step 3: Configure Cryostat custom resource

    The property spec.authProperties of the Cryostat custom resource can then be set to configure Cryostat to use this mapping instead of the default ones.

    apiVersion: operator.cryostat.io/v1beta1
    kind: Cryostat
    metadata:
      name: cryostat-sample
    spec:
      authProperties:
        configMapName: auth-properties
        filename: auth.properties
        clusterRoleName: oauth-cluster-role
    

    You can also do this on the OpenShift console. Open the Advanced Configuration section (Figure 1).

    Screenshot showing the Authorization Properties options for Cryostat containers.
    Figure 1: Authorization Properties options for Cryostat containers.

    Choose the corresponding ConfigMap and ClusterRole, and enter the key of the ConfigMap that holds the content of the authorization properties (Figure 2).

    Screenshot showing the authorization properties options.
    Figure 2: Set authorization properties options.

    Step 4: Log into the Cryostat web console

    Once the Cryostat pod is up, access the Cryostat web console via Application URL status. You will be redirected to the OpenShift login page (Figure 3).

    Screenshot showing the Cryostat web console log in screen.
    Figure 3: Visit the Cryostat web console and log in.

    Step 5: Check and accept requested permissions

    Enter your credentials and you will be asked to delegate specific permissions of your user to generate an access token. Notice now we have another role that defines additional requested rules at the bottom (Figure 4).

    Screenshot showing how to check and accept permission requests.
    Figure 4: Check and accept permission requests.

    Accept and you will be successfully logged in Figure 5). Keep in mind that actions in the Cryostat web console are still subject to the permissions the access token has, and might be denied if these are insufficient.

    Screenshot showing a successful login.
    Figure 5: Successfully logged in.

    Important: If the mapping is updated, Cryostat must be manually restarted—in other words, you must roll out a new deployment.

    Summary

    In Cryostat Operator 2.2.0 and later, you can configure permission mapping with a Cryostat custom resource. This requires a ConfigMap that holds these properties and a ClusterRole that defines appropriate access to specified Kubernetes resources. In this way, you can control the access level available to the Cryostat web console with your own settings. Note that updating to this mapping requires a manual restart of the Cryostat instance.

    Last updated: November 17, 2023

    Related Posts

    • Install the Cryostat Operator on Kubernetes from OperatorHub.io

    • How to log into Cryostat 2.1 on OpenShift: SSO for all

    • Cryostat 2.2 is released with enhanced Java recording features

    • Cryostat 2.2's new JMX credentials keyring

    Recent Posts

    • Why Models-as-a-Service architecture is ideal for AI models

    • How to run MicroShift as a container using MINC

    • OpenShift 4.19 brings a unified console for developers and admins

    • 3 steps to secure network segmentation with Ansible and AWS

    • Integrate vLLM inference on macOS/iOS using OpenAI APIs

    What’s up next?

    book cover

    The microservice architectural approach is more than just about technology: It reaches into the foundation of your organization to allow you to build truly scalable, adaptive, complex systems that help a business adapt to rapidly changing competitive markets. In Microservices for Java Developers, you'll get a hands-on introduction to frameworks and containers through a handful of familiar patterns.

    Get the free e-book
    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