Skip to content

Commit 65fa97c

Browse files
committed
Self-Hosted: first set of review feedback, especially make it clearer where to wait for up/down scaling
1 parent a52adc7 commit 65fa97c

File tree

1 file changed

+54
-23
lines changed

1 file changed

+54
-23
lines changed

docs/self-hosted/kubernetes-migration-guide.md

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,69 +75,100 @@ Please note that any changes made in Private Packagist will now be lost and will
7575
## Installing Private Packagist Self-Hosted Kubernetes
7676
If you haven't done so already, now is the time to follow the [installation guide](./kubernetes.md) to install Private Packagist Self-Hosted Kubernetes.
7777

78-
## Restore application data in Kubernetes
78+
## Import the application data in Private Packagist Self-Hosted Kubernetes
7979

80-
All commands assume that you are logged in to the server where Private Packagist Self-Hosted Kubernetes is installed,
81-
your working directory contains the three files generated by the previous steps, and that
82-
Private Packagist Self-Hosted Kubernetes is installed in the Kubernetes namespace "default".
80+
All commands assume that you are logged in to the server where Private Packagist Self-Hosted Kubernetes is installed
81+
and your working directory contains the three files generated by the previous steps.
8382

84-
To avoid any data inconsistency, we highly recommend going through the steps below in order and only restart the application
83+
If you installed Private Packagist Kubernetes in an existing cluster and are not using the default namespace,
84+
make sure to run the commands in the correct namespace or switch the namespace before running any of the command.
85+
86+
```
87+
kubectl config set-context --current --namespace=<namespace-name>
88+
```
89+
90+
To avoid any data inconsistency, we highly recommend going through the steps below in order and only start the application
8591
once all the data has been restored.
8692

8793
### Stop the Private Packagist application
8894

8995
```
90-
kubectl scale deployment ui repo worker --replicas 0 -n default
96+
kubectl scale deployment ui repo worker --replicas 0
9197
```
9298

93-
### Restore the PostgreSQL database
99+
To verify that all ui, repo, and worker pods have been run the command below and verify that the pods don't appear in the list anymore.
100+
```
101+
kubectl get pods
102+
```
103+
104+
### Import the PostgreSQL database
94105

95106
Follow the instructions below to restore the PostgreSQL database in the cluster.
96107
If you are using your own PostgreSQL instance, use the `packagist_db.sql` file directly to import the data into your instance.
97108

98109
Please note that the backup will overwrite any existing data in the database and any changes you made during setup will be lost.
99110

111+
After each scale command, use `kubectl get pods` again to verify that the postgres pod is in the correct running state.
112+
100113
```
101-
kubectl scale statefulset postgres --replicas 0 -n default
102-
kubectl delete pvc postgres-data-postgres-0 -n default
103-
kubectl scale statefulset postgres --replicas 1 -n default
104-
cat packagist_db.sql | kubectl exec -it -n default statefulsets/postgres -- psql -U postgres -d packagist_db
114+
kubectl scale statefulset postgres --replicas 0
115+
kubectl delete pvc postgres-data-postgres-0
116+
kubectl scale statefulset postgres --replicas 1
117+
cat packagist_db.sql | kubectl exec -it statefulsets/postgres -- psql -U postgres -d packagist_db
105118
```
106119

107-
### Restore the Redis database
120+
### Import the Redis database
108121

109-
Follow the instructions below to restore the Redis database in the cluster.
122+
Follow the instructions below to restore the Redis database for Private Packagist Self-Hosted without an existing Kubernetes cluster.
110123
If you are using your own Redis instance, use the `packagist_redis.rdb` file directly to [restore Redis from an RDB file](https://redis.io/learn/guides/import#restore-an-rdb-file) or follow the instructions of your hosted service provider.
124+
If you are installing Private Packagist Self-Hosted in an existing cluster and aren't planning on using your own Redis then please contact us.
125+
126+
After each scale command, use `kubectl get pods` again to verify that the redis pod is in the correct running state.
111127

112-
Follow these steps if you are using Private Packagist Self-Hosted with an embeded Kubernetes cluster
113128
```
114-
export PV_NAME=$(kubectl get pvc -n default redis-data-redis-0 -ojsonpath='{.spec.volumeName}')
129+
export PV_NAME=$(kubectl get pvc redis-data-redis-0 -ojsonpath='{.spec.volumeName}')
115130
kubectl scale statefulset -n default redis --replicas 0
116131
rm /var/openebs/local/$PV_NAME/appendonly.aof
117132
cp packagist_redis.rdb /var/openebs/local/$PV_NAME/dump.rdb
118-
kubectl scale statefulset -n default redis --replicas 1
133+
kubectl scale statefulset redis --replicas 1
119134
```
120135

121-
### Restore the dist and artifact files
136+
### Import the dist and artifact files
137+
138+
Importing the dist and artifact files requires the UI pods to be back online via the command below. This will take a few seconds.
139+
You can use the second command to verify once 2/2 pods are running.
140+
```
141+
kubectl scale statefulset ui --replicas 1
142+
kubectl get pods -w
143+
```
122144

123145
Please note that depending on the size of the `packagist_storage.tar.gz` file and the type of blob storage that you have configured
124146
it can take several minutes for this command to finish.
125147

126148
```
127-
kubectl scale statefulset -n default ui --replicas 1
128-
kubectl cp -n default packagist_storage.tar.gz ui:/tmp/packagist_storage.tar.gz
129-
kubectl exec -n default ui /srv/manager/bin/console packagist:self-hosted:migrate-storage import /tmp/packagist_storage.tar.gz && rm /tmp/packagist_storage.tar.gz
149+
kubectl cp packagist_storage.tar.gz ui:/tmp/packagist_storage.tar.gz
150+
kubectl exec ui /srv/manager/bin/console packagist:self-hosted:migrate-storage import /tmp/packagist_storage.tar.gz && rm /tmp/packagist_storage.tar.gz
151+
130152
```
131153

132154
### Start the Private Packagist application
133155

134-
Once your data has been restored. Restart the application, log in to Private Packagist, and verify that your organization
135-
and packages are there again.
156+
Once your data has been restored. Start the application:
136157

137158
```
138-
kubectl scale deployment ui --replicas 1 -n default
159+
kubectl scale deployment ui --replicas 1
139160
```
140161

162+
This can take a few minutes. You can run the command below to see when all pods are back up and running.
163+
164+
```
165+
kubectl get pods -w
166+
```
167+
168+
Once the all pods are back up and running. Log in to Private Packagist and verify that your organization is shown in the UI.
169+
Ideally, run a `composer update` command in one of your projects to assert that the Composer repository and any of the
170+
background workers run as expected.
171+
141172
### Adjust domain names
142173

143174
In case you initially set up Private Packagist Self-Hosted Kubernetes with a different domain name, you can now edit the

0 commit comments

Comments
 (0)