This is a cache of https://docs.openshift.com/container-platform/4.12/virt/virtual_machines/virt-managing-configmaps-secrets-service-accounts.html. It is a snapshot of the page at 2024-11-22T13:31:08.451+0000.
Managing config maps, <strong>secret</strong>s, and service accounts in virtual machines - Virtual machines | Virtualization | OpenShift Container Platform 4.12
×

You can use secrets, config maps, and service accounts to pass configuration data to virtual machines. For example, you can:

  • Give a virtual machine access to a service that requires credentials by adding a secret to the virtual machine.

  • Store non-confidential configuration data in a config map so that a pod or another object can consume the data.

  • Allow a component to access the API server by associating a service account with that component.

OpenShift Virtualization exposes secrets, config maps, and service accounts as virtual machine disks so that you can use them across platforms without additional overhead.

Adding a secret, config map, or service account to a virtual machine

You add a secret, config map, or service account to a virtual machine by using the OpenShift Container Platform web console.

These resources are added to the virtual machine as disks. You then mount the secret, config map, or service account as you would mount any other disk.

If the virtual machine is running, changes will not take effect until you restart the virtual machine. The newly added resources are marked as pending changes for both the Environment and Disks tab in the Pending Changes banner at the top of the page.

Prerequisites
  • The secret, config map, or service account that you want to add must exist in the same namespace as the target virtual machine.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select a virtual machine to open the VirtualMachine details page.

  3. In the Environment tab, click Add Config Map, secret or Service Account.

  4. Click Select a resource and select a resource from the list. A six character serial number is automatically generated for the selected resource.

  5. Optional: Click Reload to revert the environment to its last saved state.

  6. Click Save.

Verification
  1. On the VirtualMachine details page, click the Disks tab and verify that the secret, config map, or service account is included in the list of disks.

  2. Restart the virtual machine by clicking ActionsRestart.

You can now mount the secret, config map, or service account as you would mount any other disk.

Removing a secret, config map, or service account from a virtual machine

Remove a secret, config map, or service account from a virtual machine by using the OpenShift Container Platform web console.

Prerequisites
  • You must have at least one secret, config map, or service account that is attached to a virtual machine.

Procedure
  1. Click VirtualizationVirtualMachines from the side menu.

  2. Select a virtual machine to open the VirtualMachine details page.

  3. Click the Environment tab.

  4. Find the item that you want to delete in the list, and click Remove delete on the right side of the item.

  5. Click Save.

You can reset the form to the last saved state by clicking Reload.

Verification
  1. On the VirtualMachine details page, click the Disks tab.

  2. Check to ensure that the secret, config map, or service account that you removed is no longer included in the list of disks.