Hello,
I was able to share a directory on my host with charmed applications running in lxd containers (localhost provider) using Juju’s built in mechanism for supplying a supplemental lxd profile as a file in the charm.
In my initial attempt to do this, I provided a lxd profile to the charm containing a disk device, where the source
, /media
is a directory on my host, and the path
, /nfs
is the target location in the container.
$ cat ../slurm-charms/charm-slurmd/lxd-profile.yaml
config: {}
description: ""
devices:
shared:
path: /nfs
source: /media
type: disk
name: shared
I built the charm and deployed it, and was able to see the source file from the host in the desired target location in the container.
$ ls /media
myfile.txt
$ juju run --application slurmd "ls -la /nfs"
- Stdout: |
total 6
drwxrwxrwx 2 nobody nogroup 4096 Sep 3 22:00 .
drwxr-xr-x 19 root root 25 Sep 3 21:52 ..
-rw-r--r-- 1 root root 0 Sep 3 22:00 myfile.txt
UnitId: slurmd/0
- Stdout: |
total 6
drwxrwxrwx 2 nobody nogroup 4096 Sep 3 22:00 .
drwxr-xr-x 19 root root 25 Sep 3 21:55 ..
-rw-r--r-- 1 root root 0 Sep 3 22:00 myfile.txt
UnitId: slurmd/1
- Stdout: |
total 6
drwxrwxrwx 2 nobody nogroup 4096 Sep 3 22:00 .
drwxr-xr-x 19 root root 25 Sep 3 21:55 ..
-rw-r--r-- 1 root root 0 Sep 3 22:00 myfile.txt
UnitId: slurmd/2
- Stdout: |
total 6
drwxrwxrwx 2 nobody nogroup 4096 Sep 3 22:00 .
drwxr-xr-x 19 root root 25 Sep 3 21:55 ..
-rw-r--r-- 1 root root 0 Sep 3 22:00 myfile.txt
UnitId: slurmd/3
Using the lxd-profile.yaml
file in the charm, I was able to accomplish sharing the host directory with the containers.
One drawback I found to providing lxd profiles to charmed applications in this way, is that you must rebuild a charm if you want to supply a different lxd profile. I feel like this experience of applying a supplemental lxd profile is powerful and that it could be more powerful if it was extended to be used in a more dynamic way other than having to bake the lxd-profile.yaml
file into the charm.
Looking at the application-config
, I’m thinking it may be a reasonable location to account for the lxd-profile
such that a user might supply the supplemental lxd-profile
at deploy time.
Example: juju deploy slurmd --lxd-profile="$(base64 my-lxd-profile.yaml)"
Where the lxd-profile
is part of the application-config
:
$ juju config slurmd
application: slurmd
application-config:
trust:
default: false
description: Does this application have access to trusted credentials
source: default
type: bool
value: false
lxd-profile:
default: ""
source: default
type: string
description: Supplemental lxd profile directives.
value: <base64-encoded-string>
Ultimately, I am wondering what others thoughts are concerning lxd-profile
existing as an application-config
?
Thanks