#Trying to port forward minio instance in a K3S cluster

1 messages · Page 1 of 1 (latest)

shell zinc
#

I have been following this https://github.com/dagger/dagger/issues/5292 to run a kubernetes cluster inside dagger, containing an instance of minio.
From a mino client container I am now trying to set an alias pointing to that minio by port forwarding its service

// creating the port forward
vaultPF := setKubectl(client.Container().From("bitnami/kubectl"), *k8s).
    WithExposedPort(4222).
    WithExec([]string{"kubectl port-forward --namespace=minio-operator service/operator 4222:4222 &"})

mc = setKubectl(client.Container().From("bitnami/minio-client"), *k8s).
    WithEnvVariable("CLUSTER_ACCESSKEY", clusterAccessKey).
    WithEnvVariable("CLUSTER_SECRETKEY", clusterSecretKey).
    WithServiceBinding("minio.k3s.lan", vaultPF).
    WithExec([]string{"mc --insecure alias set cluster https://minio.k3s.lan:4222 $CLUSTER_ACCESSKEY $CLUSTER_SECRETKEY"})

The issue is that the execution get stuck while forwarding the port

241: [0.33s] Forwarding from 127.0.0.1:4222 -> 4222
241: [0.33s] Forwarding from [::1]:4222 -> 4222

I've tried using nohup, the & at the end of the command as well a creating a thread for the vaultPF container but nothing seems to do it,
Thank you for your help !

GitHub

What is the issue? Some users in discord (https://discord.com/channels/707636530424053791/1114570469958484008) have requested the ability to test kubernetes pipelines in Dagger. With the help of @v...

#

This is the setKubectl function

func setKubectl(c *dagger.Container, k8s K8sInstance) *dagger.Container {
    kubectl := k8s.container.File("/opt/bitnami/kubectl/bin/kubectl")

    return c.WithMountedCache("/cache/k3s", k8s.configCache).
        WithServiceBinding("kubernetes.default.svc", k8s.k3s).
        WithEnvVariable("CACHE", time.Now().String()).
        WithUser("root").
        WithEntrypoint([]string{"sh", "-c"}).
        WithFile("/usr/local/bin/kubectl", kubectl).
        WithExec([]string{"mkdir -p /.kube"}).
        WithExec([]string{"cp", "/cache/k3s/k3s.yaml", "/.kube/config"}, dagger.ContainerWithExecOpts{SkipEntrypoint: true}).
        WithEnvVariable("KUBECONFIG", "/.kube/config").
        WithExec([]string{"kubectl", "config", "set-cluster", "default", "--server=https://kubernetes.default.svc:6443"}, dagger.ContainerWithExecOpts{SkipEntrypoint: true}).
        WithExec([]string{"chown", "1001:0", "/.kube/config"}, dagger.ContainerWithExecOpts{SkipEntrypoint: true})
}
#

Trying to port forward minio instance in a K3S cluster

old cosmos
#

👋 if you have the ability to create the minio service as NodePort that'd make it simpler since you can avoid doing theport-forward. Would that be possible?