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 basic OVS CNI plugin implementation #4

Merged
merged 1 commit into from
Aug 21, 2018
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
  •  
  •  
  •  
168 changes: 168 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[constraint]]
name = "github.com/containernetworking/cni"
version = "0.6.0"

[[constraint]]
name = "github.com/containernetworking/plugins"
version = "0.7.1"

[[constraint]]
name = "github.com/vishvananda/netlink"
version = "1.0.0"

# https://github.com/golang/dep/issues/1799
[[override]]
source = "https://github.com/fsnotify/fsnotify/archive/v1.4.7.tar.gz"
name = "gopkg.in/fsnotify.v1"

[prune]
go-tests = true
unused-packages = true
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ format:
go vet ./pkg/...

test:
go test ./cmd/... ./pkg/...
go test ./cmd/... ./pkg/... -v --ginkgo.v

test-%:
go test ./$(subst -,/,$*)/...
go test ./$(subst -,/,$*)/... -v --ginkgo.v

docker-build: $(patsubst %, docker-build-%, $(COMPONENTS))

Expand All @@ -46,10 +46,7 @@ cluster-up:
cluster-down:
./cluster/down.sh

cluster-sync: $(patsubst %, cluster-sync-%, $(COMPONENTS))

cluster-sync-%:
./cluster/build.sh $*
./cluster/sync.sh $*
cluster-sync: build
./cluster/sync.sh

.PHONY: build format test docker-build docker-push dep clean-dep cluster-up cluster-down cluster-sync
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Open vSwitch CNI plugin

* [Development](docs/devel.md)
* [CNI Plugin](docs/cni-plugin.md) - Documentation and usage of standalone Open vSwitch CNI plugin.
* [Usage Example on Local Cluster](docs/local-cluster-example.md) - Demo that will guide you through Multus and OVS CNI installation and show you how to use it in order to attach Kubernetes Pod to OVS bridge configured on host.
* [Development](docs/devel-guide.md) - Reference point for development helper commands, building, testing, container images and local cluster.
27 changes: 0 additions & 27 deletions cluster/build.sh

This file was deleted.

8 changes: 7 additions & 1 deletion cluster/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ set -e

source ./cluster/gocli.sh

$gocli_interactive ssh node01
interactive=$1

if [[ $interactive == "-i" ]]; then
docker exec -it kubevirt-node01 ssh.sh
else
docker exec kubevirt-node01 ssh.sh $@
fi
39 changes: 39 additions & 0 deletions cluster/examples/ovs-cni.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: ovs-cni-plugin-installator-amd64
namespace: kube-system
labels:
tier: node
app: ovs-cni-plugin
spec:
template:
metadata:
labels:
tier: node
app: ovs-cni-plugin
spec:
nodeSelector:
beta.kubernetes.io/arch: amd64
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: ovs-cni-plugin-installator
image: registry:5000/ovs-cni-plugin
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
volumeMounts:
- name: cnibin
mountPath: /host/opt/cni/bin
volumes:
- name: cnibin
hostPath:
path: /opt/cni/bin
1 change: 0 additions & 1 deletion cluster/gocli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@
#

gocli="docker run --net=host --privileged --rm -v /var/run/docker.sock:/var/run/docker.sock kubevirtci/gocli:latest"
gocli_interactive="docker run --net=host --privileged --rm -it -v /var/run/docker.sock:/var/run/docker.sock kubevirtci/gocli:latest"
14 changes: 11 additions & 3 deletions cluster/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@

set -e

component=$1

source ./cluster/gocli.sh

registry_port=$($gocli ports registry | tr -d '\r')
registry=localhost:$registry_port

REGISTRY=$registry make docker-push-$component
REGISTRY=$registry make docker-build
REGISTRY=$registry make docker-push

./cluster/kubectl.sh delete --ignore-not-found -f ./cluster/examples/ovs-cni.yml

# Wait until all objects are deleted
until [[ $(./cluster/kubectl.sh get -f ./cluster/examples/ovs-cni.yml 2>&1 | grep NotFound | wc -l) -eq $(./cluster/kubectl.sh get -f ./cluster/examples/ovs-cni.yml 2>&1 | wc -l) ]]; do
sleep 1
done

./cluster/kubectl.sh create -f ./cluster/examples/ovs-cni.yml
5 changes: 4 additions & 1 deletion cluster/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -e

source ./cluster/gocli.sh

$gocli run --random-ports --nodes 1 --background kubevirtci/k8s-1.10.3
$gocli run --random-ports --nodes 1 --background kubevirtci/k8s-multus-1.11.1

k8s_port=$($gocli ports k8s | tr -d '\r')

Expand All @@ -36,3 +36,6 @@ echo 'Wait until all pods are running'
until [[ $(./cluster/kubectl.sh get pods --all-namespaces --no-headers | wc -l) -eq $(./cluster/kubectl.sh get pods --all-namespaces --no-headers | grep Running | wc -l) ]]; do
sleep 1
done

./cluster/cli.sh sudo yum install -y openvswitch
./cluster/cli.sh sudo systemctl start openvswitch
3 changes: 3 additions & 0 deletions cmd/plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM centos:centos7
COPY plugin /ovs
CMD ["sh", "-c", "cp /ovs /host/opt/cni/bin/ovs && sleep infinity"]
26 changes: 26 additions & 0 deletions cmd/plugin/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2018 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/version"

"kubevirt.io/ovs-cni/pkg/plugin"
)

func main() {
skel.PluginMain(plugin.CmdAdd, plugin.CmdDel, version.All)
}
Binary file added cmd/plugin/plugin
Binary file not shown.
Loading