Experience Red Hat OpenShift Virtualization: Advanced operations and automation

Red Hat® OpenShift® Virtualization allows organizations to run and deploy new and existing virtual machines on a modernized platform. Learn how to manage your environment and perform critical operational tasks often required of virtual machine administrators from day-2 onward.

This learning path is for operations teams or system administrators

Developers may want to check out Foundations of OpenShift on developers.redhat.com.

Get started on developers.redhat.com

Security and compliance

20 mins

The Mega-Sale was a success, but now a critical security audit is looming. We need to demonstrate strict adherence to industry compliance standards for all our virtualized workloads. Our challenge is to ensure a unified approach to security across both VMs and containers. In this module, we will be tasked with scanning our infrastructure with the Red Hat® OpenShift® Compliance Operator and remediating any reported vulnerabilities to ensure that our cluster meets our strict security standards. We will also configure distinct user accounts and access roles to be used by the security auditors that only need limited access to our virtualization infrastructure.

Prerequisites:

  • A computer with a web browser and internet access
    • A Chromium-based browser is preferred: these are recommended, as some copy/paste functions don’t work in Firefox for the time being
  • (Recommended for non-US users) Familiarity with special characters in other countries’ keyboard layouts, since the remote access console uses the US keyboard by default

In this resource, you will:

  • Remediate reported vulnerabilities to meet security standards
  • Configure distinct user accounts and access roles

Scan infrastructure with the OpenShift Compliance Operator

This section of our lab will focus on making use of the OpenShift Compliance Operator to configure security scans in your OpenShift cluster. The compliance operator can help ensure that the hosts in your OpenShift environment meet specific security standards, and are deployed to meet those standards.

Note: In our lab environment we will only be scanning and remediating our worker nodes, as it is a virtual hosted environment and doing so with the control plane can cause the cluster to become unstable.

01 compliance overview

Figure 1. Compliance overview

  1. Select Operators and then Installed Operators from the left side navigation menu. Confirm that you have selected All Projects and select the Compliance Operator.

02 compliance operator

Figure 2. Compliance operator

 

  1. This takes you to the Operator details page. Use the horizontal scrollbar to move across and locate the ScanSetting tab.

03 compliance details

Figure 3. Compliance details

 

  1. Click the Create ScanSetting button.

04 scansetting button

Figure 4. Create ScanSetting button

 

  1. On the Create ScanSetting page, set the name of the scan to scan01. Then click the YAML view radio button.

05 create scansetting

Figure 5. Create Scansetting

 

  1. In the ScanSetting YAML details, make note of the following values that are set by default:
    • The autoApplyRemediations field is set to false.
    • The roles to be scanned by default include entries for master and worker nodes.
    • The name field is set to scan01 which you entered on the form view.
  2. Delete the entry for master to ensure we don’t scan or remediate control plane nodes.
  3. Click the Create button to create this simple scansetting definition that will only scan worker nodes.

06 scansetting details

Figure 6. ScanSetting details

 

  1. Now click on the Profile tab where there are a number of pre-defined scanning profiles.
  2. In the search box, type rhcos4 and locate the FedRamp moderate profile rhcos4-moderate in the list.

07 profiles detail

Figure 7. Profiles detail

 

  1. Click on rhcos4-moderate and then on the YAML. Scroll down the output to browse the rules that are enforced as a part of this scan. A quick glimpse at the side panel shows that there are quite a few of them.

08 rhcos4 mod rules

Figure 8. RHCOS4-Moderate rules

 

  1. When you are done reviewing the rules, return to the Operator details page by clicking your browser’s back button twice.
  2. Next we want to create a ScanSettingBinding, pairing a Profile with our ScanSetting definition we created. We do this by navigating to the Scan Setting Binding tab, and clicking the Create ScanSettingBinding button.

09 create scansettingbinding

Figure 9. Create ScanSettingBinding

 

  1. In the ScanSettingBinding YAML details, let us make a few changes:
    • The metadata.name value should be set to fedramp01
    • The settingsRef.name field is set to scan01 which we created earlier.
  2. Click the Create button.

    Note: The profile is set to rhcos4-moderate (the fedramp moderate profile) by default.

 

10 scansettingbinding details

Figure 10. ScanSettingBinding details

 

  1. After the ScanSettingBinding is created, the fedramp01 scan will be run automatically. You can view this on the Compliance Suite tab.

11 compliance suite

Figure 11. Compliance Suite

 

  1. This Compliance Suite runs the defined scans against the specified nodes, in our case the worker nodes defined in scan01.
  2. For more detailed information you can click on the Compliance Scan tab. There you can watch as the scan proceeds through the steps of RUNNING, AGGREGATING, and DONE.

12 compliance scan

Figure 12. Compliance Scan

 

  1. Once the scan completes (3-5 minutes on average) you can check your results by clicking on the ComplianceCheckResult tab. It will list all of the scans that were a part of the compliance suite we chose and their results.
  2. Change the search bar to Label and apply the following labels:
    • compliance.openshift.io/check-status=FAIL
    • compliance.openshift.io/check-severity=high

13 compliance check results

Figure 13. Compliance check results

 

20. Six high-severity checks have a failed status:

ComplianceCheckResultCheck-SeverityCheck-Status
rhcos4-moderate-worker-configure-crypto-policyhighFAIL
rhcos4-moderate-worker-coreos-pti-kernel-argumenthighFAIL
rhcos4-moderate-worker-disable-ctrlaltdel-burstactionhighFAIL
rhcos4-moderate-worker-disable-ctrlaltdel-reboothighFAIL
rhcos4-moderate-worker-enable-fips-modehighFAIL
rhcos4-moderate-worker-no-empty-passwordshighFAIL
Note: This is a table to better organize the view of each failure detected on the scan. You can search for each of these failures manually in the OpenShift console.

Node remediation with the OpenShift Compliance Operator

When it comes to remediation, it can be performed in one of two ways. Automatically, which may seem simple and the easiest way to do it, but can lead to unexpected results. Or manually, which can be tedious, but allows you to canary test each application, and later automate through a tool like GitOps that checks for failures before proceeding.

Note: One example of this is the rhcos4-moderate-worker-enable-fips-mode, which was listed as a high severity, fail status on our previous scan. It cannot be applied unless at install time if FIPS mode is enabled. Attempting to auto-remediate this can lead to issues with your cluster.

In this section, we are going to choose one of our failures from the previous scan and remediate it manually.

  1. Starting from the list above we are going to choose to remediate the following scan result: rhcos4-moderate-worker-coreos-pti-kernel-arguments as required by our audit.

    Note: The rhcos4-moderate-worker-coreos-pti-kernel-argument is required to isolate kernel and userspace page tables to prevent attacks.

    Click on the Compliance Remediation tab, and in the Name search bar type the term pti-kernel to find the suggested remediation for rhcos4-moderate-worker-coreos-pti-kernel-argument. When the result appears, click the three-dot menu on the right, then select Edit ComplianceRemediation from the menu that appears.

14 compliance remediation

Figure 14. Compliance remediation

 

  1. This will launch the ComplianceRemediation details page with a YAML block describing the current status.
  2. Under the spec section you will see that the current apply state is false, and the kernelArugument that will be applied is that pti=on. Under the status section we see that the remediation state is NotApplied.

15 compred details

Figure 15. Compliance remediation details

 

  1. Under the spec section change the apply field to true and click the Save button.

16 compred true

Figure 16. Compliance remediation “true”

 

  1. You will be prompted with a message that lets you know that this is a managed resource. Click the Save button to start the remediation process.

17 managed resource

Figure 17. Managed resource prompt

 

  1. Once applied, a MachineConfig will be generated to provide the remediation, and each node in the cluster will be cordoned, drained, and remediated in sequence.
  2. On the left side menu, click on Compute and Nodes to observe the process.

18 nodes cordoned

Figure 18. Node 3 cordoned

 

  1. You will see a node enter the SchedulingDisabled state to begin its remediation. Click on that node for its Node details page, and notice that the event log shows the node was cordoned to apply the update. You can also see CPU and Memory utilization drop off as the node was successfully drained.

19 node 3 updating

Figure 19. Node 3 Updating

Note: This process can take quite a bit of time to complete depending on how busy the cluster currently is, and how many nodes there are to remediate as they each have to evict pods safely and reboot to apply the update. Also, you may be logged out of the cluster while the pods are being evacuated.
  1. After several minutes the MachineConfig will be applied to each of the worker nodes in our cluster, and we can recheck our Compliance Scan results.
  2. Return to the Compliance Operator configuration by clicking on Operators and Installed Operators in the left side menu.

02 compliance operator

Figure 20. OpenShift Compliance Operator

 

  1. Click on the Compliance Scan tab, where you will see the scan we completed earlier. Click the three-dot menu, and select the option to delete the current scan.

20 delete compliance scan

Figure 21. Delete compliance scan

 

  1. You will be prompted to be sure that you want to delete the current compliance scan. Click the Delete button.

21 delete scan prompt

Figure 22. Delete scan prompt

 

  1. The Compliance Suite object defined earlier will automatically kick off a new scan which you will see appear on your screen.

22 new compliance scan

Figure 23. New compliance scan

 

  1. As before this scan will take a few minutes to complete. Once it is finished, the results can be viewed by clicking on the ComplianceCheckResult tab and then searching for the rhcos4-moderate-worker-coreos-pti-kernel-argument and noticing that its label is now check-status=PASS instead of FAIL.

23 check status pass

Figure 24. Check status pass

 

With the completion of these sections we have created a compliance scan and successfully remediated an identified vulnerability using the OpenShift Compliance Operator.

Configure role-based access controls for cluster roles

One of the notable features that OpenShift is known for compared to vanilla Kubernetes is its rich set of role-based access controls for separate user accounts and cluster roles that define what each user is able to do when logged into the cluster. In this section of the module, we are going to create a read-only account for our auditor and explore the limitations by which they are bound.

  1. Start by clicking on User Management and Users in the left side menu.
  2. You will see the current admin user that you are logged in as listed, and you will see that the identity is provided by the htpasswd_provider:admin authenticator.

24 user list

Figure 25. User list

Note: If no other authentication source has been set up prior and you are logged in as the default kubeadmin account, you will see a wizard here to assist with setting up your first authentication source.

Create a group

  1. Now click on Groups in the left menu, then click the button for Create Group.

25 create group

Figure 26. Create group

 

  1. In the Create Group YAML dialog, set the name of the group to auditor_readonly and add the users auditor1 and auditor2. Click the Create button.

26 create group settings

Figure 27. Create group settings

 

  1. You will be presented with the Group details screen where you can see the two user accounts listed, and we can define permissions by assigning the group a role binding. Click on the RoleBindings menu.

27 group details

Figure 28. Group details

 

  1. After clicking on RoleBindings, click the Create binding button.

28 create binding

Figure 29. Create binding

 

  1. This will bring you to the Create RoleBinding page. On this page, select the following to create a read-only role binding for the auditor, and then click the Create button:
    • Binding type: Cluster-wide role binding
    • Name: cluster_readonly
    • Role name: view

29 role binding details

Figure 30. RoleBinding details

Create the user accounts

  1. With the role binding created, we now need to add our two auditor accounts to our group.
  2. In the left side menu, click Administration and CustomResourceDefinitions and use the search bar to look for the OAuth entry. When you find it, click it.

30 crd oauth

Figure 31. CRDs OAuth

 

  1. This will load the details page for the OAuth custom resource definition. On this page, click on Instances and then click on cluster.

31 oauth instances

Figure 32. OAuth instances

 

  1. On the cluster configuration page you will see where the htpasswd_provider is already currently configured, but there will also be a dropdown menu that has the word Add. You can select another provider from that list. Click and select HTPasswd as the option.

32 add htpass

Figure 33. Add authentication

Note: Notice that in addition to HTPasswd, there are many options that allow you to integrate external authorization and authentication solutions with Red Hat OpenShift, which is perfect for larger enterprises.
  1. You will be presented with a page that allows you to add in an HTPasswd file or supply usernames and hashed credentials for that purpose. Set the name of the identity provider to auditor_login and paste the following syntax into the text box before clicking the Add button.

    auditor1:$apr1$VtSYSShP$CikLVoVy5sobCaHCvuxCv.
    
    auditor2:$apr1$4Vpe3O5u$OhjtFGDNHnl2RWiNnhlhZ0

33 add identity provider

Figure 34. Add identity provider

 

  1. Once added you will be returned to the Cluster OAuth details page and you will now see two identity providers listed, along with a blue notice that OAuth is being reconfigured. Click on the link provided for View authentication conditions for reconfiguration status.

34 oauth reconfig

Figure 35. OAuth reconfiguration

 

  1. You will be brought to a page that shows the progress as the authentication cluster operator is reconfigured. Once all the pods are restarted, the status will change to Available and the message will say All is well.

35 oauth reconfig 2

Figure 36. OAuth reconfiguration progressing

 

36 oauth reconfig 3

Figure 37. OAuth reconfiguration complete

Test the configuration

  1. With the OAuth configuration complete, we can now test our auditor login and the limits of their account.
  2. Log out of OpenShift by clicking on admin at the top, and selecting Log out from the dropdown menu.

37 logout openshift

Figure 38. Log out of OpenShift

 

  1. There is now an option to login with the auditor_login identity provider on the main OpenShift page.

38 login openshift

Figure 39. Log in to OpenShift

 

  1. Click on auditor_login and when presented use the following username and password combination:
    • Username: auditor1
    • Password: auditor1pass!

39 auditor1 login

Figure 40. Auditor 1 login

 

  1. When the auditor logs in with the read-only permissions, they will be able to see only a limited view of the OpenShift console from the Admin perspective.

40 auditor1 admin view

Figure 41. Auditor 1 admin view

 

  1. If the auditor needs to validate our virtual machine environment, they can still access that by clicking on Virtualization and VirtualMachines in the left side menu.
  2. They can see all virtual machines in each project, and their current status.
  3. The auditor can even click on a specific machine and get additional details. In this case, they want to test the database server in the webapp-vms namespace.

41 auditor1 vm view

Figure 42. Auditor 1 VM view

 

  1. Once they are on the VirtualMachine details page, they can see the information about the virtual guest, including its CPU and memory utilization. However, they are prevented from launching the VNC console or manipulating the machine state in any way, as the buttons are greyed out.

42 auditor1 database readonly

Figure 43. Auditor 1 database ReadOnly

 

  1. At your leisure, you may explore the UI and confirm that the Auditor1 account is read-only. When you are finished, proceed to the next module.

 

In this section of our lab we created a limited read-only account with view permissions for the auditors that will be examining our infrastructure.

Summary

In this module we were preparing for our company’s annual security audit. We can tighten our OpenShift Virtualization security by using the Compliance Operator to automate standard-setting scans and applications. We further strengthen this posture by configuring RBAC to limit access to specific individuals.

In the next lesson, we’ll cover advanced networking and security tasks.

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る