@@ -10,6 +10,7 @@ import (
1010 "strings"
1111
1212 "github.com/juanfont/headscale/integration/dockertestutil"
13+ "github.com/juanfont/headscale/integration/k3sic"
1314)
1415
1516const (
@@ -21,6 +22,7 @@ const (
2122 nameDockerContext = "Docker Context"
2223 nameDockerSocket = "Docker Socket"
2324 nameGolangImage = "Golang Image"
25+ nameK3sImage = "K3s Image"
2426 nameGoInstall = "Go Installation"
2527)
2628
@@ -66,6 +68,7 @@ func runDoctorCheck(ctx context.Context) error {
6668 results = append (results , checkDockerSocket (ctx ))
6769 results = append (results , checkDockerHubCredentials ())
6870 results = append (results , checkGolangImage (ctx ))
71+ results = append (results , checkK3sImage (ctx ))
6972 }
7073
7174 // Check 3: Go installation
@@ -242,6 +245,47 @@ func checkGolangImage(ctx context.Context) DoctorResult {
242245 return pass (nameGolangImage , fmt .Sprintf ("Golang image %s is now available" , imageName ))
243246}
244247
248+ // checkK3sImage verifies the rancher/k3s image used by TestK8sOperator is
249+ // available locally or can be pulled. Like the golang image, the public
250+ // rancher/k3s image is rate-limited on anonymous Docker Hub pulls, so this
251+ // check doubles as a reminder to configure Docker Hub credentials.
252+ func checkK3sImage (ctx context.Context ) DoctorResult {
253+ cli , err := createDockerClient (ctx )
254+ if err != nil {
255+ return fail (nameK3sImage , "Cannot create Docker client for image check" )
256+ }
257+ defer cli .Close ()
258+
259+ imageName := k3sic .K3sImage
260+
261+ available , err := checkImageAvailableLocally (ctx , cli , imageName )
262+ if err != nil {
263+ return fail (
264+ nameK3sImage ,
265+ fmt .Sprintf ("Cannot check k3s image %s: %v" , imageName , err ),
266+ "Check Docker daemon status" ,
267+ "Try: docker images | grep rancher/k3s" ,
268+ )
269+ }
270+
271+ if available {
272+ return pass (nameK3sImage , fmt .Sprintf ("K3s image %s is available locally" , imageName ))
273+ }
274+
275+ err = ensureImageAvailable (ctx , cli , imageName , false )
276+ if err != nil {
277+ return warn (
278+ nameK3sImage ,
279+ fmt .Sprintf ("K3s image %s not available locally and could not pull: %v" , imageName , err ),
280+ "Only TestK8sOperator needs this image; other tests are unaffected" ,
281+ "Configure Docker Hub credentials (docker login) to avoid rate limits" ,
282+ "Try: docker pull " + imageName ,
283+ )
284+ }
285+
286+ return pass (nameK3sImage , fmt .Sprintf ("K3s image %s is now available" , imageName ))
287+ }
288+
245289// checkGoInstallation verifies Go is installed and working.
246290func checkGoInstallation (ctx context.Context ) DoctorResult {
247291 _ , err := exec .LookPath ("go" )
0 commit comments