Extending Knox with the SSB service definitions

You must create service definitions for the SSB Console and Materialized Views in the Knox Admin UI.

  1. Go to your cluster in Cloudera Manager.
  2. Select Knox from the list of services.
  3. Select Knox Gateway Home.
  4. Open the General Proxy Information.
  5. Click Admin UI URL.
    You are redirected to the Knox Manager page.
  6. Click Service Definitions under Resource Types.
  7. Click on the plus icon to add the SSB service definitions.
    The Create a New Service Definition window appears.
  8. Delete the default text from the window.
  9. Create the service definitions for SSB.
    1. Copy the following XML entry for the SSB-MVE-API service definition:
      <?xml version="1.0" encoding="UTF-8"?>
      <serviceDefinitions>
         <serviceDefinition>
            <service name="ssb-mve-api" role="SSB-MVE-API" version="1.4.0.0">
               <metadata>
                  <context>/ssb-mve-api</context>
                  <description>Streaming SQL Builder - Materialized View Engine API</description>
                  <shortDesc>SSB - MVE API</shortDesc>
                  <type>API</type>
               </metadata>
               <routes>
                  <route path="/ssb-mve-api/**">
                     <rewrite apply="SSB-MVE-API/ssb-mve-api/path" to="request.url"/>
                  </route>
               </routes>
            </service>
            <rules>
               <rule dir="IN" name="SSB-MVE-API/ssb-mve-api/path" pattern="*://*:*/**/ssb-mve-api/{path=**}?{**}">
                  <rewrite template="{$serviceUrl[SSB-MVE-API]}/{path=**}?{**}"/>
               </rule>
            </rules>
         </serviceDefinition>
      </serviceDefinitions>
    2. Paste it to the New Service Definition window.
    3. Click Ok.
    4. Click on the plus icon to create a new service definition.
    5. Copy the following XML entry for the SSB-SSC-UI service definition:
      <?xml version="1.0" encoding="UTF-8"?>
      <serviceDefinitions>
         <serviceDefinition>
            <service name="ssb-ssc-ui" role="SSB-SSC-UI" version="1.4.0.0">
               <dispatch classname="org.apache.knox.gateway.dispatch.ConfigurableDispatch" use-two-way-ssl="false">
                  <param>
                     <name>responseExcludeHeaders</name>
                     <value>Www-Authenticate</value>
                  </param>
               </dispatch>
               <metadata>
                  <context>/ssb-ssc-ui</context>
                  <description>SQL Streaming Builder - Streaming SQL Console - UI</description>
                  <shortDesc>SSB Console</shortDesc>
                  <type>UI</type>
               </metadata>
               <routes>
                  <route path="/ssb-ssc-ui/">
                     <rewrite apply="SSB-SSC-UI/filter/outbound/headers" to="response.headers"/>
                     <rewrite apply="SSB-SSC-UI/filter/outbound/body" to="response.body"/>
                  </route>
                  <route path="/ssb-ssc-ui/**">
                     <rewrite apply="SSB-SSC-UI/filter/outbound/headers" to="response.headers"/>
                     <rewrite apply="SSB-SSC-UI/filter/outbound/body" to="response.body"/>
                  </route>
                  <route path="/ssb-ssc-ui/**?**">
                     <rewrite apply="SSB-SSC-UI/filter/outbound/headers" to="response.headers"/>
                     <rewrite apply="SSB-SSC-UI/filter/outbound/body" to="response.body"/>
                  </route>
               </routes>
            </service>
            <rules>
               <rule dir="IN" name="SSB-SSC-UI/rule/inbound/query" pattern="*://*:*/**/ssb-ssc-ui/{path=**}?{**}">
                  <rewrite template="{$serviceUrl[SSB-SSC-UI]}/{path=**}?{**}"/>
               </rule>
               <rule dir="IN" name="SSB-SSC-UI/rule/inbound/path" pattern="*://*:*/**/ssb-ssc-ui/{**}">
                  <rewrite template="{$serviceUrl[SSB-SSC-UI]}/{**}"/>
               </rule>
               <rule dir="IN" name="SSB-SSC-UI/rule/inbound/root" pattern="*://*:*/**/ssb-ssc-ui/">
                  <rewrite template="{$serviceUrl[SSB-SSC-UI]}/"/>
               </rule>
               <rule dir="OUT" flow="OR" name="SSB-SSC-UI/rule/outbound/header/links">
                  <match pattern="*://*:*/{path=**}?{**}">
                     <rewrite template="{$frontend[url]}/ssb-ssc-ui/{path=**}"/>
                  </match>
                  <match pattern="*://*:*/{path=**}">
                     <rewrite template="{$frontend[url]}/ssb-ssc-ui/{path=**}"/>
                  </match>
                  <match pattern="*://*:*/">
                     <rewrite template="{$frontend[url]}/ssb-ssc-ui/"/>
                  </match>
               </rule>
               <rule dir="OUT" name="SSB-SSC-UI/rule/outbound/html/static" pattern="/static/{**}">
                  <rewrite template="{$frontend[url]}/ssb-ssc-ui/static/{**}"/>
               </rule>
               <rule dir="OUT" flow="OR" name="SSB-SSC-UI/rule/outbound/js/api">
                  <match pattern="/api/v1/query"/>
                  <match pattern="/api/v1">
                     <rewrite template="{$frontend[path]}/ssb-ssc-ui/api/v1"/>
                  </match>
               </rule>
               <rule dir="OUT" name="SSB-SSC-UI/rule/outbound/js/ws">
                  <match pattern="/socket.io">
                     <rewrite template="{$frontend[path]}/ssb-ssc-ws/socket.io"/>
                  </match>
               </rule>
               <rule dir="OUT" flow="OR" name="SSB-SSC-UI/rule/outbound/html/link">
                  <match pattern="/{path=**}?{**}">
                     <rewrite template="{$frontend[url]}/ssb-ssc-ui/{path=**}?{**}"/>
                  </match>
                  <match pattern="/{**}">
                     <rewrite template="{$frontend[url]}/ssb-ssc-ui/{**}"/>
                  </match>
               </rule>
               <filter name="SSB-SSC-UI/filter/outbound/headers">
                  <content type="application/x-http-headers">
                     <apply path="Location" rule="SSB-SSC-UI/rule/outbound/header/links"/>
                  </content>
               </filter>
               <filter name="SSB-SSC-UI/filter/outbound/body">
                  <content type="*/javascript">
                     <apply path="/api/v1/query|/api/v1" rule="SSB-SSC-UI/rule/outbound/js/api"/>
                     <apply path="/socket.io" rule="SSB-SSC-UI/rule/outbound/js/ws"/>
                  </content>
                  <content type="*/html">
                     <apply path="/static" rule="SSB-SSC-UI/rule/outbound/html/static"/>
                     <apply path="/api/v1" rule="SSB-SSC-UI/rule/outbound/html/link"/>
                     <apply path="/ui.*" rule="SSB-SSC-UI/rule/outbound/html/link"/>
                  </content>
               </filter>
            </rules>
         </serviceDefinition>
      </serviceDefinitions>
    6. Paste it to the New Service Definition window.
    7. Click Ok.
    8. Click on the plus icon to create a new service definition.
    9. Copy the following XML entry for the SSB-SSC-WS service definition:
      <?xml version="1.0" encoding="UTF-8"?>
      <serviceDefinitions>
         <serviceDefinition>
            <service name="ssb-ssc-ws" role="SSB-SSC-WS" version="1.4.0.0">
               <routes>
                  <route path="/ssb-ssc-ws/socket.io/">
                     <rewrite apply="SSB-SSC-WS/ssb-ssc-ws/inbound1" to="request.url"/>
                  </route>
                  <route path="/ssb-ssc-ws/socket.io/**">
                     <rewrite apply="SSB-SSC-WS/ssb-ssc-ws/inbound2" to="request.url"/>
                  </route>
               </routes>
            </service>
            <rules>
               <rule dir="IN" name="SSB-SSC-WS/ssb-ssc-ws/inbound1" pattern="*://*:*/**/ssb-ssc-ws/socket.io/">
                  <rewrite template="{$serviceUrl[SSB-SSC-WS]}/socket.io/"/>
               </rule>
               <rule dir="IN" name="SSB-SSC-WS/ssb-ssc-ws/inbound2" pattern="*://*:*/**/ssb-ssc-ws/socket.io/{**}">
                  <rewrite template="{$serviceUrl[SSB-SSC-WS]}/socket.io/{**}"/>
               </rule>
            </rules>
         </serviceDefinition>
      </serviceDefinitions>
    10. Paste it to the New Service Definition window.
    11. Click Ok.
  10. In the list of Service definitions, you should be able to see the following entries: