@@ -3,80 +3,62 @@ id: policy-package-deployment
3
3
title : Deploying a Policy Package
4
4
---
5
5
6
- It is now common to deploy Rucio using containers managed by software
7
- such as Docker and Kubernetes. This section of the documentation is
8
- intended to give guidance on how policy packages can be deployed in
9
- this type of environment.
10
-
11
6
Broadly speaking, three things must happen in order for a policy
12
7
package to be deployed successfully:
13
8
14
9
1 . The policy package code must be available to the Rucio server
15
10
(and possibly other components such as daemons).
16
11
1 . The directory containing the policy package must be in the server's
17
12
` PYTHONPATH ` .
18
- 1 . The policy package name must be set in the Rucio configuration file,
19
- or using the ` RUCIO_POLICY_PACKAGE ` environment variable.
20
-
21
- ### Installing the policy package
22
-
23
- There are a few possible ways to get the policy package code into the
24
- container where the server runs. One way is to build a custom
25
- experiment-specific container image based on the generic Rucio server
26
- image, and to install the policy package at build time in the
27
- ` Dockerfile ` , either by directly copying the files in, or by installing
28
- it from some sort of repository. For experiments that already customise
29
- the container image, this is likely to be the easiest option.
13
+ 1 . Rucio must be configured to find the policy package.
30
14
31
- Alternatively, the standard Rucio container can be used and a volume
32
- containing the policy package files can be mounted at run time (using
33
- the ` -v ` or ` --volume ` command line flag). When using Kubernetes, there
34
- is also a third possibility: use an
35
- [ init container] ( https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ )
36
- to install the policy package onto a shared volume, which is then mounted
37
- by the server container when it starts up.
15
+ ## Deploying a policy package
38
16
39
- ### Adding the policy package to the server's PYTHONPATH
17
+ The table below describes the different approaches you can use to deploy a policy package.
40
18
41
- It is possible to set environment variables within the container when
42
- starting it (using Docker's ` -e ` command line flag). This can be used to
43
- set ` PYTHONPATH ` , however this will replace the original value rather
44
- than appending to it, so there is a risk of removing other important
45
- items from the path. A safer option is to override Rucio's
46
- ` docker-entrypoint.sh ` script and instead use a script that appends the
47
- policy package's directory to ` PYTHONPATH ` before starting the HTTP server.
48
- This can be done either at build time in the ` Dockerfile ` , or at run time
49
- using the ` --entrypoint ` command line option.
19
+ | Approach / columns | Ease of setup | Amount of work needed for new Rucio and new policy package versions | Extra external dependencies at runtime |
20
+ | -------------------------------------------- | --------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
21
+ | Kubernetes init container | Easy | | Index (e.g. PyPI) or Git registry (e.g. GitLab) in question (if a new policy package version is released) |
22
+ | Pass build argument to Dockerfile | Easy | - Building + hosting the image yourself - Rebuilding the image - Redeploying | Registry where you host the image (no more risk than what is already there, assuming your registry is as reliable as DockerHub) |
23
+ | Generate YAML and add as Kubernetes secret | Medium | - Need to duplicate actual policy package content into configuration | None |
50
24
51
- When deploying using Kubernetes and Helm charts, it is possible to specify
52
- the policy package directory in the ` optional_config: ` section of
53
- ` values.yaml ` . This is then propagated to the container as an environment
54
- variable, which can be added to ` PYTHONPATH ` by the entry point script. For
55
- example, include this in ` values.yaml ` :
25
+ ### Deploying via Kubernetes init container
26
+ In the ` values.yaml ` for ` server ` and ` daemons ` (and optionally for ` ui ` / ` webui ` ), under ` policyPackages ` :
27
+ 1 . Set ` policyPackages.enabled ` to ` true `
28
+ 2 . List your policy packages under ` policyPackages.packages ` in the following format:
29
+ ```
30
+ example: install from an index (default is PyPI)
31
+ - moduleName: vo_1_policy_package
32
+ requirement: vo_1_policy_package==1.4.0
33
+ version: 1.4.0
34
+ example: install from a git repository
35
+ - moduleName: vo_2_policy_package
36
+ requirement: git+https://github.com/vo-2/[email protected]
37
+ version: 0.1.0
38
+ ```
39
+ 3 . (Optional) set ` policyPackages.pvc.createPvc ` to true to create a PVC for the policy packages; leave false if providing it separately.
56
40
57
- ``` yaml
58
- optional_config :
59
- policy_pkg_path : /opt/rucio/policy
41
+ ### Deploying via Dockerfile build argument
42
+ 1 . In the ` server ` , ` clients ` , ` daemons ` , ` ui ` and ` init ` containers, pass the ` POLICY_PACKAGE_REQUIREMENTS ` build argument. Example:
43
+ Example:
44
+ ```
45
+ docker build -t server --build-arg POLICY_PACKAGE_REQUIREMENTS=vo_1_policy_package==0.4.0,git+https://github.com/vo-2/[email protected]
60
46
```
61
47
62
- This will appear in the container's environment as a variable called
63
- ` POLICY_PKG_PATH`, which can be added to `PYTHONPATH` by the entry point
64
- script before starting the server :
48
+ ### Deploying via Kubernetes secret
49
+ You can generate ` yaml ` for all the files included in your policy package,
50
+ and add them as Kubernetes secrets.
51
+ You can find information in the [ Kubernetes guide] ( operator/k8s_guide.md ) on how to create and manage secrets.
65
52
66
- ` ` ` bash
67
- if [ ! -z "$POLICY_PKG_PATH" ]; then
68
- export PYTHONPATH=${POLICY_PKG_PATH}:${PYTHONPATH:+:}${PYTHONPATH}
69
- fi
70
- ` ` `
53
+ This process can be somewhat automated by having a cronjob that creates the secret policy and applies it.
71
54
72
- # ## Specifying the policy package in the configuration file
73
55
74
- It is likely that most experiments are already customising the Rucio
75
- configuration file, in which case the policy package (`package = name` in
76
- the `[policy]` section) can simply be added to the existing customised file.
77
- Alternatively, the package name can be set in the `RUCIO_POLICY_PACKAGE`
78
- environment variable (see previous section for how to pass environment
79
- variables into the server container) .
56
+ ## Configuring Rucio to find a policy package
57
+ To configure Rucio, you should either:
58
+ 1 . Modify the configuration file, by adding the package name as ` package = name ` in
59
+ the ` [policy] ` section, or
60
+ 2 . Setting the the package name in the ` RUCIO_POLICY_PACKAGE `
61
+ environment variable .
80
62
81
63
When deploying using Kubernetes and Helm charts, it is possible to specify
82
64
configuration options in ` values.yaml ` . Values included in the ` config: `
@@ -86,5 +68,5 @@ section of this file are automatically merged into `rucio.cfg` by the
86
68
``` yaml
87
69
config :
88
70
policy :
89
- package: packagename
71
+ package : name
90
72
` ` `
0 commit comments