From c978ca0d263e09d78677b68c1ff769b8e406b369 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Mon, 6 Apr 2020 18:35:33 +0200 Subject: [PATCH] Support BTRFS and ZFS docker storage It seems that mounting /dev/mapper from the host to the kind nodes remove the limitation on Docker of using BTRFS or ZFS https://kind.sigs.k8s.io/docs/user/known-issues/#docker-on-btrfs-or-zfs --- .../internal/providers/docker/provision.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pkg/cluster/internal/providers/docker/provision.go b/pkg/cluster/internal/providers/docker/provision.go index e769fd8a45..bf2a5ad47c 100644 --- a/pkg/cluster/internal/providers/docker/provision.go +++ b/pkg/cluster/internal/providers/docker/provision.go @@ -164,9 +164,32 @@ func commonArgs(cluster string, cfg *config.Cluster) ([]string, error) { if usernsRemap() { args = append(args, "--userns=host") } + + // handle Docker on Btrfs or ZFS + dockerStorage, err := getDockerStorage() + if err != nil { + return nil, errors.Wrap(err, "can't get Docker Storage") + } + if dockerStorage == "btrfs" || dockerStorage == "zfs" { + args = append(args, "--volume", "/dev/mapper", "/dev/mapper") + } + return args, nil } +// get docker Storage Driver +func getDockerStorage() (string, error) { + cmd := exec.Command("docker", "info", "-f", "{{.Driver}}") + lines, err := exec.CombinedOutputLines(cmd) + if err != nil { + return "", errors.Wrap(err, "failed to get storage") + } + if len(lines) != 1 { + return "", errors.Errorf("docker info should return one line, got %d lines", len(lines)) + } + return strings.ToLower(strings.TrimSpace(lines[0])), nil +} + func runArgsForNode(node *config.Node, clusterIPFamily config.ClusterIPFamily, name string, args []string) ([]string, error) { args = append([]string{ "run",