Skip to content

Commit

Permalink
Support BTRFS and ZFS docker storage
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aojea committed Apr 7, 2020
1 parent 92cca75 commit d198c7a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cluster/internal/providers/docker/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ func commonArgs(cluster string, cfg *config.Cluster) ([]string, error) {
if usernsRemap() {
args = append(args, "--userns=host")
}

// handle Docker on Btrfs or ZFS
// https://github.com/kubernetes-sigs/kind/issues/1416#issuecomment-606514724
if mountDevMapper() {
args = append(args, "--volume", "/dev/mapper", "/dev/mapper")
}

return args, nil
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/cluster/internal/providers/docker/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,17 @@ func usernsRemap() bool {
}
return false
}

// mountDevMapper checks if the Docker storage driver is Btrfs or ZFS
func mountDevMapper() bool {
storage := ""
cmd := exec.Command("docker", "info", "-f", "{{.Driver}}")
lines, err := exec.CombinedOutputLines(cmd)
if err != nil {
return false
}
if len(lines) > 0 {
storage = strings.ToLower(strings.TrimSpace(lines[0]))
}
return storage == "btrfs" || storage == "zfs"
}

0 comments on commit d198c7a

Please sign in to comment.