[Bug]: k3s > 1.24.x will not start
Module
K3S
Testcontainers version
1.17.6
Using the latest Testcontainers version?
Yes
Host OS
Ubuntu 20.04 on WSL2 on Windows 11
Host Arch
x86
Docker version
Client:
Version: 20.10.12
API version: 1.41
Go version: go1.16.2
Git commit: 20.10.12-0ubuntu2~20.04.1
Built: Wed Apr 6 02:14:38 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Desktop
Engine:
Version: 20.10.23
API version: 1.41 (minimum version 1.12)
Go version: go1.18.10
Git commit: 6051f14
Built: Thu Jan 19 17:32:04 2023
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: 1.6.18
GitCommit: 2456e983eb9e37e47538f59ea18f2043c9a73640
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
What happened?
k3s testcontainer will not start. Log message: for k3s 1.25.x
no-deploy flag is deprecated. Use --disable instead.
for k3s 1.26.x
flag provided but not defined: -no-deploy
I traced it back to this line https://github.com/testcontainers/testcontainers-java/blob/c90daab5d80adb692f213fa5f02c108a329105d5/modules/k3s/src/main/java/org/testcontainers/k3s/K3sContainer.java#L44
see also https://docs.k3s.io/reference/server-config#deprecated-options
Workaround is to use k3s<=1.24.x
Relevant log output
No response
Additional Information
No response
It seems to be a matter of starting a container with another flag as per this docs page: https://docs.k3s.io/faq#how-can-i-use-my-own-ingress-instead-of-traefik
Overriding withCommand should fix it. Still not sure how to fix it, we can use ComparableVersion but we can reach out the point of abusing of it at certain point.
In my case, it worked with withCommand as follows.
DockerImageName
.parse("rancher/k3s:v1.25.10-k3s1"))
.withLogConsumer(Slf4jLogConsumer(logger))
.withCommand(
"server",
"--disable=traefik",
"--tls-san=${DockerClientFactory.instance().dockerHostIpAddress()}")
The flag --no-deploy was deprecated and replaced by --disable, many years ago (somewhere in k3s:v1.17.x ?).
The flag was finally removed in v1.25.0, more than a year ago.
https://docs.k3s.io/cli/server#deprecated-options
That means this module is broken out of the box for more than a year.
Switching to the --disable flag is the less surprising thing to do: it works from the current k3s:v1.25.14 and all the way back to k3s:v1.17.17 (from 3 years ago).