Skip to content

Commit 6407685

Browse files
authored
Merge pull request #2486 from FabianKramm/main
refactor: improve local registry detection
2 parents c385a26 + 73c6984 commit 6407685

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

pkg/devspace/build/registry/util.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/loft-sh/devspace/pkg/devspace/build/builder"
77
"github.com/loft-sh/devspace/pkg/devspace/build/builder/kaniko"
88
"io"
9+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
910
"net/http"
1011
"runtime"
1112
"strings"
@@ -130,9 +131,16 @@ func UseLocalRegistry(client kubectl.Client, config *latest.Config, imageConfig
130131
return false
131132
}
132133

133-
// TODO: better check for arm64 architectures
134+
// check if node architecture equals our architecture
134135
if runtime.GOARCH != "amd64" {
135-
return false
136+
nodes, err := client.KubeClient().CoreV1().Nodes().List(context.Background(), metav1.ListOptions{})
137+
if err != nil {
138+
return false
139+
} else if len(nodes.Items) != 1 {
140+
return false
141+
} else if nodes.Items[0].Labels == nil || nodes.Items[0].Labels["kubernetes.io/arch"] != runtime.GOARCH {
142+
return false
143+
}
136144
}
137145

138146
// check if builder is kaniko
@@ -154,7 +162,7 @@ func UseLocalRegistry(client kubectl.Client, config *latest.Config, imageConfig
154162
}
155163

156164
imageWithoutPort := strings.Split(imageConfig.Image, ":")[0]
157-
if imageWithoutPort == "" || imageWithoutPort == "localhost" || imageWithoutPort == "127.0.0.1" || strings.HasSuffix(imageWithoutPort, ".cluster.local") {
165+
if imageWithoutPort == "" || imageWithoutPort == "localhost" || imageWithoutPort == "127.0.0.1" || strings.HasSuffix(imageWithoutPort, ".local") || strings.HasSuffix(imageWithoutPort, ".localhost") {
158166
return false
159167
}
160168
}

0 commit comments

Comments
 (0)