This project is a standalone repository hosting the Kubevirt plugin for OpenShift Console.
Make sure the Remote Containers extension is installed. This method uses Docker Compose where one container is the OpenShift console and the second container is the plugin. It requires that you have access to an existing OpenShift cluster. After the initial build, the cached containers will help you start developing in seconds.
- Create a
dev.env
file inside the.devcontainer
folder with the correct values for your cluster:
OC_PLUGIN_NAME=kubevirt-plugin
OC_URL=https://api.example.com:6443
OC_USER=kubeadmin
OC_PASS=<password>
(Ctrl+Shift+P) => Remote Containers: Open Folder in Container...
yarn dev
- Navigate to http://localhost:9000
yarn test-cypress-docker
- Navigate to http://localhost:10000
- login with password
kubevirt
(no need for username)
- Set up Console and See the plugin development section in Console Dynamic Plugins README for details on how to run OpenShift console using local plugins.
- Run bridge with
-plugins kubevirt-plugin=http://localhost:9001
- Run
yarn dev
inside the plugin.
You should use the useKubevirtTranslation
hook as follows:
conster Header: React.FC = () => {
const { t } = useKubevirtTranslation();
return <h1>{t('Hello, World!')}</h1>;
};
For labels in console-extensions.json
, you should use the format
%plugin__kubevirt-plugin~My Label%
. Console will replace the value with
the message for the current language from the plugin__kubevirt-plugin
namespace. For example:
{
"type": "console.navigation/section",
"properties": {
"id": "admin-demo-section",
"perspective": "admin",
"name": "%plugin__kubevirt-plugin~VirtualMachines%"
}
}
Note that you will need to include a comment in utils/i18n.ts
like the
following for i18next-parser to
add the message from console-extensions.json
to your message catalog as follows:
// t('plugin__kubevirt-plugin~VirtualMachines')
Run yarn i18n
to update the JSON files in the locales
folder of the
dynamic plugin when adding or changing messages.
- Build the image:
docker build -t quay.io/kubevirt-ui/kubevirt-plugin:latest .
- Run the image:
docker run -it --rm -d -p 9001:80 quay.io/kubevirt-ui/kubevirt-plugin:latest
- Push the image to the image registry:
docker push quay.io/kubevirt-ui/kubevirt-plugin:latest
After pushing an image with your changes to an image registry, you can deploy the plugin to a cluster by instantiating the template:
oc process -f oc-manifest.yaml \
-p PLUGIN_NAME=kubevirt-plugin \
-p NAMESPACE=kubevirt-ui \
-p IMAGE=quay.io/kubevirt-ui/kubevirt-plugin:latest \
| oc create -f -
Once deployed, patch the Console operator config to enable the plugin.
oc patch consoles.operator.openshift.io cluster \
--patch '{ "spec": { "plugins": ["kubevirt-plugin"] } }' --type=merge