This is a cache of https://docs.openshift.com/container-platform/4.5/virt/virtual_machines/virt-managing-configmaps-secrets-service-accounts.html. It is a snapshot of the page at 2024-11-21T00:29:15.113+0000.
Managing ConfigMaps, <strong>secrets</strong>, and service accounts in virtual machines - Virtual machines | OpenShift Virtualization | OpenShift Container Platform 4.5
×

You can use secrets, ConfigMaps, 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 ConfigMap 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, ConfigMaps, and service accounts as virtual machine disks so that you can use them across platforms without additional overhead.

Adding a secret, ConfigMap, or service account to a virtual machine

Add a secret, ConfigMap, or service account to a virtual machine by using the OpenShift Container Platform web console.

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

  • The virtual machine must be powered off.

Procedure
  1. From the side menu, click Virtualization.

  2. Click the Virtual Machine tab.

  3. Select a virtual machine to open its Virtual Machine Overview page.

  4. Click the Environment tab.

  5. Click Select a resource and select a secret, ConfigMap, or service account from the list.

  6. Click Save.

  7. Optional. Add another object by clicking Add Config Map, Secret or Service Account.

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

Verification
  1. From the Virtual Machine Overview page, click the Disks tab.

  2. Check to ensure that the secret, ConfigMap, or service account is included in the list of disks.

  3. Optional. Start the virtual machine by clicking ActionsStart Virtual Machine. You can now mount the secret, ConfigMap, or service account as you would mount any other disk.

Removing a secret, ConfigMap, or service account from a virtual machine

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

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

  • The virtual machine must be powered off.

Procedure
  1. From the side menu, click Virtualization.

  2. Click the Virtual Machine tab.

  3. Select a virtual machine to open its Virtual Machine Overview page.

  4. Click the Environment tab.

  5. Find the item that you want to delete in the list, and click the Delete button delete on the right side of the item.

  6. Click Save.

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

Verification
  1. From the Virtual Machine Overview page, click the Disks tab.

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