generated from interTwin-eu/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit of docker sidecar plugin
- Loading branch information
Showing
17 changed files
with
2,238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: sidecars | ||
|
||
sidecars: | ||
CGO_ENABLED=1 GOOS=linux go build -o bin/docker-sd cmd/main.go | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"strconv" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/virtual-kubelet/virtual-kubelet/log" | ||
|
||
commonIL "github.com/intertwin-eu/interlink/pkg/common" | ||
docker "github.com/intertwin-eu/interlink-docker-plugin/pkg/docker" | ||
"github.com/intertwin-eu/interlink-docker-plugin/pkg/docker/gpustrategies" | ||
) | ||
|
||
func main() { | ||
logger := logrus.StandardLogger() | ||
|
||
interLinkConfig, err := commonIL.NewInterLinkConfig() | ||
if err != nil { | ||
log.L.Fatal(err) | ||
} | ||
|
||
if interLinkConfig.VerboseLogging { | ||
logger.SetLevel(logrus.DebugLevel) | ||
} else if interLinkConfig.ErrorsOnlyLogging { | ||
logger.SetLevel(logrus.ErrorLevel) | ||
} else { | ||
logger.SetLevel(logrus.InfoLevel) | ||
} | ||
|
||
Ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
log.G(Ctx).Debug("Debug level: " + strconv.FormatBool(interLinkConfig.VerboseLogging)) | ||
|
||
var gpuManager gpustrategies.GPUManagerInterface | ||
gpuManager = &gpustrategies.GPUManager{ | ||
GPUSpecsList: []gpustrategies.GPUSpecs{}, | ||
Ctx: Ctx, | ||
} | ||
|
||
err = gpuManager.Init() | ||
if err != nil { | ||
log.G(Ctx).Fatal(err) | ||
} | ||
|
||
err = gpuManager.Discover() | ||
if err != nil { | ||
log.G(Ctx).Fatal(err) | ||
} | ||
|
||
err = gpuManager.Check() | ||
if err != nil { | ||
log.G(Ctx).Fatal(err) | ||
} | ||
|
||
SidecarAPIs := docker.SidecarHandler{ | ||
Config: interLinkConfig, | ||
Ctx: Ctx, | ||
GpuManager: gpuManager, | ||
} | ||
|
||
mutex := http.NewServeMux() | ||
mutex.HandleFunc("/status", SidecarAPIs.StatusHandler) | ||
mutex.HandleFunc("/create", SidecarAPIs.CreateHandler) | ||
mutex.HandleFunc("/delete", SidecarAPIs.DeleteHandler) | ||
mutex.HandleFunc("/getLogs", SidecarAPIs.GetLogsHandler) | ||
err = http.ListenAndServe(":"+interLinkConfig.Sidecarport, mutex) | ||
|
||
if err != nil { | ||
log.G(Ctx).Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
FROM golang:1.21 as build-stage | ||
|
||
WORKDIR /app | ||
COPY .. . | ||
RUN CGO_ENABLED=1 GOOS=linux go build -o bin/docker-sidecar cmd/main.go | ||
|
||
FROM bash:latest as bash-stage | ||
|
||
# Deploy the application binary into a lean image | ||
FROM docker:24.0-dind-rootless AS build-release-stage | ||
|
||
WORKDIR / | ||
|
||
COPY --from=build-stage /app/bin/docker-sidecar /sidecar/docker-sidecar | ||
|
||
# adding bash binary to be able to perform commands within the sidecar binary | ||
COPY --from=bash-stage /usr/local/bin/bash /bin | ||
|
||
USER root:root | ||
|
||
ENV PATH "$PATH:/bin" | ||
|
||
#creating a simple startup script to start both docker rootless and the sidecar | ||
RUN echo -e '#!/bin/bash\ndockerd-entrypoint.sh & /sidecar/docker-sidecar' > /sidecar/startup-docker.sh | ||
RUN chmod +x /sidecar/startup-docker.sh | ||
RUN chmod -R 777 /sidecar | ||
|
||
ENV INTERLINKCONFIGPATH=/InterLinkConfig.yaml | ||
|
||
USER 1000:1000 | ||
|
||
#setting up the path for the docker daemon | ||
ENV DOCKER_HOST=unix:///run/user/1000/docker.sock | ||
|
||
WORKDIR /sidecar | ||
|
||
ENTRYPOINT ["/sidecar/startup-docker.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
module github.com/intertwin-eu/interlink | ||
|
||
go 1.21 | ||
|
||
toolchain go1.21.3 | ||
|
||
require ( | ||
github.com/containerd/containerd v1.7.15 | ||
gopkg.in/yaml.v2 v2.4.0 | ||
k8s.io/api v0.29.1 | ||
k8s.io/client-go v0.29.1 | ||
) | ||
|
||
require ( | ||
github.com/Microsoft/go-winio v0.6.1 // indirect | ||
github.com/NVIDIA/go-nvml v0.12.0-4 // indirect | ||
github.com/alexellis/go-execute v0.6.0 // indirect | ||
github.com/containerd/log v0.1.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/distribution/reference v0.6.0 // indirect | ||
github.com/docker/docker v26.0.1+incompatible // indirect | ||
github.com/docker/go-connections v0.5.0 // indirect | ||
github.com/docker/go-units v0.5.0 // indirect | ||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect | ||
github.com/felixge/httpsnoop v1.0.3 // indirect | ||
github.com/go-logr/logr v1.4.1 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.6 // indirect | ||
github.com/go-openapi/jsonreference v0.20.2 // indirect | ||
github.com/go-openapi/swag v0.22.3 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.4 // indirect | ||
github.com/google/gnostic-models v0.6.8 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/moby/docker-image-spec v1.3.1 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/opencontainers/go-digest v1.0.0 // indirect | ||
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/sirupsen/logrus v1.9.3 // indirect | ||
github.com/virtual-kubelet/virtual-kubelet v1.11.0 // indirect | ||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect | ||
go.opentelemetry.io/otel v1.22.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.22.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.22.0 // indirect | ||
golang.org/x/mod v0.14.0 // indirect | ||
golang.org/x/net v0.19.0 // indirect | ||
golang.org/x/oauth2 v0.11.0 // indirect | ||
golang.org/x/sys v0.16.0 // indirect | ||
golang.org/x/term v0.15.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
golang.org/x/tools v0.16.1 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/protobuf v1.33.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/apimachinery v0.29.1 // indirect | ||
k8s.io/klog/v2 v2.110.1 // indirect | ||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect | ||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect | ||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect | ||
sigs.k8s.io/yaml v1.3.0 // indirect | ||
) |
Oops, something went wrong.