This is a cache of https://docs.okd.io/4.9/virt/virtual_machines/virt-managing-configmaps-secrets-service-accounts.html. It is a snapshot of the page at 2024-11-25T00:14:02.725+0000.
Managing config maps, secrets, and <strong>service</strong> accounts in virtual machines - Virtual machines | Virtualization | OKD 4.9
×

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.

OKD 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

Add a secret, config map, or service account to a virtual machine by using the OKD web console.

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 WorkloadsVirtualization from the side menu.

  2. Click the Virtual Machines tab.

  3. Select a virtual machine to open the Virtual Machine Overview screen.

  4. Click the Environment tab.

  5. Click Select a resource and select a secret, config map, or service account from the list. A six character serial number is automatically generated for the selected resource.

  6. Click Save.

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

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

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

  3. 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.

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

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

  3. Optional. Choose the appropriate method to apply your changes:

    1. If the virtual machine is running, restart the virtual machine by clicking ActionsRestart Virtual Machine.

    2. If the virtual machine is stopped, start the virtual machine by clicking ActionsStart Virtual Machine.

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 OKD 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 WorkloadsVirtualization from the side menu.

  2. Click the Virtual Machines tab.

  3. Select a virtual machine to open the Virtual Machine Overview screen.

  4. Click the Environment tab.

  5. Find the item that you want to delete in the list, and click Remove 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, config map, or service account that you removed is no longer included in the list of disks.