|
| 1 | +//Used in assembly deploy-plugin-cluster.adoc |
| 2 | + |
| 3 | +:_mod-docs-content-type: PROCEDURE |
| 4 | +[id="enabling-a-dynamic-plugin-by-using-the-cli_{context}"] |
| 5 | += Enabling a dynamic plugin with the CLI |
| 6 | + |
| 7 | +[role="_abstract"] |
| 8 | +You can enable a dynamic plugin to extend the core web console with more features, such as additional pages, perspectives, or dashboard items. Use the {oc-first} after a scripted installation, such as an Operator or Helm-based install. Add the `ConsolePlugin` name to `spec.plugins` in the console Operator configuration (`console.operator.openshift.io/cluster`) so the web console loads it. |
| 9 | + |
| 10 | +.Prerequisites |
| 11 | +* You logged in to the cluster as a user with `cluster-admin` privileges. |
| 12 | +* You installed the dynamic plugin using a scripted installation, such as an Operator or Helm chart. |
| 13 | +* A `ConsolePlugin` custom resource (CR) exists on the cluster. |
| 14 | +
|
| 15 | +.Procedure |
| 16 | +. Confirm the name of the `ConsolePlugin` resource by running the following command: |
| 17 | ++ |
| 18 | +[source,terminal] |
| 19 | +---- |
| 20 | +$ oc get consoleplugin |
| 21 | +---- |
| 22 | ++ |
| 23 | +. Optional: View details for a specific `ConsolePlugin` resource by running the following commands: |
| 24 | + |
| 25 | +.. Set the plugin name as an environment variable: |
| 26 | ++ |
| 27 | +[source,terminal] |
| 28 | +---- |
| 29 | +$ PLUGIN_NAME="<plugin_name>" |
| 30 | +---- |
| 31 | ++ |
| 32 | +where `<plugin_name>` is the name of the `ConsolePlugin` resource. |
| 33 | +.. Verify the plugin details: |
| 34 | ++ |
| 35 | +[source,terminal] |
| 36 | +---- |
| 37 | +$ oc get consoleplugin "${PLUGIN_NAME}" -o yaml |
| 38 | +---- |
| 39 | ++ |
| 40 | +The following example shows a `ConsolePlugin` YAML with the plugin listed in `spec.plugins`: |
| 41 | ++ |
| 42 | +[source,yaml] |
| 43 | +---- |
| 44 | +apiVersion: operator.openshift.io/v1 |
| 45 | +kind: Console |
| 46 | +metadata: |
| 47 | + name: cluster |
| 48 | +spec: |
| 49 | + plugins: |
| 50 | + - <plugin_name> |
| 51 | + # ... |
| 52 | +---- |
| 53 | ++ |
| 54 | +Replace `<plugin_name>` with the name of your plugin. |
| 55 | + |
| 56 | +. Enable the dynamic plugin by adding the `ConsolePlugin` name to the console Operator configuration. |
| 57 | ++ |
| 58 | +[NOTE] |
| 59 | +==== |
| 60 | +Make sure the Operator finishes installing the dynamic plugin before you run the following patch command. |
| 61 | +==== |
| 62 | ++ |
| 63 | +.. Set the plugin patch as an environment variable: |
| 64 | ++ |
| 65 | +[source,terminal] |
| 66 | +---- |
| 67 | +$ PLUGIN_PATCH=$(cat <<EOF |
| 68 | +[ |
| 69 | + { |
| 70 | + "op": "add", |
| 71 | + "path": "/spec/plugins/-", |
| 72 | + "value": "<plugin_name>" |
| 73 | + } |
| 74 | +] |
| 75 | +EOF |
| 76 | +) |
| 77 | +---- |
| 78 | + |
| 79 | +.. Patch the console Operator configuration: |
| 80 | ++ |
| 81 | +[source,terminal] |
| 82 | +---- |
| 83 | +$ oc patch consoles.operator.openshift.io cluster --type=json -p "${PLUGIN_PATCH}" |
| 84 | +---- |
| 85 | + |
| 86 | +.Verification |
| 87 | +. Confirm that the console Operator configuration includes the `ConsolePlugin` name by running the following command: |
| 88 | ++ |
| 89 | +[source,terminal] |
| 90 | +---- |
| 91 | +$ oc get console.operator.openshift.io cluster -o jsonpath='{.spec.plugins}{"\n"}' |
| 92 | +---- |
| 93 | + |
| 94 | +. Refresh the {product-title} web console. |
| 95 | ++ |
| 96 | +The console can take a few minutes to apply the updated configuration. |
| 97 | + |
| 98 | +[role="_additional-resources"] |
| 99 | +.Additional resources |
| 100 | +* https://github.com/openshift/console/tree/main/dynamic-demo-plugin#enabling-the-plugin[Upstream demo instructions for enabling a plugin] |
| 101 | +* https://github.com/openshift/console-plugin-template/blob/3a06152cffdd10ad9654b6b607cb00a055f29733/charts/openshift-console-plugin/templates/patch-consoles-job.yaml[Helm template that patches the console Operator configuration] |
0 commit comments