Previously, you configured your VM through a combination of the custom-config-data.yaml file and a configuration hook that applied the configuration contained in this YAML file to Rhino. While this approach was user-friendly for the operator deploying the VM, it required development effort to design the configuration in the YAML file and implement the configuration hook for every configuration field. This section describes an alternative approach for configuring your VM using Rhino declarative configuration.

Prerequisites

This section assumes you are familiar with the basic concepts described in the Rhino documentation around Rhino declarative configuration. If you aren’t familiar with the concepts, read that documentation first.

Steps

Obtain the baseline Rhino declarative configuration

The declarative configuration bundle supplied to the VM must be a complete configuration bundle. As such, it is easiest to first deploy a VM without any configuration changes to obtain a "default" complete configuration bundle.

Connect to your VM over SSH and then run the following command:

rhino-console exportdeclarativeconfig rhino-declarative-config

Disconnect and then use scp to download this directory to your development environment:

scp -r rhino@<VM management IP address>:/home/rhino/rhino-declarative-config rhino-declarative-config

You should now have a rhino-declarative-config directory containing two files: config-bundle.yaml and namespace-default.yaml.

Update the configuration

You will use Rhino declarative configuration to configure the HTTP server to compress the response. Open the namespace-default.yaml file in your preferred editor and then locate this fragment:

- name: AutomaticContentCompression
  value: false
  present: true

Change this into:

- name: AutomaticContentCompression
  value: true
  present: true

Upload the Rhino declarative configuration

Now transfer the Rhino declarative configuration files to the SIMPL VM, and from there upload it to CDS.

Copy the entire rhino-declarative-config directory into the /home/admin/yamls directory on the SIMPL VM:

scp -r rhino-declarative-config admin@<SIMPL VM IP address>:/home/admin/yamls

Next, on the SIMPL VM, run the following commands:

  • cdcsars

  • http-example/0.1.0/resources/rvtconfig upload-config -c <CDS address> -i /home/admin/yamls -t custom --vm-version-source this-rvtconfig.

This will upload the configuration files to CDS. Wait for about one minute for the configuration changes to take effect.

Test the changes

Run the following curl command:

curl -v http://<VM signaling IP address>:8000/ -H "Accept-Encoding: gzip"

The output should contain

Content-Encoding: gzip

and a response that isn’t human-readable.

Result

You updated your application to support compression using declarative configuration and verified that this worked correctly.

Previous page Next page