Varlink is an interface description format and protocol that aims to make services accessible to both humans and machines in the simplest feasible way.
First, install the varlink
command line tool.
$ tce-load -wi compiletc
$ tce-load -wi git meson
$ git clone https://github.com/varlink/libvarlink
$ cd libvarlink
$ sed -e 's|/usr/bin/python3|/usr/bin/env python3|' -i varlink-wrapper.py
$ meson build --prefix=/usr/local && ninja -C build
$ sudo install -D -m 755 build/tool/varlink /usr/local/bin/varlink
Second, install the libvarlink
library (and -dev).
$ sudo install -D -m 755 build/lib/libvarlink.so.* /usr/local/lib/
$ sudo install -D -m 644 lib/varlink.h /usr/local/include/
$ sudo install -D -m 755 build/lib/libvarlink.so /usr/local/lib/
$ sudo install -D -m 644 build/lib/libvarlink.pc /usr/local/lib/pkgconfig/
Start the podman service, and set up a symlink.
# podman varlink --timeout 0 unix:/var/run/podman.sock &
# mkdir -p /run/podman
# chmod 0700 /run/podman
# ln -s /var/run/podman.sock /run/podman/io.podman
Normally this is done by using the init script:
$ sudo /usr/local/etc/init.d/podman start
Test the connection, by running a simple info
:
$ sudo varlink info unix://run/podman/io.podman
Vendor: Atomic
Product: podman
Version: 0.9.4-dev
URL: https://github.com/containers/libpod
Interfaces:
org.varlink.service
io.podman
Public varlink interfaces are registered system-wide by their well-known address, by default /run/org.varlink.resolver. The resolver translates a given varlink interface to the service address which provides this interface.
Build the resolver
against libvarlink.so
above.
$ tce-load -wi compiletc
$ tce-load -wi git meson
$ git clone https://github.com/varlink/org.varlink.resolver
$ cd org.varlink.resolver
$ make
$ sudo install -D -m 755 build/src/*resolver /usr/local/sbin/resolver
This needs to define all services to be resolved.
{
"services": [
{
"address": "unix:/run/org.varlink.resolver;mode=0666",
"interfaces": [
"org.varlink.resolver"
]
},
{
"address": "unix:/run/podman/io.podman;mode=0600",
"interfaces": [
"io.podman"
]
}
]
}
Start the resolver service, creating the socket.
# sysconfdir=/usr/local/etc
# resolver --varlink=unix:/run/org.varlink.resolver --config=$sysconfdir/varlink.json
Normally this is done by using the init script:
$ sudo /usr/local/etc/init.d/varlink start
Now you can resolve services, to their sockets:
$ sudo varlink resolve io.podman
unix:/run/podman/io.podman;mode=0600