#Precommit Ci/Cd
1 messages · Page 1 of 1 (latest)
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
}
Any thoughts team or this is not the usecase dagger is targeting
One thing could be done in terms of installing k3 as part of custom container and then testing the whole setup