nightscout / nightscout.github.io

website, meta repo for whole project
GNU General Public License v2.0
107 stars 233 forks source link

Managing multiple Nightscout sites: Hints to reduce the administrative burden #89

Closed bjornoleh closed 3 years ago

bjornoleh commented 3 years ago

While migrating our NS sites to Atlas, I documented some steps to simplify the management of multiple NS sites. I didn't want to mention this earlier, as there have been more than enough to deal with regarding the migration process.

Perhaps we could now consider adding these steps to a separate page in http://nightscout.github.io/?

The hints are given in the order of usefulness. Number 1. - 3. are easy, and could be considered mandatory when managing multiple NS sites. Number 4 is the most effort, and probably not very useful to most.

  1. Github: a single account is enough
  2. Heroku: Adding control over multiple NS sites from the same Heroku login
  3. Heroku: Use "Automatic deploy of master" (must use "pull request for updating for this to work, not the "delete fork" procedure)
  4. MongoDB Atlas: Adding control over multiple NS databases from the same Atlas login

(and a hint about Reverting to a previous deploy in Heroku, which is useful, but slightly off topic)

I have the required screenshots, but haven't edited out the usernames etc yet. @psonnera , what are you using to edit screenshots? It could be good to do it consistently throughout the documentation.

Managing multiple Nightscout sites: Hints to reduce the administrative burden -but it will take a few clicks now to set it up:

Github: You need only one Github account!

Then, the Github part of the update Nightscout will only have to be done once. (must use "pull request for updating for this to work, not the "delete fork" procedure)

(make it even clearer in http://nightscout.github.io/nightscout/new_user/#step-1-create-a-github-account that only one account is needed for multiple NS sites).

Heroku https://dashboard.heroku.com/apps

Log into the Heroku account that you wish to administer from another account (let’s call the other account the “master Heroku account”). Select the “App” you want to access from the master account. Click Access Click Add collaborator Enter the email address which is used with the master Heroku account Click Save changes

You will receive an email, but no actions are needed. Log out of the current account Log into your “master Heroku account” All “Apps” (NS-instances) will be available after login. Select either one to do what you need to do.

Automatic deploy of Nightscout Master: Click Deploy

Scroll down to Deployment method – Check that your Github account is connected Scroll down to Automatic deploys Click Enable Automatic Deploys

Do this for each Nightscout instance in Heroku. Now, all your NS sites will be updated to the latest Master as soon as you perform a “Pull request” in Github.

To update NS, please follow the instructions from within the NS site Click Check for Updates and follow the instructions. There is a mention about how to proceed with “Enable Automatic Deploys” turned on. You will only have to do this for one of the NS-sites, the others will be updated simultaneously if you followed the steps above.

(Reverting to a previous deploy:) Should you ever regret updating your NS, it is easy to revert to any previous version. Click Activity Find your previous deploy in the list Click “Roll back to here” This goes for any changes made to the Heroku Config variables as well.

MongoDB Atlas After having migrated your NS databases to MongoDB Atlas (or set up a new NS site with Atlas), these few steps will let you manage all your databases from one login.

https://account.mongodb.com/account/login Log into the Atlas account that you wish to administer from another account (let’s call the other account the “master Atlas account”). ORGANIZATION: Click Access Manager Click Invite Users

Enter the email address of the “master Atlas account” Select access permissions: Organization Owner Click Invite to Organization

The invited account will be listed in the Access Manager

Log out of the current Atlas user, and into the “master Atlas account”. You should never have to log into the other accounts again. Check the email which is used for the “master Atlas account”, look for “Invitation to MongoDB Cloud”, and click “Accept Invite”.

You will be prompted to log into your “master Atlas account” to accept the invite. Click your name in the upper left-hand corner You will find all your organizations here. Select either one.

Optional: To rename the organization, klick the gear icon next to the selected name Edit the Organization Name by clicking the pen icon

psonnera commented 3 years ago

Github: a single account is enough PS> Completely agree

Heroku: Adding control over multiple NS sites from the same Heroku login PS> many were already thinking about it and if the 1000 free dynos are per app that would make sense

Heroku: Use "Automatic deploy of master" (must use "pull request for updating for this to work, not the "delete fork" procedure) PS> Now that we won't have Azure users anymore (hopefully) it might be an idea. I don't believe deploying is the worst for users. Most stumble on Github upgrade...

MongoDB Atlas: Adding control over multiple NS databases from the same Atlas login PS> This need to be digged as there were worries it would create a data flow not covered by the M0 plan, might be possible too image

psonnera commented 3 years ago

(and a hint about Reverting to a previous deploy in Heroku, which is useful, but slightly off topic) PS> yes, downgrade is planned to be documented

I used Snagit to capture screenshots and mixed border styles by mistake, mostly PrtScr and Paint. Eventually I'll have to uniformize all pictures. I like having a border as it improves readability.

I still need to complete https://nightscout.github.io/nightscout/admin_tools/ before Decembre 8th when we'll have the last wave of migrations and Upgrade pages will be removed or simplified... then yes, I also think about adding an Advanced section covering other deployments like Ocean Droplets, Containers, home NAS, etc...

bjornoleh commented 3 years ago

Heroku: Adding control over multiple NS sites from the same Heroku login PS> many were already thinking about it and if the 1000 free dynos are per app that would make sense

I don't think the dyno hours is an issue at all. You are simply giving others with a Heroku account access to your app as a "Collaborator". So the dyno hours should not be affected. We have done this for a month or two now with three apps which are registered on individual email accounts connected to my Heroku user (which is used for one of the three). No issues!

It is actually also a nice feature to use if helping someone remotely too. @sulkaharo introduced me to this option, and we used it for some troubleshooting a while ago. Just ask the person you are helping to add your email as a Contributor, and you will have access to the Config Vars, deployment, and Papertrail logs etc. If the person asking for help really isn't on top of things, this may speed things up considerably. Of course, do remember to remove yourself as collaborator when you are done.

Heroku: Use "Automatic deploy of master" (must use "pull request for updating for this to work, not the "delete fork" procedure) PS> Now that we won't have Azure users anymore (hopefully) it might be an idea. I don't believe deploying is the worst for users. Most stumble on Github upgrade...

Possibly, but if managing two or more accounts, it will speed things up if you are done after updating Master by a pull request, instead of visiting each Heroku app and hitting Deploy.

As long as people use the NS-guide for updating (as described here: http://nightscout.github.io/update/update/#step1-update-your-repository-in-github), it should not be a problem. But the list of open PRs in nightscout/cgm-remote-monitor suggests that this is a bit of an issue :-)

MongoDB Atlas: Adding control over multiple NS databases from the same Atlas login PS> This need to be digged as there were worries it would create a data flow not covered by the M0 plan, might be possible too image

I think this is ok, similarly as with Heroku. I believe you just grant others the access privileges to your organization. We have done this with three organizations since migrating (10. Oct), and have not run into any issues yet.

psonnera commented 3 years ago

@bjornoleh reading your comments I see I completely misunderstood. Now I got you. I need to think how to insert this without confusing the documentation, I guess another page is what is required, and I'll put your text in it.

bjornoleh commented 3 years ago

Cool. Let me know when or if you need the screenshots. I can pm you if you want them unedited (with url and database names visible) , or I can edit them for you.

psonnera commented 3 years ago

@bjornoleh ready for your review https://psonnera.github.io/nightscout.github.io/troubleshoot/multiadmin/

bjornoleh commented 3 years ago

Nice! I am quite sure this will be useful for some people. And it doesn't look like too much hassle to set up either. Thanks!

Just a few comments:

image

https://psonnera.github.io/nightscout.github.io/troubleshoot/multiadmin/#heroku

You will now see it as a collaborator. Using the pen icon you can modify it or delete it (like when used for other people remote support).

To rename the organization, klick the gear icon next to the selected name Edit the Organization Name by clicking the pen icon

psonnera commented 3 years ago

@bjornoleh can't find the FB post regarding profiles and Loop... is that the same idea? https://looptips.wordpress.com/deleting-loop-profiles-in-nightscout

bjornoleh commented 3 years ago

@psonnera yes, that is the crude one for deleting the whole profile collection.

Alternatively, selective deletion is possible, for example by using Robo 3T (https://robomongo.org/) as shown in this video (remember to viev it in 720P, otherwise it'll be too blurry) https://youtu.be/iipp0MfPKNQ

bjornoleh commented 3 years ago

This is the FB post https://m.facebook.com/groups/CGMITCOFFTOPIC/permalink/1191967457866937/

psonnera commented 3 years ago

@bjornoleh looking at the amount of work to duplicate this, I believe I'll just link the video and Wordpress document in an additional troubleshooting entry. Is this acceptable?

bjornoleh commented 3 years ago

Just deleting the profile collection is not that bad, but yes, the selective deletion is too much, just link to the video for that. Perhaps you could include the steps in the wordpress document properly in the troubleshooting? And just make a warning that all profile data will be deleted, and if this is not acceptable: please follow the steps in the video. Sounds good?

psonnera commented 3 years ago

Implemented

sulkaharo commented 3 years ago

Ping related to this topic: when people add other users to their Heroku accounts, this opens up potential vulnerability of those users being able to deploy new malicious versions of Nightscout and/or modify data in Mongo, so this should be done with extreme care.