tensorchord / envd

🏕️ Reproducible development environment
https://envd.tensorchord.ai/
Apache License 2.0
1.93k stars 156 forks source link

feasibility-research(runtime): Support the OCI runtime spec-compatible runtime #282

Open gaocegege opened 2 years ago

gaocegege commented 2 years ago

Description

Xuanwo commented 2 years ago

Can we integrate with OCI runtime spec directly? So that we can work with runc, crun, containerd, kata, ...

gaocegege commented 2 years ago

SGTM.

gaocegege commented 1 year ago

should we plan to support podman? for Linux users, podman may be their best choice for managing containers and images. also for macOS users, podman is available now. podman can run without a daemon service and sudo permission. supporting podman may increase the user experience by hidding containers under the hood

From #915

/cc @TaylorHere

TaylorHere commented 1 year ago

Any update or progress on this issue?

gaocegege commented 1 year ago

We did not start yet. We are still working on kubernetes support.

TaylorHere commented 1 year ago

https://github.com/opencontainers/runtime-tools/tree/master/generate this package may be a good choice to generate the OCI state

TaylorHere commented 1 year ago

I see some tools can work with docker socket and podman socket like jetbrains, maybe OCI is not needed, just a client that can work with those sockets. so, I tried

diff --git a/pkg/buildkitd/buildkitd.go b/pkg/buildkitd/buildkitd.go
index da28703..4ab5282 100644
--- a/pkg/buildkitd/buildkitd.go
+++ b/pkg/buildkitd/buildkitd.go
@@ -113,7 +113,7 @@ func (c generalClient) Close() error {
 // that can be used to connect to it.
 func (c *generalClient) maybeStart(ctx context.Context,
    runningTimeout, connectingTimeout time.Duration) (string, error) {
-   if c.driver == types.BuilderTypeDocker {
+   if c.driver == types.BuilderTypeDocker || c.driver == types.BuilderTypePodman {
        dockerClient, err := docker.NewClient(ctx)
        if err != nil {
            return "", err
diff --git a/pkg/home/context.go b/pkg/home/context.go
index 6b6f250..b57ad38 100644
--- a/pkg/home/context.go
+++ b/pkg/home/context.go
@@ -96,7 +96,8 @@ func (m *generalManager) ContextCreate(ctx types.Context, use bool) error {
    }
    switch ctx.Builder {
    case types.BuilderTypeDocker, types.BuilderTypeKubernetes,
-       types.BuilderTypeUNIXDomainSocket, types.BuilderTypeTCP:
+       types.BuilderTypeUNIXDomainSocket, types.BuilderTypeTCP,
+       types.BuilderTypePodman:
        break
    default:
        return errors.New("unknown builder type")
diff --git a/pkg/types/envd.go b/pkg/types/envd.go
index c9422b0..dfde360 100644
--- a/pkg/types/envd.go
+++ b/pkg/types/envd.go
@@ -129,6 +129,7 @@ type BuilderType string

 const (
    BuilderTypeDocker           BuilderType = "docker-container"
+   BuilderTypePodman           BuilderType = "podman-container"
    BuilderTypeKubernetes       BuilderType = "kube-pod"
    BuilderTypeTCP              BuilderType = "tcp"
    BuilderTypeUNIXDomainSocket BuilderType = "UNIX"
sudo ln -s /run/podman/podman.sock /var/run/docker.sock
envd context create --name podman --builder podman-container --builder-address envd_buildkitd --use 
envd bootstrap
INFO[2022-11-01T21:00:45+08:00] [1/3] Bootstrap SSH Key                      
INFO[2022-11-01T21:00:45+08:00] [2/3] Bootstrap autocomplete                 
INFO[2022-11-01T21:00:45+08:00] You may have to restart your shell for autocomplete to get initialized (e.g. run "exec $SHELL") 
INFO[2022-11-01T21:00:45+08:00] [3/3] Bootstrap buildkit                     
INFO[2022-11-01T21:00:46+08:00] The buildkit is running at podman-container://envd_buildkitd 

works fine

aseaday commented 1 year ago

Nice Job. Maybe we need a podman socket CI to test it all.

TaylorHere commented 1 year ago

Nice Job. Maybe we need a podman socket CI to test it all.

I will try to create a PR on this.

TaylorHere commented 1 year ago

bad news, the rootless socket is not working.

gaocegege commented 1 year ago

May I ask why it does not work? Did it return an error?

TaylorHere commented 1 year ago

it looks hung on client.NewClientWithOpts

TaylorHere commented 1 year ago

No, my bad, it's working with rootless sockets

DOCKER_HOST=unix:///run/user/1000/podman/podman.sock envd bootstrap 
INFO[2022-11-02T11:01:59+08:00] [1/3] Bootstrap SSH Key                      
INFO[2022-11-02T11:01:59+08:00] [2/3] Bootstrap autocomplete                 
INFO[2022-11-02T11:01:59+08:00] You may have to restart your shell for autocomplete to get initialized (e.g. run "exec $SHELL") 
INFO[2022-11-02T11:01:59+08:00] [3/3] Bootstrap buildkit                     
INFO[2022-11-02T11:02:00+08:00] The buildkit is running at podman-container://envd_buildkitd 
gaocegege commented 1 year ago

Related to https://github.com/tensorchord/envd/issues/1123

gaocegege commented 1 year ago

No, my bad, it's working with rootless sockets

DOCKER_HOST=unix:///run/user/1000/podman/podman.sock envd bootstrap 
INFO[2022-11-02T11:01:59+08:00] [1/3] Bootstrap SSH Key                      
INFO[2022-11-02T11:01:59+08:00] [2/3] Bootstrap autocomplete                 
INFO[2022-11-02T11:01:59+08:00] You may have to restart your shell for autocomplete to get initialized (e.g. run "exec $SHELL") 
INFO[2022-11-02T11:01:59+08:00] [3/3] Bootstrap buildkit                     
INFO[2022-11-02T11:02:00+08:00] The buildkit is running at podman-container://envd_buildkitd 

buildkit is running successfully in podman. Thanks!

We also need to support creating envd containers in podman.