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

[WIP] Node network Part1 #499

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6f4d61f
Basic nodeNetwork implementation
rmohr Oct 6, 2017
0bfd253
Generalize and improve Interface detection
rmohr Oct 9, 2017
3cec661
Add test based on goexpect to ensure that nodeNetwork is configured
rmohr Oct 9, 2017
b06cfa9
Add CNI plugins to virt-handler
rmohr Oct 10, 2017
7b20ec6
Bring CNI dhcp lease daemon into place
rmohr Oct 11, 2017
65a755b
Add CNI wrapper tool to allow easy invocation of CNI plugins
rmohr Oct 11, 2017
b6d4cef
wip
rmohr Oct 11, 2017
2a13c79
Add ipamonly and noroutes CNI plugins
rmohr Oct 11, 2017
8519372
Generalize cni config rewrite
rmohr Oct 13, 2017
b628ef8
Add Support for libvirt metadata
rmohr Oct 16, 2017
000cead
Integrate CNI calls into the VMSync flow
rmohr Oct 16, 2017
a3a8fd6
Move MAC random generation to the main network plugin
rmohr Oct 17, 2017
7bfdd42
Add mac and IP store for ipamonly plugin
rmohr Oct 17, 2017
a2c1650
Set netmaks of the acquired IP to /32
rmohr Oct 17, 2017
aba2457
Use store in ipamonly plugin
rmohr Oct 17, 2017
f448155
Make sure that CNI DHCP client can be restarted
rmohr Oct 17, 2017
4fa471d
Move all network related code to an independent provider
rmohr Oct 17, 2017
e9a5dc4
Publish IP and MAC of interfaces in VM status
rmohr Oct 17, 2017
ce6f2b1
Add tests which perform http calls from pods to the VM
rmohr Oct 18, 2017
7946bcf
Fix function signature in tests
rmohr Oct 18, 2017
62ac29b
Fix nodenetwork manifest
rmohr Oct 19, 2017
f4f0410
Make unit tests pass again after node networking changes
rmohr Oct 19, 2017
0236bec
Delete CNI cache on first deployment or node restart
rmohr Oct 19, 2017
9510466
Rebase on latest to incorporate virt-handler changes
rmohr Nov 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ vendor/*
.idea
*.iml
cmd/fake-qemu-process/fake-qemu*
cmd/virt-handler/network-helper/network-helper*
cmd/virt-handler/cnitool/cnitool*
cmd/virt-handler/cni/main/ipamonly/ipamonly*
cmd/virt-handler/cni/ipam/noroutes/noroutes*
cmd/virt-handler/cni/cni*
cmd/virt-manifest/virt-manifest*
cmd/virt-controller/virt-controller*
cmd/virt-launcher/virt-launcher*
Expand Down
32 changes: 31 additions & 1 deletion Gopkg.lock

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

22 changes: 22 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1930,11 +1930,26 @@
"device": {
"type": "string"
},
"mode": {
"type": "string"
},
"network": {
"type": "string"
}
}
},
"v1.InterfaceStatus": {
"properties": {
"ip": {
"description": "IP assigned to the device.",
"type": "string"
},
"mac": {
"description": "MAC address assigned to the device. This can either be the MAC from the spec or an auto-generated one",
"type": "string"
}
}
},
"v1.InterfaceTarget": {
"required": [
"dev"
Expand Down Expand Up @@ -2710,6 +2725,13 @@
"$ref": "#/definitions/v1.VMGraphics"
}
},
"interfaces": {
"description": "Interfaces represent the details of all configured interfaces.",
"type": "array",
"items": {
"$ref": "#/definitions/v1.InterfaceStatus"
}
},
"migrationNodeName": {
"description": "MigrationNodeName is the node where the VM is live migrating to.",
"type": "string"
Expand Down
2 changes: 1 addition & 1 deletion automation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ kubectl version
# Disable proxy configuration since it causes test issues
export -n http_proxy
# Run functional tests
FUNC_TEST_ARGS="--ginkgo.noColor" make functest
FUNC_TEST_ARGS="--ginkgo.noColor" make functest DOCKER_TAG=devel
6 changes: 3 additions & 3 deletions cluster/vm-nocloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ spec:
nocloud:
userDataBase64: I2Nsb3VkLWNvbmZpZwpwYXNzd29yZDogYXRvbWljCnNzaF9wd2F1dGg6IFRydWUKY2hwYXNzd2Q6IHsgZXhwaXJlOiBGYWxzZSB9Cg==
interfaces:
- source:
network: default
type: network
- type: nodeNetwork
consoles:
- type: pty
memory:
unit: MB
value: 64
Expand Down
8 changes: 4 additions & 4 deletions cluster/vm.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
apiVersion: kubevirt.io/v1alpha1
kind: VirtualMachine
metadata:
name: testvm
name: testvm1
spec:
domain:
devices:
graphics:
- type: spice
interfaces:
- type: network
source:
network: default
- type: nodeNetwork
model:
type: virtio
video:
- type: qxl
disks:
Expand Down
7 changes: 7 additions & 0 deletions cmd/virt-handler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,12 @@ RUN dnf -y install libvirt-client genisoimage && \
dnf -y clean all

COPY virt-handler /virt-handler
COPY network-helper/network-helper /tools/network-helper
COPY cnitool/cnitool /tools/cnitool
COPY cni/cni /tools/cni
COPY cni/ipam/noroutes/noroutes /plugins/noroutes
COPY cni/main/ipamonly/ipamonly /plugins/ipamonly
copy kubevirt.json /etc/cni/net.d/
copy nodenetwork.json /etc/cni/net.d/

ENTRYPOINT [ "/virt-handler" ]
69 changes: 69 additions & 0 deletions cmd/virt-handler/cni/ipam/noroutes/noroutes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package main

import (
"encoding/json"
"fmt"

"net"

"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
"github.com/containernetworking/cni/pkg/version"
"github.com/containernetworking/plugins/pkg/ipam"
)

const socketPath = "/run/cni/dhcp.sock"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, I think this is left over from some skeleton code you pulled in from container networking.


type NetConf struct {
types.NetConf
RealIPAM string `json:"realipam"`
}

func main() {
skel.PluginMain(cmdAdd, cmdDel, version.All)
}

func loadConf(bytes []byte) (*NetConf, string, error) {
n := &NetConf{}
if err := json.Unmarshal(bytes, n); err != nil {
return nil, "", fmt.Errorf("failed to load netconf: %v", err)
}
return n, n.CNIVersion, nil
}

func cmdAdd(args *skel.CmdArgs) error {

n, cniVersion, err := loadConf(args.StdinData)
if err != nil {
return err
}
r, err := ipam.ExecAdd(n.RealIPAM, args.StdinData)
if err != nil {
return err
}

res, err := current.NewResultFromResult(r)
if err != nil {
return err
}
// remove all routes
res.Routes = nil
// don't mess around with existing default gateways
for _, ipconfig := range res.IPs {
ipconfig.Gateway = nil
}
// Force only a route for the acquired IP
res.IPs[0].Address.Mask = net.IPv4Mask(255, 255, 255, 255)

return types.PrintResult(res, cniVersion)
}

func cmdDel(args *skel.CmdArgs) error {

n, _, err := loadConf(args.StdinData)
if err != nil {
return err
}
return ipam.ExecDel(n.RealIPAM, args.StdinData)
}
Loading