#Precommit Ci/Cd

1 messages · Page 1 of 1 (latest)

native yarrow
#

We run precommit ci/cd with tilt for kubernetes. thinking to move to dagger. currently we use orbstack for local dev ci/cd before commiting. so we want to use the same local kubernetes cluster inside dagger go sdk. it is becoming v difficult to access local kubernetes for local ci/cd of apps. What is way forward here?

#

i tired container to host networking but no luck -
homeDir, err := os.UserHomeDir()
if err != nil {
panic(fmt.Sprintf("Failed to get user's home directory: %v", err))
}

// Construct the full path to the .kube directory
kubeConfigPath := filepath.Join(homeDir, ".kube")
//fmt.Sprintf("kubeconfigpath:%v", kubeConfigPath)
kubeConfigMount := client.Host().Directory(kubeConfigPath, dagger.HostDirectoryOpts{})

// Get the current user's home directory
kubeAPIPort := 26443 // Kubernetes API server port
hostService := client.Host().Service([]dagger.PortForward{
    {Frontend: kubeAPIPort, Backend: kubeAPIPort},
})

out, err := client.Container().
    From(imageref).
    WithDirectory("/root/.kube", kubeConfigMount).
    WithServiceBinding("kubernetes-api", hostService).
    WithExec([]string{"kubectl", "get", "pods", "--server=https://kubernetes-api"}).
    //, "--server=https://kubernetes-api"}).
    Stdout(ctx)
if err != nil {
    fmt.Fprintf(os.Stderr, "Error: %v\n", err)
    return
}
native yarrow
#

Any thoughts team or this is not the usecase dagger is targeting

native yarrow
#

One thing could be done in terms of installing k3 as part of custom container and then testing the whole setup