Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,38 @@ func runE(cmd *cobra.Command, args []string) error {
config.DefaultConfig.ControlPlaneConnectivity = config.Portmap

// initialize kind provider
// Check KIND_EXPERIMENTAL_PROVIDER directly, as the kind CLI does, so it
// takes effect regardless of auto-detection results.
var option cluster.ProviderOption
switch p := container.Runtime(); p {
case "podman":
option = cluster.ProviderWithPodman()
case "nerdctl", "finch", "nerdctl.lima":
option = cluster.ProviderWithNerdctl(p)
default:
option = cluster.ProviderWithDocker()
if p := os.Getenv("KIND_EXPERIMENTAL_PROVIDER"); p != "" {
switch p {
case "podman":
klog.Infof("Using podman provider due to KIND_EXPERIMENTAL_PROVIDER")
option = cluster.ProviderWithPodman()
container.SetRuntime("podman")
case "docker":
klog.Infof("Using docker provider due to KIND_EXPERIMENTAL_PROVIDER")
option = cluster.ProviderWithDocker()
container.SetRuntime("docker")
case "nerdctl", "finch", "nerdctl.lima":
klog.Infof("Using %s provider due to KIND_EXPERIMENTAL_PROVIDER", p)
option = cluster.ProviderWithNerdctl(p)
container.SetRuntime(p)
default:
klog.Warningf("Ignoring unknown KIND_EXPERIMENTAL_PROVIDER value %q", p)
}
}
if option == nil {
p := container.DetectRuntime()
container.SetRuntime(p)
switch p {
case "podman":
option = cluster.ProviderWithPodman()
case "nerdctl", "finch", "nerdctl.lima":
option = cluster.ProviderWithNerdctl(p)
default:
option = cluster.ProviderWithDocker()
}
}
kindProvider := cluster.NewProvider(
option,
Expand Down
22 changes: 11 additions & 11 deletions pkg/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ func Runtime() string {
return containerRuntime
}

func init() {
// allow to override the container provider as we do in KIND
if p := os.Getenv("KIND_EXPERIMENTAL_PROVIDER"); p != "" {
containerRuntime = p
return
}
// SetRuntime overrides the auto-detected container runtime.
func SetRuntime(name string) {
containerRuntime = name
}

// DetectRuntime probes the system for an available container runtime.
func DetectRuntime() string {
if dockerIsAvailable() {
return
return "docker"
}
if podmanIsAvailable() {
containerRuntime = "podman"
return
return "podman"
}
if nerdctlIsAvailable() {
containerRuntime = "nerdctl"
if _, err := exec.LookPath("nerdctl"); err != nil {
if _, err := exec.LookPath("finch"); err == nil {
containerRuntime = "finch"
return "finch"
}
}
return "nerdctl"
}
return "docker"
}

func Logs(name string, w io.Writer) error {
Expand Down
Loading