This project serves as a minimal template for an Openshift dynamic plugin. It shows basic operations with a Custom Resource Definition (CRD), in this case CronTab CRD, such as creating, editing and deleting.
It requires OpenShift 4.11.
The CronTab Dynamic Plugin creates new menu entry, routes, list page, details page and a default YAML template for a CRD.
A Helm chart is available to deploy the plugin to an OpenShift environment.
To deploy the plugin on a cluster using a Helm chart:
helm upgrade -i crontab-plugin charts/crontab-plugin -n crontab-plugin-ns --create-namespace --set plugin.image=docker.io/raspbeep/crontab-plugin:latest
-i crontab-plugin
: specifies installation of a release named crontab-plugin
-n crontab-plugin-ns --create-namespace
: creates a new namespace for the helm chart
plugin.image
: Specifies the location of the image containing the plugin, to be deployed
Additional parameters can be specified if desired. Consult the chart values file for the full set of supported parameters.
You can deploy the plugin to a cluster by applying oc-manifest.yaml
.
oc apply -f oc-manifest.yaml
oc-manifest.yaml
specifies all Kubernetes resources (and their desired state) necessary for the dynamic plugin. This includes: Namespace, CustomResourceDefinition, Deployment (with plugin image location), Configmap, Service and Console Plugin.
Once deployed, patch the Console operator config to enable the plugin.
oc patch consoles.operator.openshift.io cluster --patch '{ "spec": { "plugins": ["crontab-plugin"] } }' --type=merge
In one terminal window, run:
yarn install
yarn run start
In another terminal window, run:
Before you can deploy your plugin on a cluster, you must build an image and push it to an image registry.
-
Build the image:
NOTE: If you have a Mac with Apple silicon, you will need to add the flag
--platform=linux/amd64
when building the image to target the correct platform to run in-cluster.docker build -f Dockerfile -t $NAME/crontab-plugin:latest . --no-cache
-
Push the image:
docker push $NAME/crontab-plugin:latest