-
Notifications
You must be signed in to change notification settings - Fork 505
METRON-1878: Add Metron as a Knox service #1275
Conversation
|
Re: quick links; you might be out of luck, based on https://issues.apache.org/jira/browse/AMBARI-21325. There might be ways around it (or require manual updating), but beyond that I don't know. |
|
Thoughts on the outstanding items Installing Metron in Knox
Adding Knox to the stack
Ambari Automation
Quick Links
|
|
Thanks for the feedback @justinleet.
|
|
I'm not sure if we can have Ambari do that in a general way. Right now we do have the Metron client get distributed throughout for the purpose of setting up Storm security. We could also do the same thing for whatever we need to distribute for Knox. It means a Metron Client needs to coexist with any Knox servers, but that seems like a reasonable restriction (even if I'd rather not have to deal with it). I think that would also address the custom topology question. If we're okay with putting more load on the Metron Client, I'd rather use the custom topology and just do it that way. For quicklinks, I'm okay with having the manual update process documented as part of the Knox setup, as long as it's noted its not a Metron issue, it's an Ambari/Knox interaction issue (and maybe just link to the Jira) |
|
@merrimanr Where does this leave the management UI if I enable Knox? |
|
I will be looking into this further, but I see a lot of the following in the management UI logs. This repeated for more than 80k lines in a matter of minutes: |
|
EDIT - that's the rest logs, not management UI logs. When I shutdown the management UI, the exceptions stop. |
mmiklavc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to click submit on these Q's last week.
|
Also, it's probably worth adding a simple explanation or diagram that talks about the message routing - e.g. I'm assuming we have these endpoints available via 2 distinct URL's when run locally? |
Turns out this was Zookeeper having gone down after HDFS filled up. Ambari had a lag in reporting. Independent of this PR, we might want to see about addressing REST api connectivity issues in the management UI. As it stands, the UI is left orphaned and inoperable without much explanation to the end user when something goes wrong when communicating with REST. |
|
@merrimanr Just summing up a few things I think we should have come out of this PR per our offline convo earlier:
Here's the basic request/response lifecycle as I understand it: Static asset call for Angular application This is for javascript, html, and images. I realize "static" may be a misnomer for Angular javascript, but it's static insofar as the web container is concerned: Dynamic/REST content call. Knox is now replacing ExpressJS entirely as the proxy mechanism. Note, ExpressJS didn't perform any function for static assets, only for calls to 3rd parties like the REST app. This is necessary because CORS restricts a browser from making the calls directly to REST (or any other non-origin host that's different from the original host that served up the client-side Angular app). This could theoretically be handled by a proper server side web application, but my understanding is that this would be superfluous given the API contract we've enacted with the REST API, i.e. it handles requests/responses in JSON that an AngularJS application can process easily. |
# Conflicts: # dependencies_with_url.csv
|
@mmiklavc I've made several updates to the PR. I realized in my testing that for this feature to work correctly, the Knox SSO code should be included so I merged in #1281. In addition to resolving those merge conflicts, I also added a unit test for the Knox SSO servlet filter and the documentation you requested. Let me know if the doc makes sense and has enough detail. I'm also debating copying the testing instructions from this PR into the README as Knox setup instructions. A follow on PR that adds this feature to the Mpack is going up soon so are manual instructions worth documenting? I also fixed a couple more UI bugs (login page redirection and the logout bug you mentioned) and tested @sardell's fix in #1301. I think that covers points 1, 2, 4, and 5. For 3, I added an inline comment to index.html explaining the relative base path setting. Do you still think we need to add something to the README for this? For 6, I was going to start on it if you haven't already. I've updated the PR description with end to end instructions for testing Knox SSO. I believe this is ready for testing and further review. |
Not necessary. I think just link the mpack PR to this one in the main comments and mention "don't merge until" so that they are committed together. |
|
The latest commit adds the Management UI as a Knox service. I've updated the PR description and testing instructions to include it. Setup is very similar to the Alerts UI. I am still working on getting the unit tests passing but it should function correctly. Sounds good wrt to mpack vs setup documentation @mmiklavc. I will open another PR that references this PR for the mpack changes. |
# Conflicts: # dependencies_with_url.csv
|
The latest commit addresses the metron-config unit test failures. This PR should be ready for review. |
mmiklavc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking pretty good @merrimanr. I have some questions and clarifications, but I think it's very close. A couple other things in addition to what I've commented inline:
- Can you talk about the rewrite rules at all? What are they currently doing and when would someone need to modify those files?
- Can you add any comment on the LDAP config with roles? Maybe a very brief cookie cutter example of how a user's LDAP users and groups will translate into Metron's interpretation of that info.
metron-interface/metron-alerts/src/app/service/app-config.service.ts
Outdated
Show resolved
Hide resolved
...rc/app/sensors/sensor-parser-config-readonly/sensor-parser-config-readonly.component.spec.ts
Outdated
Show resolved
Hide resolved
...ce/metron-config/src/app/sensors/sensor-parser-config/sensor-parser-config.component.spec.ts
Outdated
Show resolved
Hide resolved
...erface/metron-config/src/app/sensors/sensor-parser-list/sensor-parser-list.component.spec.ts
Outdated
Show resolved
Hide resolved
metron-interface/metron-config/src/app/service/app-config.service.ts
Outdated
Show resolved
Hide resolved
There is not much to say about this because there isn't any significant rewriting going on. Knox is simply forwarding the requests as is. This is the same for all 3 services (Alerts UI, Management UI, and REST) and you'll notice all
You're right, we should document how this works. I will add a section to the README. |
|
@mmiklavc the latest commits should address the changes you requested. Let me know if I missed something. I ran this up in full dev again and everything still works. |
|
Latest changes look good @merrimanr. I'm nearly finished with my testing against #1308, which includes this PR. I'm +1 on this PR, which I presume will be merged at the same time as METRON-1945 once it gets +1'ed |
# Conflicts: # metron-interface/metron-alerts/cypress/integration/pcap/pcap.spec.js
Contributor Comments
This PR adds REST and the Alerts UI as services in Knox.
Changed Included
Testing
This feature can be tested in full dev with some manual configuration. After spinning up full dev:
/usr/metron/0.7.0/bin/install_metron_knox.sh. This script copies themetron.xmlandmetronsso.xmltopology files to/usr/hdp/current/knox-server/conf/topologiesand the service definition files to/usr/hdp/current/knox-server/data/services/metron-rest/0.6.1and/usr/hdp/current/knox-server/data/services/metron-alerts/0.7.0apiRootsetting inapp-config.jsonis used to construct the url for REST requests. Change this setting in/usr/metron/0.7.0/web/alerts-ui/assets/app-config.jsonfrom:to:
loginPathsetting in/usr/metron/0.7.0/web/alerts-ui/assets/app-config.jsonfrom:to:
Any changes to
app-config.jsonrequire a page refresh./usr/metron/0.7.0/web/alerts-ui/assets/app-config.jsonfrom:to:
knoxSpring active profile in Ambari. Navigate toAmbari > Metron > Configs > REST.Change the
Active Spring profilessetting fromdevtodev,knox. This sets the Swagger context path to Knox and adds the Knox SSO servlet filter.Copy the value generated from that command. Navigate to
Ambari > Metron > Configs > RESTand change theMetron Spring optionsto:The
knox.rootsetting sets the Knox root path. The Swagger interface is served by the REST application and provides links for the various endpoints. Swagger must be configured with the new Knox root path for REST. Theknox.sso.pubkeysetting sets the Knox public key that will be used to verify Knox SSO tokens.Everything should function normally including login, logout and session timeout. To test the SSO part:
You should be redirected to the Knox SSO url with the
originalUrlparam properly set:After authenticating with LDAP credentials, you should be successfully redirected and see the global config in the browser.
To verify roles are working correctly, authenticate as the
adminuser withadmin/admin-password. Thehttps://node1:8443/gateway/metron/metron-rest/api/v1/user/whoami/rolesendpoint should returnROLE_USERandROLE_ADMINjust as it currently does.Navigate to the Alerts UI:
You should go directly to the Alerts UI without being prompted for credentials.
Click the logout link in the Alerts UI and verify you are redirected to the Knox login page.
Login back into the Alerts UI and wait. The session should timeout and you should be redirected back to the login page. The session timeout can be changed in
metronsso.xmlwith the `` property. To change from the default of 30 seconds to 5 minutes, change the property from this:to this:
Outstanding Items
Installing Metron in Knox
Installing a service in Knox involves 2 steps:
What is the best way to install these files in Knox? The approach in this PR only works if Metron is installed on the same machine as the Knox gateway.
I also opted to create a dedicated Metron topology file. I think this will give us more control and allow us to expose properties in a more user-friendly way. Knox has a default topology that you can configure in Ambari but it's exposed as is: a big xml file. Does anyone think we should use the default topology file instead?
Adding Knox to the stack
This process requires that we add Knox separately through Ambari. Do we want to make Knox a dependency for Metron similar to Kafka, Storm, etc?
Does it make sense to require that Knox and Metron are colocated? Doing this simplifies installation and configuration and I would vote we make this a requirement unless there is a good reason not to. Does anyone think there are cases where users would need to install them on different machines? If we do that, how do we install the service definition files?
Ambari automation
Currently setting up Metron with Knox is a manual process. I believe all of this can easily be automated with Ambari. How far do we want to go in this initial pass? Do we want to just document it for now? If we did want to automate this setup with Ambari, we would need to:
apiRootsettingknox.rootsetting to the REST config file (rest_application.yml) and expose it through an Ambari settingLDAP enabledsetting that automatically adds theknoxspring profile to the list of active profilesinstall_metron_knox.shin the appropriate Metron Mpack scriptQuick Links
At this point I do not know how to make Ambari quick links dynamic. You can bind the port to a property but I don't know if you can do that for the scheme, host, and path. This means that after you follow these instructions for setting up Metron with Knox, the quick links will still point to the urls without Knox. Does anyone know how to change quick links to point to Knox automatically? There has been discussion of enabling Knox by default so in that case we can just set the quick links to the Knox urls.
Hopefully a working example will provide more context as we plan out this feature.
Pull Request Checklist
Thank you for submitting a contribution to Apache Metron.
Please refer to our Development Guidelines for the complete guide to follow for contributions.
Please refer also to our Build Verification Guidelines for complete smoke testing guides.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check the following:
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via
site-book/target/site/index.html:Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.