|
| 1 | +## Migrating from Kubernetes to Appliances |
| 2 | + |
| 3 | +### Prerequisites |
| 4 | +1. Deploy an appliance with a database disk. It is recommended that the appliance being deployed is the same code version as the kubernetes environment. |
| 5 | + |
| 6 | +1. Configure the hostname and ip address on the appliance. |
| 7 | + |
| 8 | + |
| 9 | +### Collect data from the Kubernetes environment |
| 10 | +1. Disable the running environment to prepare for migration |
| 11 | + ```bash |
| 12 | + $ oc patch deployment orchestrator -p '{"spec":{"template":{"spec":{"containers":[{"name":"orchestrator","args": ["-c", "sleep 1d"], "command":["/bin/sh"]}]}}}}' |
| 13 | + ``` |
| 14 | + |
| 15 | +1. Take a backup of the database |
| 16 | + ```bash |
| 17 | + # Check for enough free disk space |
| 18 | + $ psql -d vmdb_production -c "SELECT pg_size_pretty(pg_database_size('vmdb_production'));" |
| 19 | + $ pg_dump -Fc -d vmdb_production > /var/lib/pgsql/data/postgres.dump |
| 20 | + # Copy the database backup to the appliance (usually under /tmp/ or somewhere that has enough space) |
| 21 | + ``` |
| 22 | + |
| 23 | +1. Extract the database password, encryption key, server GUID and region number |
| 24 | + ```bash |
| 25 | + $ oc rsh deploy/orchestrator |
| 26 | + sh-5.1$ cd /var/www/miq/vmdb/ |
| 27 | + sh-5.1$ source ./container_env |
| 28 | + |
| 29 | + # Extract the database password from the database config file |
| 30 | + sh-5.1$ cat config/database.yml |
| 31 | + --- |
| 32 | + production: |
| 33 | + adapter: postgresql |
| 34 | + username: root |
| 35 | + password: xxxxxxxxxxxxxxxx |
| 36 | + host: postgresql |
| 37 | + ... |
| 38 | + |
| 39 | + # Extract the encryption key |
| 40 | + sh-5.1$ cat certs/v2_key |
| 41 | + --- |
| 42 | + :algorithm: aes-256-cbc |
| 43 | + :key: xxxxxxxxxlKmYTe4FijZ6TNrvZq/vg+0BUasCWTSf08= |
| 44 | + |
| 45 | + # Extract the server GUID |
| 46 | + sh-5.1$ cat GUID |
| 47 | + xxxxxxxx-xxxx-4f37-b1d3-03c3231689ed |
| 48 | + |
| 49 | + # sh-5.1$ echo $DATABASE_REGION |
| 50 | + 0 |
| 51 | + ``` |
| 52 | + |
| 53 | + |
| 54 | +### Configure the appliance |
| 55 | +1. Create the encryption key |
| 56 | + ```bash |
| 57 | + # Use vi or nano to create the v2_key file with the content extracted from the orchestrator pod above |
| 58 | + vi /var/www/miq/vmdb/certs/v2_key |
| 59 | + chmod 400 /var/www/miq/vmdb/certs/v2_key |
| 60 | + chown manageiq:manageiq /var/www/miq/vmdb/certs/v2_key |
| 61 | + ``` |
| 62 | + |
| 63 | +1. Create the GUID file |
| 64 | + ```bash |
| 65 | + # Use vi or nano to create the GUID file with the content extracted from the orchestrator pod above |
| 66 | + vi /var/www/miq/vmdb/GUID |
| 67 | + chmod 644 /var/www/miq/vmdb/GUID |
| 68 | + chown root:root /var/www/miq/vmdb/GUID |
| 69 | + ``` |
| 70 | + |
| 71 | +1. Run the `appliance_console` to configure the appliance |
| 72 | + a. Select "Configure Application" |
| 73 | + b. Select "1) Create Internal Database" to create a new database. |
| 74 | + c. Select "3) Make No messaging changes" to skip messaging configuration for now. |
| 75 | + d. Choose the database disk |
| 76 | + e. Choose whether this will be a standalone database server |
| 77 | + f. Enter the region number |
| 78 | + g. Enter the database password from the kubernetes environment |
| 79 | + |
| 80 | +1. Restore the database from the backup from the `appliance_console` |
| 81 | + a. Select "Restore Database From Backup" |
| 82 | + b. Enter the full path to the database backup file. i.e. /tmp/postgres.dump |
| 83 | + c. Choose whether you would like to delete the dump file after the database is restored |
| 84 | + d. Confirm that you would like to restore the database. |
| 85 | + |
| 86 | +1. Configure messaging through the `appliance_console` |
| 87 | + a. Select "Configure Application" |
| 88 | + b. Select "5) Make No Database Changes" |
| 89 | + c. Select "1) Configure this appliance as a messaging server" |
| 90 | + d. When prompted, Yes, you want to unconfigure messaging first. |
| 91 | + e. Enter the hostname, username, password and whether you would like to configure another disk for the messaging service |
| 92 | + |
| 93 | + |
| 94 | +### Followup |
| 95 | +1. Depending on the authentication configuration on the kubernetes environment, you may need to clear out authentication settings |
| 96 | + ```bash |
| 97 | + cd /var/www/miq/vmdb/ |
| 98 | + bin/rails console |
| 99 | + # In the rails console: |
| 100 | + SettingsChange.all.select {|s| s.key.start_with?("/authentication")}.each {|s| s.destroy}' |
| 101 | + # When complete, `exit` |
| 102 | + ``` |
0 commit comments