Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local gpu (k3d) #240

Merged
merged 4 commits into from
Oct 31, 2024
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
13 changes: 13 additions & 0 deletions executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,19 @@ func localExecute(pipeline *zjson.Pipeline, pipelineMerkleTree *zjson.PipelineMe
}
}

if cfg.Local.Driver == "k3d" {
imageImport := []string{"image", "import"}
for _, image := range blocks {
imageImport = append(imageImport, image)
}
imageImport = append(imageImport, "-c")
imageImport = append(imageImport, cfg.Local.K3DCluster)
pullImage := cmd.NewCmd("k3d", imageImport...)
<-pullImage.Start()
log.Println(pullImage.Status().Stdout)
log.Println(pullImage.Status().Stderr)
}

if err := eg.Wait(); err != nil {
pipelineLogger.Printf("error during pipeline build execution; err=%v", err)
log.Printf("error during pipeline build execution; err=%v", err)
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ type Config struct {
Cloud Cloud `json:"Cloud,omitempty"`
}


type Local struct {
BucketPort int
Driver string
K3DCluster string `json:"K3DCluster,omitempty"`
}

type Cloud struct {
Expand Down
2 changes: 1 addition & 1 deletion setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func setup(ctx context.Context, config Config, db *sql.DB) {
signals := make(chan os.Signal, 1)
signal.Notify(signals, os.Interrupt)

if config.Local.Driver == "minikube" {
if config.Local.Driver == "minikube" || config.Local.Driver == "k3d" {
stopBucketCh := make(chan struct{}, 1)
go func() {
for {
Expand Down
12 changes: 11 additions & 1 deletion translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,17 @@ func checkImage(ctx context.Context, image string, cfg Config) (bool, bool, erro
}
}
return false, false, nil
} else {
} else if cfg.Local.Driver == "k3d" {
dockerImage := cmd.NewCmd("docker", "exec", "k3d-" + cfg.Local.K3DCluster + "-server-0", "crictl", "images")
<-dockerImage.Start()
for _, line := range dockerImage.Status().Stdout {
data := strings.Fields(line)
if "docker.io/zetaforge/"+image == data[0] + ":" + data[1] {
return true, false, nil
}
}
return false, false, nil
} else {
apiClient, err := client.NewClientWithOpts(
client.WithAPIVersionNegotiation(),
)
Expand Down
Loading