OpenShift 4.3: Console Customization: YAML Samples

In Red Hat OpenShift 4.2 we introduced OpenShift Console customization via CRDs. Now, for OpenShift 4.3, we have extended the customization abilities to allow users to add their own YAML sample to a Kubernetes resource. These YAML sample will appear in a sidebar on the creation page for any Kube resource:

Out of the box, OpenShift 4 provides a few examples for users. With this new extension mechanism users can now add their own YAML sample for all users on the Cluster. Let us look at how we can manually add a YAML example to the cluster. First we need to navigate to the Custom Resource Definition navigation item and search for YAML:

Next we select the ConsoleYAMLSample CRD and navigate to the instances tab:

In this example we are going to create a YAML Sample for “Job” Kube resource:

Let us take a closer look at the YAML:

description: An example Job YAML sample
 targetResource:
   apiVersion: batch/v1
   kind: Job                ---> Kube resource assigned this sample 
 title: Example Job         ---> Display text in the sidebar
  Snippet: false            ---> YAML will be injected and not replaced if “true”
 yaml:                  ---> Sample YAML content 
   apiVersion: batch/v1
   kind: Job
   metadata:
     name: countdown
   spec:
     template:
       metadata:
         name: countdown
       spec:
         containers:
         - name: counter
           image: centos:7
           command:
           - "bin/bash"
           - "-c"
           - "for i in 9 8 7 6 5 4 3 2 1 ; do echo $i ; done"
         restartPolicy: Never

Before we create the ConsoleYAMLSample CRD, we can navigate to the Jobs menu item and attempt to create a new Job. You will see that no Sample section appears in the Job creation page, only the Schema tab appears in the sidebar:

After we create the ConsoleYAMLSamples CRD, we can see our sample now shows up under the Samples section:

In addition to creating samples manually, this can be achieved programmatically, since the extensions mechanism was built using CRDs. An important use case: With this extension mechanism when a new Operator is installed and it adds new Kube resources (CRDs) to the cluster, the Operator can now add more YAML samples than just the default one.
Snippets
If the “snippet” flag is set to true, then the sample will show up as a snippet, and will be injected into the existing YAML at the location of the cursor in the YAML editor. Snippets will not replace the existing YAML. The Snippets section will show up as a tab in the sidebar:

If you’d like to learn more about what the OpenShift team is up to or provide feedback on any of the new 4.3 features, please take this brief 3-minute survey.

Categories
OpenShift Container Platform
Tags
, ,