forked from mirrors/nixpkgs
nixos/podman-dnsname: init
This commit is contained in:
parent
d81631fb98
commit
54f2f1e5f1
5 changed files with 84 additions and 0 deletions
36
nixos/modules/virtualisation/podman-dnsname.nix
Normal file
36
nixos/modules/virtualisation/podman-dnsname.nix
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkOption
|
||||||
|
mkIf
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.virtualisation.podman;
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
virtualisation.podman = {
|
||||||
|
|
||||||
|
defaultNetwork.dnsname.enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Enable DNS resolution in the default podman network.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
virtualisation.containers.containersConf.cniPlugins = mkIf cfg.defaultNetwork.dnsname.enable [ pkgs.dnsname-cni ];
|
||||||
|
virtualisation.podman.defaultNetwork.extraPlugins =
|
||||||
|
lib.optional cfg.defaultNetwork.dnsname.enable {
|
||||||
|
type = "dnsname";
|
||||||
|
domainName = "dns.podman";
|
||||||
|
capabilities.aliases = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -39,6 +39,7 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./podman-dnsname.nix
|
||||||
./podman-network-socket.nix
|
./podman-network-socket.nix
|
||||||
(lib.mkRenamedOptionModule [ "virtualisation" "podman" "libpod" ] [ "virtualisation" "containers" "containersConf" ])
|
(lib.mkRenamedOptionModule [ "virtualisation" "podman" "libpod" ] [ "virtualisation" "containers" "containersConf" ])
|
||||||
];
|
];
|
||||||
|
|
|
@ -335,6 +335,7 @@ in
|
||||||
plotinus = handleTest ./plotinus.nix {};
|
plotinus = handleTest ./plotinus.nix {};
|
||||||
podgrab = handleTest ./podgrab.nix {};
|
podgrab = handleTest ./podgrab.nix {};
|
||||||
podman = handleTestOn ["x86_64-linux"] ./podman.nix {};
|
podman = handleTestOn ["x86_64-linux"] ./podman.nix {};
|
||||||
|
podman-dnsname = handleTestOn ["x86_64-linux"] ./podman-dnsname.nix {};
|
||||||
podman-tls-ghostunnel = handleTestOn ["x86_64-linux"] ./podman-tls-ghostunnel.nix {};
|
podman-tls-ghostunnel = handleTestOn ["x86_64-linux"] ./podman-tls-ghostunnel.nix {};
|
||||||
pomerium = handleTestOn ["x86_64-linux"] ./pomerium.nix {};
|
pomerium = handleTestOn ["x86_64-linux"] ./pomerium.nix {};
|
||||||
postfix = handleTest ./postfix.nix {};
|
postfix = handleTest ./postfix.nix {};
|
||||||
|
|
42
nixos/tests/podman-dnsname.nix
Normal file
42
nixos/tests/podman-dnsname.nix
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import ./make-test-python.nix (
|
||||||
|
{ pkgs, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (pkgs) writeTextDir python3 curl;
|
||||||
|
webroot = writeTextDir "index.html" "<h1>Hi</h1>";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
name = "podman-dnsname";
|
||||||
|
meta = {
|
||||||
|
maintainers = with lib.maintainers; [ roberth ] ++ lib.teams.podman.members;
|
||||||
|
};
|
||||||
|
|
||||||
|
nodes = {
|
||||||
|
podman = { pkgs, ... }: {
|
||||||
|
virtualisation.podman.enable = true;
|
||||||
|
virtualisation.podman.defaultNetwork.dnsname.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
podman.wait_for_unit("sockets.target")
|
||||||
|
|
||||||
|
with subtest("DNS works"): # also tests inter-container tcp routing
|
||||||
|
podman.succeed("tar cv --files-from /dev/null | podman import - scratchimg")
|
||||||
|
podman.succeed(
|
||||||
|
"podman run -d --name=webserver -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin -w ${webroot} scratchimg ${python3}/bin/python -m http.server 8000"
|
||||||
|
)
|
||||||
|
podman.succeed("podman ps | grep webserver")
|
||||||
|
podman.succeed("""
|
||||||
|
for i in `seq 0 120`; do
|
||||||
|
podman run --rm --name=client -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg ${curl}/bin/curl http://webserver:8000 >/dev/console \
|
||||||
|
&& exit 0
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
""")
|
||||||
|
podman.succeed("podman stop webserver")
|
||||||
|
podman.succeed("podman rm webserver")
|
||||||
|
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
|
@ -28,6 +28,10 @@ buildGoModule rec {
|
||||||
|
|
||||||
doCheck = false; # NOTE: requires root privileges
|
doCheck = false; # NOTE: requires root privileges
|
||||||
|
|
||||||
|
passthru.tests = {
|
||||||
|
inherit (nixosTests) podman-dnsname;
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "DNS name resolution for containers";
|
description = "DNS name resolution for containers";
|
||||||
homepage = "https://github.com/containers/dnsname";
|
homepage = "https://github.com/containers/dnsname";
|
||||||
|
|
Loading…
Add table
Reference in a new issue