Skip to content

Commit 1cc4674

Browse files
authored
Merge pull request #215 from quirky4/eportal_docker_doc
added documentation on using the ePortal docker image
2 parents 0523c36 + cc7169c commit 1cc4674

File tree

1 file changed

+133
-2
lines changed

1 file changed

+133
-2
lines changed

docs/eportal/README.md

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,99 @@ Install ePortal:
201201
# apt update && apt install -y --no-install-recommends kcare-eportal
202202
```
203203

204+
### Docker image
205+
Simple run:
206+
207+
```text
208+
docker run -d --rm --network=host kernelcare/eportal:latest
209+
```
210+
211+
Run with persistent volume:
212+
213+
```text
214+
docker run -d --rm --network=host \
215+
-v eportal-volume:/var/lib/eportal/data/ \
216+
kernelcare/eportal:latest
217+
```
218+
219+
or mount:
220+
221+
```text
222+
docker run -d --rm --network=host \
223+
-v /var/lib/eportal/data:/var/lib/eportal/data/ \
224+
kernelcare/eportal:latest
225+
````
226+
227+
run with unprevileged user:
228+
229+
**WARNING**: Volume or mount should be provided, and the owner of the host folder
230+
should be equal to the UID that is used with ```--user``` option.
231+
```--network=host``` option can't be used in this mode.
232+
233+
```text
234+
docker run -d --rm \
235+
-v /var/lib/eportal/data:/var/lib/eportal/data/ \
236+
--user <uid of user> kernelcare/eportal:latest
237+
```
238+
239+
The ePortal image uses several environment variables which are useful for the advanced configuration
240+
241+
| Environment variable | Description | Default value |
242+
| ---------------------------------------- | ------------------------------------------------------------------------------------ | ------------- |
243+
| EPORTAL_SERVER_STATS_PERIOD | timeout in seconds when eportal send usage statistics | 1 day |
244+
| EPORTAL_AUTO_UPDATE_PERIOD | timeout in seconds when eportal tries to pull updates | 10 min |
245+
| EPORTAL_LIMIT_PATCHSETS | process at most N latest patches from patchserver | None (all) |
246+
| EPORTAL_PROXY | proxy connection string | unset |
247+
| EPORTAL_REDUCED_REPORT | do not send detailed stats to patchserver | False |
248+
| EPORTAL_NODE_URL | this node URL (replication setup) | unset |
249+
| EPORTAL_LEADER_URL | leader node URL (replication setup) | unset |
250+
| EPORTAL_REPLICATION_SHARED_KEY | shared secret for replicas (replication setup) | unset |
251+
| EPORTAL_REPLICATION_CHECK_CERT | whether to check node certificate | True |
252+
| EPORTAL_REPLICATION_CLEAN_AGE | replication log retention period in seconds | 7 days |
253+
| EPORTAL_REPLICATION_CLEAN_AGGRESSIVE_AGE | retention period for aggressive policy | 1 hour |
254+
| EPORTAL_REPLICATION_STANDBY | passive mode for node (only receiving changes) | False |
255+
| EPORTAL_CACHE_MODE | pass patch request directly to patchserver without preliminary downloading patchsets | False |
256+
| EPORTAL_PATCH_SOURCE_URL | patch source | https://downloads.kernelcare.com/patch-download/ |
257+
| EPORTAL_PATCH_SOURCE_USER | patch source user, if set, will overwrite patch source configuration in UI | unset |
258+
| EPORTAL_PATCH_SOURCE_PASSWORD | patch source password | unset |
259+
| EPORTAL_BUNITS | enable business units feature (multi tenancy) | False |
260+
| EPORTAL_BUNITS_LOGIN_SELECTOR | allows to select business unit when logging in | False |
261+
| EPORTAL_RADAR_PROXY_ENABLE | enable TuxCare RADAR proxying | False |
262+
| EPORTAL_RADAR_PROXY_BASEURL | TuxCare RADAR URL | https://radar.tuxcare.com |
263+
| EPORTAL_SEND_CHECKIN_PERIOD | servers check-ins report period in seconds | 1 day |
264+
265+
266+
For example, if you need to send reduced stats:
267+
268+
```text
269+
docker run -d --rm --network=host \
270+
-e EPORTAL_REDUCED_REPORT=1 \
271+
-v eportal-volume:/var/lib/eportal/data/ \
272+
kernelcare/eportal:latest
273+
```
274+
275+
Users management command should be executed in the running container. For example, to create an admin user:
276+
277+
```text
278+
docker exec <container-id> kc.eportal -a admin -p AdminPassword
279+
```
280+
281+
#### Image upgrade and downgrade
282+
283+
Typically, upgrading or downgrading ePortal image does not require any additional actions.
284+
285+
Special cases of downgrading:
286+
* Downgrade **from** versions <= 2.11-1 is not supported
287+
* Downgrade **to** versions <= 2.11-1 requires additional steps.
288+
For example, having data dir created with kernelcare/eportal:2.12-1,
289+
you want to downgrade to kernelcare/eportal:2.8-1.
290+
First, make a backup of eportal-volume, then proceed with
291+
```text
292+
docker run --rm -v eportal-volume:/var/lib/eportal/data --entrypoint=python3.8 \
293+
-it kernelcare/eportal:2.8-1 /var/lib/eportal/data/migration/migratedb.py
294+
```
295+
Then you can use kernelcare/eportal:2.8-1 image to run container as usual.
296+
204297
## Allowed hosts
205298

206299
We must declare the list of allowed hosts in the configuration for security reasons. It help to avoid HTTP Host header attacks. According to your installation, you need to add this parameter into [ePortal config file](#config-files):
@@ -1389,7 +1482,7 @@ If you migrate from Debian-based to Debian-based system you can simply:
13891482
* Stop ePortal on both hosts.
13901483
* Copy `/var/lib/eportal` to a new host. Note: directory owner must stay as `eportal:eportal`.
13911484
* Copy config `/etc/eportal/config` if it exists.
1392-
* Run migration `/usr/share/kcare-eportal/migratedb.py --upgrade` on a new host.
1485+
* Run migration `/usr/share/kcare-eportal/migratedb.py` on a new host.
13931486
* Start ePortal on a new host.
13941487

13951488
Migration from RHEL-based distro is more elaborate. Later we refer to a `$BASE_DIR` variable in scripts. You can export it for RHEL-based distros:
@@ -1449,14 +1542,30 @@ For Debian-based distros:
14491542
[new-host ~]# chown -R eportal:eportal $BASE_DIR
14501543
```
14511544

1452-
* Run migration `/usr/share/kcare-eportal/migratedb.py --upgrade` on a new host.
1545+
* Run migration `/usr/share/kcare-eportal/migratedb.py` on a new host.
14531546

14541547
* Start ePortal on the new host:
14551548

14561549
```text
14571550
[new-host ~]# systemctl start eportal
14581551
```
14591552

1553+
### Migration to docker container
1554+
1555+
Let's suppose that we're going to use dockerized eportal on the same host.
1556+
1557+
The easiest way to migrate is to reuse the data directory. It can be mounted when the container starts.
1558+
1559+
```text
1560+
docker run -d --rm --network=host -v /var/lib/eportal:/var/lib/eportal/data kernelcare/eportal:latest
1561+
```
1562+
1563+
If you prefer to use a named volume for data-dir then all data should be copied from ```/var/lib/eportal``` to the volume (see [Docker docs](https://docs.docker.com/reference/cli/docker/container/cp/))
1564+
1565+
If you have custom configuration at ```/etc/eportal/config``` you can pass it using environment variables or
1566+
mount this configuration file directly into the container like this ```-v /etc/eportal/config:/etc/eportal/config:ro```
1567+
1568+
14601569
## Backup and restore
14611570

14621571
### Create backup
@@ -1489,6 +1598,28 @@ For example:
14891598
`download-missing` commands ensure patchset state on disk corresponds with a state
14901599
in db.
14911600

1601+
### Backup and restore for ePortal docker container
1602+
1603+
Volume backup process can be performed according to the instructions given [here](https://docs.docker.com/engine/storage/volumes/#back-up-restore-or-migrate-data-volumes).
1604+
For example:
1605+
```text
1606+
docker run --rm --volumes-from eportal -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /var/lib/eportal/data/
1607+
```
1608+
1609+
or if you want to make a backup without patches (only configs and the database)
1610+
```text
1611+
docker run --rm --volumes-from eportal -v $(pwd):/backup ubuntu tar
1612+
--exclude '/var/lib/eportal/data/patches'
1613+
--exclude '/var/lib/eportal/data/arch'
1614+
--exclude '/var/lib/eportal/data/resources'
1615+
-cvf /backup/backup.tar /var/lib/eportal/data/
1616+
```
1617+
1618+
That backup could be restored like this
1619+
```text
1620+
docker run --rm --volumes-from eportal2 -v $(pwd):/backup ubuntu bash -c "cd / && tar xvf /backup/backup.tar"
1621+
```
1622+
14921623
## Config files
14931624

14941625
* ePortal config: `/etc/eportal/config`. Config for old versions (<1.35): `/usr/share/kcare-eportal/local.py`.

0 commit comments

Comments
 (0)