Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add containerd cri #19

Merged
merged 5 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ IMAGE_REGISTRY ?= quay.io/mduarted
IMAGE_NAME ?= multus-dynamic-networks-controller
IMAGE_TAG ?= latest

CRI_SOCKET_PATH ?= "/host/run/containerd/containerd.sock"

.PHONY: manifests

all: build test
Expand All @@ -19,7 +21,7 @@ img-build: build test
$(OCI_BIN) build -t ${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG} -f images/Dockerfile .

manifests:
IMAGE_REGISTRY=${IMAGE_REGISTRY} hack/generate_manifests.sh
IMAGE_REGISTRY=${IMAGE_REGISTRY} CRI_SOCKET_PATH=${CRI_SOCKET_PATH} hack/generate_manifests.sh

test:
$(GO) test -v ./...
13 changes: 13 additions & 0 deletions cmd/dynamic-networks-controller/networks-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (

"github.com/maiqueb/multus-dynamic-networks-controller/pkg/config"
"github.com/maiqueb/multus-dynamic-networks-controller/pkg/controller"
"github.com/maiqueb/multus-dynamic-networks-controller/pkg/cri"
"github.com/maiqueb/multus-dynamic-networks-controller/pkg/cri/containerd"
"github.com/maiqueb/multus-dynamic-networks-controller/pkg/logging"
)

Expand Down Expand Up @@ -84,6 +86,11 @@ func newController(stopChannel chan struct{}, configuration *config.Multus) (*co

eventBroadcaster := newEventBroadcaster(k8sClient)

containerRuntime, err := newContainerRuntime(configuration)
if err != nil {
return nil, fmt.Errorf("failed to create the CRI: %v", err)
}

podNetworksController, err := controller.NewPodNetworksController(
podInformerFactory,
nadInformerFactory,
Expand All @@ -92,6 +99,7 @@ func newController(stopChannel chan struct{}, configuration *config.Multus) (*co
configuration.MultusSocketPath,
k8sClient,
nadClientSet,
containerRuntime,
)
if err != nil {
return nil, fmt.Errorf("failed to create the pod networks controller: %v", err)
Expand Down Expand Up @@ -135,3 +143,8 @@ func handleSignals(stopChannel chan struct{}, signals ...os.Signal) {
stopChannel <- struct{}{}
}()
}

func newContainerRuntime(configuration *config.Multus) (cri.ContainerRuntime, error) {
const withoutTimeout = 0
return containerd.NewContainerdRuntime(configuration.CriSocketPath, withoutTimeout)
}
33 changes: 29 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/maiqueb/multus-dynamic-networks-controller
go 1.18

require (
github.com/containerd/containerd v1.6.8
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.3.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.17.0
Expand All @@ -13,37 +14,61 @@ require (
)

require (
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/Microsoft/hcsshim v0.9.4 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/containerd/cgroups v1.0.3 // indirect
github.com/containerd/continuity v0.2.2 // indirect
github.com/containerd/fifo v1.0.0 // indirect
github.com/containerd/ttrpc v1.1.0 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/emicklei/go-restful v2.10.0+incompatible // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-logr/logr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/googleapis v1.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.11.13 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.5.0 // indirect
github.com/moby/sys/signal v0.6.0 // 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/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
github.com/opencontainers/selinux v1.10.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
Expand Down
Loading