7.8. Managing ConfigMaps, secrets, and service accounts in virtual machines
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.
7.8.1. 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
- From the side menu, click Virtualization.
- Click the Virtual Machine tab.
- Select a virtual machine to open its Virtual Machine Overview page.
- Click the Environment tab.
- Click Select a resource and select a secret, ConfigMap, or service account from the list.
- Click Save.
- 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
- From the Virtual Machine Overview page, click the Disks tab.
- Check to ensure that the secret, ConfigMap, or service account is included in the list of disks.
-
Optional. Start the virtual machine by clicking Actions
Start Virtual Machine. You can now mount the secret, ConfigMap, or service account as you would mount any other disk.
7.8.2. 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
- From the side menu, click Virtualization.
- Click the Virtual Machine tab.
- Select a virtual machine to open its Virtual Machine Overview page.
- Click the Environment tab.
- Find the item that you want to delete in the list, and click the Delete button on the right side of the item.
- Click Save.
You can reset the form to the last saved state by clicking Reload.
Verification
- From the Virtual Machine Overview page, click the Disks tab.
- Check to ensure that the secret, ConfigMap, or service account that you removed is no longer included in the list of disks.