Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Configure DO VPS to toggle from proxying cluster to local site #14

Closed
geerlingguy opened this issue Jan 28, 2022 · 4 comments
Closed

Configure DO VPS to toggle from proxying cluster to local site #14

geerlingguy opened this issue Jan 28, 2022 · 4 comments
Labels

Comments

@geerlingguy
Copy link
Owner

After #6 is complete, I would like to document the process of making it easy (and as automatic as possible) to switch the actual Nginx config between proxying PHP-FPM running on the local server vs. Kubernetes on the Pi cluster through the SSH tunnel.

There are a few moving parts to the transition, since Drupal is a stateful application (assuming a 'blue' server and a 'green' server):

  1. Pause DB transactions on 'blue' server (and put site in maintenance mode) so new data isn't written.
  2. Export/dump database from current 'blue' server.
  3. Sync Drupal files dir across from 'blue' server to 'green' server.
  4. Import database into new 'green' server.
  5. Verify 'green' server is running well and no errors are showing up.
  6. Switch Nginx config to proxy 'green' server.

And the opposite would apply switching back from green to blue.

Worst case, as long as I have a DB backup, I could just switch back to the VPS if there are issues with the cluster (e.g. huge load from HN slashdotting, or something like that), and sort out any comments or content edits later by hand.

@geerlingguy
Copy link
Owner Author

So...

Not sure if I'm going to try to automate this entire process. The cluster is handling things nicely (see #6), but before I commit to making it easy to switch back and forth, I want more data and more time to test.

For now, the process I followed to switch from my VPS host to the cluster is:

  1. Manually export the MySQL database from DO VPS using Sequel Ace.
  2. Copy that .sql file over to turing-node-1.local
  3. Import on turing-node-1.local: kubectl -n drupal exec -i MARIADB_POD_HERE -- mysql -u drupal -pPASSWORD_HERE drupal < jeffgeerling.sql
  4. Manually rsync or scp the Drupal files directory down from DO VPS to my Mac.
  5. Copy all the files to the Drupal files directory on turing-node-3.local: rsync -avz ~/Downloads/jeffgeerling-files/ pi@turing-node-3.local:/zfsdata/nfsshare/drupal-drupal-files-pvc-pvc-8db3b18b-a635-4bb5-812f-dabaf21ccd37/
  6. Log into turing-node-3.local and in the drupal-drupal-files-* directory run: sudo chown -R www-data:www-data ./* (otherwise Drupal can't manage css/aggregate files in there and styles break).
  7. Verify the site is loading at www.jeffgeerling.com:8080 (and probably run a manual cache flush)
  8. Manually enter the Solr server password since it's stored outside the database/configuration.
  9. Edit the DO VPS nginx www.jeffgeerling.com.conf file and change the ports from :81 to :8080 for various paths and file types (there are four instances).
  10. Restart nginx (sudo systemctl restart nginx).

Bingo!

@geerlingguy geerlingguy changed the title Configure DO VPS to easily toggle from proxying cluster to local site Configure DO VPS to toggle from proxying cluster to local site Feb 9, 2022
@geerlingguy
Copy link
Owner Author

See: geerlingguy/jeffgeerling-com#141

Had to revert some stuff, change a lot, etc. But site is back up and running now.

@stale
Copy link

stale bot commented Jun 11, 2022

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

@stale stale bot added the stale label Jun 11, 2022
@stale
Copy link

stale bot commented Jul 12, 2022

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

@stale stale bot closed this as completed Jul 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant