Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
178cf85183 | ||
|
|
272161b00b | ||
|
|
56155d0819 | ||
|
|
c711826996 | ||
|
|
eef6965590 | ||
|
|
4926cb6f9a | ||
|
|
d9ca54e777 | ||
|
|
1f6a6349a9 | ||
|
|
8f27f8f442 | ||
|
|
681109ba71 | ||
|
|
99c691745a | ||
|
|
1af5699948 | ||
|
|
ef7571f1ef | ||
|
|
c0726923f5 | ||
|
|
4d9eadde5b | ||
|
|
9da5cee8d9 | ||
|
|
ca22ecdf09 | ||
|
|
2e58e92d48 | ||
|
|
fd0c53b424 | ||
|
|
7b1e8ac1cf | ||
|
|
31b7e063e7 | ||
|
|
b5172f46c1 | ||
|
|
5a6cb8e708 | ||
|
|
c3c28ea27e | ||
|
|
623abeef4c | ||
|
|
5f30846092 | ||
|
|
6ddbc5cb57 | ||
|
|
f9f3b18ce4 | ||
|
|
dc2925263c | ||
|
|
56fd45f7ea | ||
|
|
21a0fc30e8 | ||
|
|
673d0af97d | ||
|
|
402400d4cb | ||
|
|
b1a66012bd | ||
|
|
85fa976a25 | ||
|
|
640b487914 | ||
|
|
7c84e24f48 | ||
|
|
125f3cf6f6 | ||
|
|
b2ffe77029 | ||
|
|
3607cf2d7a | ||
|
|
a57cf4bc83 | ||
|
|
6036037817 |
No files matched your search
+3
-3
@@ -61,9 +61,6 @@
|
||||
[submodule "vendor/github.com/hashicorp/go-cleanhttp"]
|
||||
path = vendor/github.com/hashicorp/go-cleanhttp
|
||||
url = http://github.com/hashicorp/go-cleanhttp
|
||||
[submodule "vendor/github.com/appc/cni"]
|
||||
path = vendor/github.com/appc/cni
|
||||
url = https://github.com/appc/cni
|
||||
[submodule "vendor/github.com/coreos/go-iptables"]
|
||||
path = vendor/github.com/coreos/go-iptables
|
||||
url = https://github.com/coreos/go-iptables
|
||||
@@ -124,3 +121,6 @@
|
||||
[submodule "vendor/github.com/weaveworks/common"]
|
||||
path = vendor/github.com/weaveworks/common
|
||||
url = https://github.com/weaveworks/common
|
||||
[submodule "vendor/github.com/containernetworking/cni"]
|
||||
path = vendor/github.com/containernetworking/cni
|
||||
url = https://github.com/containernetworking/cni
|
||||
+41
-2
@@ -1,6 +1,44 @@
|
||||
## Release 1.9.4
|
||||
|
||||
Bug fixes and minor improvements
|
||||
|
||||
* Support Kubernetes 1.6 by creating a new DaemonSet #2777,#2801
|
||||
* Support Kubernetes 1.6 by allowing CNI callers to send a
|
||||
network-delete request for a container that is not running or has
|
||||
never been attached to the network #2850
|
||||
* Leave non-weave ipsets alone in Network Policy Controller (e.g. when
|
||||
running Weave Net alonside keepalived-vip) #2751,#2846
|
||||
* Fix various small issues revealed by 'staticcheck' tool #2843,#2857
|
||||
* Avoid leaving 'defunct' processes when weave-kube container restarts #2836,#2845
|
||||
* When using the CNI plugin with a non-standard network configuration
|
||||
file, the weave bridge could get the same IP as a container, if
|
||||
'weave expose' hadn't run at that point #2839,#2856
|
||||
|
||||
Build and Testing
|
||||
|
||||
* Check that no defunct processes remain after each test #2852
|
||||
* Update build and test scripts to work with Kubernetes 1.6 beta #2851
|
||||
|
||||
[Full list of changes](https://github.com/weaveworks/weave/milestone/53?closed=1).
|
||||
|
||||
## Release 1.9.3
|
||||
|
||||
Bug fixes and minor improvements
|
||||
|
||||
* Fixed a race condition in Fast Datapath encrypted connections which could lead Weave Net to crash: #2824, #2825.
|
||||
|
||||
## Release 1.9.2
|
||||
|
||||
Bug fixes and minor improvements
|
||||
|
||||
* Fix a weave-kube bug when `br_netfilter` or `xt_set` module is compiled into
|
||||
kernel #2820/#2821
|
||||
* Detect the absence of the required `xt_set` kernel module #2821
|
||||
|
||||
## Release 1.9.1
|
||||
|
||||
# Bug fixes and minor improvements
|
||||
Bug fixes and minor improvements
|
||||
|
||||
* Fix a race condition when the Weave Net container is restarted
|
||||
which could allow a new container to be allocated the same IP
|
||||
address as an existing one #2784,#2787
|
||||
@@ -14,7 +52,8 @@
|
||||
larger clusters can be created #2781
|
||||
* WeaveDNS was incorrectly case-sensitive for reverse DNS lookups #2817,#2818
|
||||
|
||||
# Build and Testing
|
||||
Build and Testing
|
||||
|
||||
* Scripts to create VMs to run automated tests were rewritten to use
|
||||
Terraform and Ansible, to make it much easier to test with different
|
||||
versions of components such as Docker and Kubernetes #2647,#2694,#2775,#2796
|
||||
|
||||
@@ -173,6 +173,8 @@ ifeq ($(BUILD_IN_CONTAINER),true)
|
||||
# It bind-mounts the source into the container and passes all important variables
|
||||
exes $(EXES) tests lint: $(BUILD_UPTODATE)
|
||||
git submodule update --init
|
||||
# Containernetworking has another copy of vishvananda/netlink which leads to duplicate definitions
|
||||
-@rm -r vendor/github.com/containernetworking/cni/vendor
|
||||
@mkdir -p $(shell pwd)/.pkg
|
||||
$(SUDO) docker run $(RM) $(RUN_FLAGS) \
|
||||
-v $(shell pwd):/go/src/github.com/weaveworks/weave \
|
||||
|
||||
+15
@@ -90,6 +90,7 @@ build() {
|
||||
## (library versions?)
|
||||
sed -i "/SCRIPT_VERSION=/ c\SCRIPT_VERSION=\"$VERSION\"" ./weave
|
||||
sed -i -e "s/:latest/:$VERSION/" -e "/imagePullPolicy: Always/d" ./prog/weave-kube/weave-daemonset.yaml
|
||||
sed -i -e "s/:latest/:$VERSION/" -e "/imagePullPolicy: Always/d" ./prog/weave-kube/weave-daemonset-k8s-1.6.yaml
|
||||
make SUDO=$SUDO WEAVE_VERSION=$VERSION DOCKERHUB_USER=$DOCKERHUB_USER
|
||||
|
||||
if make tests; then
|
||||
@@ -165,6 +166,13 @@ draft() {
|
||||
--name "weave-daemonset.yaml" \
|
||||
--file "./prog/weave-kube/weave-daemonset.yaml"
|
||||
|
||||
github-release upload \
|
||||
--user $GITHUB_USER \
|
||||
--repo weave \
|
||||
--tag $LATEST_TAG \
|
||||
--name "weave-daemonset-k8s-1.6.yaml" \
|
||||
--file "./prog/weave-kube/weave-daemonset-k8s-1.6.yaml"
|
||||
|
||||
echo "** Draft $TYPE $RELEASE_NAME $VERSION created at"
|
||||
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG"
|
||||
}
|
||||
@@ -251,6 +259,13 @@ publish() {
|
||||
--name "weave-daemonset.yaml" \
|
||||
--file "./prog/weave-kube/weave-daemonset.yaml"
|
||||
|
||||
github-release upload \
|
||||
--user $GITHUB_USER \
|
||||
--repo weave \
|
||||
--tag latest_release \
|
||||
--name "weave-daemonset-k8s-1.6.yaml" \
|
||||
--file "./prog/weave-kube/weave-daemonset-k8s-1.6.yaml"
|
||||
|
||||
echo "** Release $RELEASE_NAME $VERSION published at"
|
||||
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/$LATEST_TAG"
|
||||
echo -e "\thttps://github.com/$GITHUB_USER/weave/releases/latest_release"
|
||||
|
||||
@@ -138,6 +138,8 @@ Finally, for **Mainline** releases only:
|
||||
published to https://www.weave.works
|
||||
* Add the new version of `weave-net` to the checkpoint system at
|
||||
https://checkpoint-api.weave.works/admin
|
||||
* File a PR to update the version of the daemonset at
|
||||
https://github.com/kubernetes/kops/tree/master/upup/models/cloudup/resources/addons/networking.weave
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
||||
+2
-2
@@ -210,9 +210,9 @@ func (alloc *Allocator) doOperation(op operation, ops *[]operation) {
|
||||
// already succeeded. If it is on the queue, we call
|
||||
// cancel on it, allowing callers waiting for the resultChans
|
||||
// to unblock.
|
||||
func (alloc *Allocator) cancelOp(op operation, ops *[]operation) {
|
||||
func (alloc *Allocator) cancelOp(opToCancel operation, ops *[]operation) {
|
||||
for i, op := range *ops {
|
||||
if op == op {
|
||||
if op == opToCancel {
|
||||
*ops = append((*ops)[:i], (*ops)[i+1:]...)
|
||||
op.Cancel()
|
||||
break
|
||||
|
||||
@@ -186,6 +186,7 @@ func TestAllocatorClaim(t *testing.T) {
|
||||
alloc.Prime()
|
||||
// Do an allocate on the other peer, which we will try to claim later
|
||||
addrx, err := allocs[0].Allocate(container1, subnet, true, returnFalse)
|
||||
require.NoError(t, err)
|
||||
// Should not get the address we pre-claimed
|
||||
require.NotEqual(t, addrx, preAddr)
|
||||
router.Flush()
|
||||
|
||||
@@ -52,12 +52,12 @@ func TestLowlevel(t *testing.T) {
|
||||
|
||||
s := New()
|
||||
require.Equal(t, address.Count(0), s.NumFreeAddresses())
|
||||
ok, got := s.Allocate(address.NewRange(0, 1000))
|
||||
ok, _ := s.Allocate(address.NewRange(0, 1000))
|
||||
require.False(t, ok, "allocate in empty space should fail")
|
||||
|
||||
s.Add(100, 100)
|
||||
require.Equal(t, address.Count(100), s.NumFreeAddresses())
|
||||
ok, got = s.Allocate(address.NewRange(0, 1000))
|
||||
ok, got := s.Allocate(address.NewRange(0, 1000))
|
||||
require.True(t, ok && got == 100, "allocate")
|
||||
require.Equal(t, address.Count(99), s.NumFreeAddresses())
|
||||
require.NoError(t, s.Claim(150))
|
||||
@@ -68,6 +68,7 @@ func TestLowlevel(t *testing.T) {
|
||||
wt.AssertErrorInterface(t, (*error)(nil), s.Free(100), "double free")
|
||||
|
||||
r, ok := s.Donate(address.NewRange(0, 1000))
|
||||
require.True(t, ok, "donate")
|
||||
require.Equal(t, address.NewRange(0xa0, 0x20), r, "donate")
|
||||
|
||||
// test Donate when addresses are scarce
|
||||
@@ -78,6 +79,7 @@ func TestLowlevel(t *testing.T) {
|
||||
require.NoError(t, s.Claim(0))
|
||||
require.NoError(t, s.Claim(2))
|
||||
r, ok = s.Donate(address.NewRange(0, 1000))
|
||||
require.True(t, ok, "donate")
|
||||
require.Equal(t, address.NewRange(1, 1), r, "donate")
|
||||
r, ok = s.Donate(address.NewRange(0, 1000))
|
||||
require.True(t, !ok, "donate should fail")
|
||||
|
||||
@@ -6,4 +6,6 @@ const (
|
||||
MainChain = "WEAVE-NPC"
|
||||
DefaultChain = "WEAVE-NPC-DEFAULT"
|
||||
IngressChain = "WEAVE-NPC-INGRESS"
|
||||
|
||||
IpsetNamePrefix = "weave-"
|
||||
)
|
||||
@@ -2,6 +2,7 @@ package ipset
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -22,6 +23,8 @@ type Interface interface {
|
||||
Flush(ipsetName Name) error
|
||||
Destroy(ipsetName Name) error
|
||||
|
||||
List(prefix string) ([]Name, error)
|
||||
|
||||
FlushAll() error
|
||||
DestroyAll() error
|
||||
}
|
||||
@@ -72,6 +75,24 @@ func (i *ipset) DestroyAll() error {
|
||||
return doExec("destroy")
|
||||
}
|
||||
|
||||
// Fetch a list of all existing sets with a given prefix
|
||||
func (i *ipset) List(prefix string) ([]Name, error) {
|
||||
output, err := exec.Command("ipset", "list", "-name", "-output", "plain").Output()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var selected []Name
|
||||
sets := strings.Split(string(output), "\n")
|
||||
for _, v := range sets {
|
||||
if strings.HasPrefix(v, prefix) {
|
||||
selected = append(selected, Name(v))
|
||||
}
|
||||
}
|
||||
|
||||
return selected, err
|
||||
}
|
||||
|
||||
func doExec(args ...string) error {
|
||||
if output, err := exec.Command("ipset", args...).CombinedOutput(); err != nil {
|
||||
return errors.Wrapf(err, "ipset %v failed: %s", args, output)
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ func newSelectorSpec(json *unversioned.LabelSelector, nsName string, ipsetType i
|
||||
// We prefix the selector string with the namespace name when generating
|
||||
// the shortname because you can specify the same selector in multiple
|
||||
// namespaces - we need those to map to distinct ipsets
|
||||
ipsetName: ipset.Name("weave-" + shortName(nsName+":"+key)),
|
||||
ipsetName: ipset.Name(IpsetNamePrefix + shortName(nsName+":"+key)),
|
||||
ipsetType: ipsetType}, nil
|
||||
}
|
||||
|
||||
|
||||
+18
-12
@@ -5,19 +5,24 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/appc/cni/pkg/skel"
|
||||
"github.com/appc/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/skel"
|
||||
"github.com/containernetworking/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/types/current"
|
||||
)
|
||||
|
||||
func (i *Ipam) CmdAdd(args *skel.CmdArgs) error {
|
||||
var conf types.NetConf
|
||||
if err := json.Unmarshal(args.StdinData, &conf); err != nil {
|
||||
return fmt.Errorf("failed to load netconf: %v", err)
|
||||
}
|
||||
result, err := i.Allocate(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return result.Print()
|
||||
return types.PrintResult(result, conf.CNIVersion)
|
||||
}
|
||||
|
||||
func (i *Ipam) Allocate(args *skel.CmdArgs) (*types.Result, error) {
|
||||
func (i *Ipam) Allocate(args *skel.CmdArgs) (types.Result, error) {
|
||||
// extract the things we care about
|
||||
conf, err := loadIPAMConf(args.StdinData)
|
||||
if err != nil {
|
||||
@@ -46,12 +51,13 @@ func (i *Ipam) Allocate(args *skel.CmdArgs) (*types.Result, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &types.Result{
|
||||
IP4: &types.IPConfig{
|
||||
IP: *ipnet,
|
||||
result := ¤t.Result{
|
||||
IPs: []*current.IPConfig{{
|
||||
Version: "4",
|
||||
Address: *ipnet,
|
||||
Gateway: conf.Gateway,
|
||||
Routes: conf.Routes,
|
||||
},
|
||||
}},
|
||||
Routes: conf.Routes,
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -65,9 +71,9 @@ func (i *Ipam) Release(args *skel.CmdArgs) error {
|
||||
}
|
||||
|
||||
type ipamConf struct {
|
||||
Subnet string `json:"subnet,omitempty"`
|
||||
Gateway net.IP `json:"gateway,omitempty"`
|
||||
Routes []types.Route `json:"routes"`
|
||||
Subnet string `json:"subnet,omitempty"`
|
||||
Gateway net.IP `json:"gateway,omitempty"`
|
||||
Routes []*types.Route `json:"routes"`
|
||||
}
|
||||
|
||||
type netConf struct {
|
||||
|
||||
+45
-19
@@ -5,11 +5,14 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/appc/cni/pkg/ipam"
|
||||
"github.com/appc/cni/pkg/skel"
|
||||
"github.com/appc/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/ipam"
|
||||
"github.com/containernetworking/cni/pkg/skel"
|
||||
"github.com/containernetworking/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/types/current"
|
||||
"github.com/vishvananda/netlink"
|
||||
"github.com/vishvananda/netns"
|
||||
weaveapi "github.com/weaveworks/weave/api"
|
||||
@@ -40,17 +43,26 @@ func loadNetConf(bytes []byte) (*NetConf, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (c *CNIPlugin) getIP(ipamType string, args *skel.CmdArgs) (result *types.Result, err error) {
|
||||
func (c *CNIPlugin) getIP(ipamType string, args *skel.CmdArgs) (newResult *current.Result, err error) {
|
||||
var result types.Result
|
||||
// Default IPAM is Weave's own
|
||||
if ipamType == "" {
|
||||
result, err = ipamplugin.NewIpam(c.weave).Allocate(args)
|
||||
} else {
|
||||
result, err = ipam.ExecAdd(ipamType, args.StdinData)
|
||||
}
|
||||
if err == nil && result.IP4 == nil {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result == nil {
|
||||
return nil, fmt.Errorf("Received no usable result from IPAM plugin")
|
||||
}
|
||||
newResult, err = current.NewResultFromResult(result)
|
||||
// Check if ipam returned no results without error
|
||||
if err == nil && len(newResult.IPs) == 0 {
|
||||
return nil, fmt.Errorf("IPAM plugin failed to allocate IP address")
|
||||
}
|
||||
return result, err
|
||||
return newResult, err
|
||||
}
|
||||
|
||||
func (c *CNIPlugin) CmdAdd(args *skel.CmdArgs) error {
|
||||
@@ -70,28 +82,35 @@ func (c *CNIPlugin) CmdAdd(args *skel.CmdArgs) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to allocate IP address: %s", err)
|
||||
}
|
||||
// Only expecting one address
|
||||
ip := result.IPs[0]
|
||||
|
||||
// If config says nothing about routes or gateway, default one will be via the bridge
|
||||
if result.IP4.Routes == nil && result.IP4.Gateway == nil {
|
||||
bridgeIP, err := weavenet.FindBridgeIP(conf.BrName, &result.IP4.IP)
|
||||
if len(result.Routes) == 0 && ip.Gateway == nil {
|
||||
bridgeIP, err := weavenet.FindBridgeIP(conf.BrName, &ip.Address)
|
||||
if err == weavenet.ErrBridgeNoIP {
|
||||
bridgeArgs := *args
|
||||
bridgeArgs.ContainerID = "weave:expose"
|
||||
// It would be better if libcni let us send just the desired parameters,
|
||||
// but there is a bug: https://github.com/containernetworking/cni/issues/410
|
||||
// so just blank out the one we want to change
|
||||
os.Setenv("CNI_CONTAINERID", bridgeArgs.ContainerID)
|
||||
bridgeIPResult, err := c.getIP(conf.IPAM.Type, &bridgeArgs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to allocate IP address for bridge: %s", err)
|
||||
}
|
||||
if err := assignBridgeIP(conf.BrName, bridgeIPResult.IP4.IP); err != nil {
|
||||
bridgeCIDR := bridgeIPResult.IPs[0].Address
|
||||
if err := assignBridgeIP(conf.BrName, bridgeCIDR); err != nil {
|
||||
return fmt.Errorf("unable to assign IP address to bridge: %s", err)
|
||||
}
|
||||
if err := weavenet.ExposeNAT(bridgeIPResult.IP4.IP); err != nil {
|
||||
if err := weavenet.ExposeNAT(bridgeCIDR); err != nil {
|
||||
return fmt.Errorf("unable to create NAT rules: %s", err)
|
||||
}
|
||||
bridgeIP = bridgeIPResult.IP4.IP.IP
|
||||
bridgeIP = bridgeCIDR.IP
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
result.IP4.Gateway = bridgeIP
|
||||
result.IPs[0].Gateway = bridgeIP
|
||||
}
|
||||
|
||||
ns, err := netns.GetFromPath(args.Netns)
|
||||
@@ -110,20 +129,20 @@ func (c *CNIPlugin) CmdAdd(args *skel.CmdArgs) error {
|
||||
id = fmt.Sprintf("%x", data)
|
||||
}
|
||||
|
||||
if err := weavenet.AttachContainer(args.Netns, id, args.IfName, conf.BrName, conf.MTU, false, []*net.IPNet{&result.IP4.IP}, false); err != nil {
|
||||
if err := weavenet.AttachContainer(args.Netns, id, args.IfName, conf.BrName, conf.MTU, false, []*net.IPNet{&ip.Address}, false); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := weavenet.WithNetNSLinkUnsafe(ns, args.IfName, func(link netlink.Link) error {
|
||||
return setupRoutes(link, args.IfName, result.IP4.IP, result.IP4.Gateway, result.IP4.Routes)
|
||||
return setupRoutes(link, args.IfName, ip.Address, ip.Gateway, result.Routes)
|
||||
}); err != nil {
|
||||
return fmt.Errorf("error setting up routes: %s", err)
|
||||
}
|
||||
|
||||
result.DNS = conf.DNS
|
||||
return result.Print()
|
||||
return types.PrintResult(result, conf.CNIVersion)
|
||||
}
|
||||
|
||||
func setupRoutes(link netlink.Link, name string, ipnet net.IPNet, gw net.IP, routes []types.Route) error {
|
||||
func setupRoutes(link netlink.Link, name string, ipnet net.IPNet, gw net.IP, routes []*types.Route) error {
|
||||
var err error
|
||||
if routes == nil { // If config says nothing about routes, add a default one
|
||||
if !ipnet.Contains(gw) {
|
||||
@@ -133,7 +152,7 @@ func setupRoutes(link netlink.Link, name string, ipnet net.IPNet, gw net.IP, rou
|
||||
return err
|
||||
}
|
||||
}
|
||||
routes = []types.Route{{Dst: zeroNetwork}}
|
||||
routes = []*types.Route{{Dst: zeroNetwork}}
|
||||
}
|
||||
for _, r := range routes {
|
||||
if r.GW != nil {
|
||||
@@ -170,8 +189,11 @@ func (c *CNIPlugin) CmdDel(args *skel.CmdArgs) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err = weavenet.WithNetNS(args.Netns, "del-iface", args.IfName); err != nil {
|
||||
return fmt.Errorf("error removing interface %q: %s", args.IfName, err)
|
||||
// As of CNI 0.3 spec, runtimes can send blank if they just want the address deallocated
|
||||
if args.Netns != "" {
|
||||
if _, err = weavenet.WithNetNS(args.Netns, "del-iface", args.IfName); err != nil {
|
||||
return fmt.Errorf("error removing interface %q: %s", args.IfName, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Default IPAM is Weave's own
|
||||
@@ -180,6 +202,10 @@ func (c *CNIPlugin) CmdDel(args *skel.CmdArgs) error {
|
||||
} else {
|
||||
err = ipam.ExecDel(conf.IPAM.Type, args.StdinData)
|
||||
}
|
||||
// Hack - don't know how we should detect this situation properly
|
||||
if args.Netns == "" && strings.Contains(err.Error(), "no addresses") {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to release IP address: %s", err)
|
||||
}
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ func run(dockerClient *docker.Client, weave *weaveapi.Client, address, meshAddre
|
||||
}
|
||||
go serveStatus(statusListener)
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, os.Interrupt, os.Kill, syscall.SIGTERM)
|
||||
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
select {
|
||||
case sig := <-sigChan:
|
||||
|
||||
@@ -2,6 +2,23 @@
|
||||
|
||||
set -e
|
||||
|
||||
modprobe_safe() {
|
||||
modprobe $1 || echo "Ignore the error if \"$1\" is built-in in the kernel" >&2
|
||||
}
|
||||
|
||||
# Check whether xt_set actually exists
|
||||
xt_set_exists() {
|
||||
ipset create weave-kube-test hash:ip
|
||||
iptables -t filter -N WEAVE-KUBE-TEST
|
||||
if ! iptables -A WEAVE-KUBE-TEST -m set --match-set weave-kube-test src -j DROP; then
|
||||
NOT_EXIST=1
|
||||
fi
|
||||
iptables -F WEAVE-KUBE-TEST
|
||||
iptables -X WEAVE-KUBE-TEST
|
||||
ipset destroy weave-kube-test
|
||||
[ -z "$NOT_EXIST" ] || (echo "\"xt_set\" does not exist" >&2 && return 1)
|
||||
}
|
||||
|
||||
# Default if not supplied - same as weave net default
|
||||
IPALLOC_RANGE=${IPALLOC_RANGE:-10.32.0.0/12}
|
||||
HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784}
|
||||
@@ -17,8 +34,9 @@ EXPECT_NPC=${EXPECT_NPC:-1}
|
||||
|
||||
# Ensure we have the required modules for NPC
|
||||
if [ "${EXPECT_NPC}" != "0" ]; then
|
||||
modprobe br_netfilter
|
||||
modprobe xt_set
|
||||
modprobe_safe br_netfilter
|
||||
modprobe_safe xt_set
|
||||
xt_set_exists
|
||||
fi
|
||||
|
||||
# kube-proxy requires that bridged traffic passes through netfilter
|
||||
@@ -99,7 +117,7 @@ post_start_actions() {
|
||||
|
||||
post_start_actions &
|
||||
|
||||
exec /home/weave/weaver $EXTRA_ARGS --port=6783 $BRIDGE_OPTIONS \
|
||||
/home/weave/weaver $EXTRA_ARGS --port=6783 $BRIDGE_OPTIONS \
|
||||
--http-addr=$HTTP_ADDR --status-addr=$STATUS_ADDR --docker-api='' --no-dns \
|
||||
--ipalloc-range=$IPALLOC_RANGE $NICKNAME_ARG \
|
||||
--ipalloc-init $IPALLOC_INIT \
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: weave-net
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- pods
|
||||
- namespaces
|
||||
- nodes
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
- apiGroups:
|
||||
- extensions
|
||||
resources:
|
||||
- networkpolicies
|
||||
verbs:
|
||||
- get
|
||||
- list
|
||||
- watch
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: weave-net
|
||||
namespace: kube-system
|
||||
---
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: weave-net
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: weave-net
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: weave-net
|
||||
namespace: kube-system
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: weave-net
|
||||
namespace: kube-system
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: weave-net
|
||||
spec:
|
||||
hostNetwork: true
|
||||
hostPID: true
|
||||
containers:
|
||||
- name: weave
|
||||
image: weaveworks/weave-kube:latest
|
||||
imagePullPolicy: Always
|
||||
command:
|
||||
- /home/weave/launch.sh
|
||||
livenessProbe:
|
||||
initialDelaySeconds: 30
|
||||
httpGet:
|
||||
host: 127.0.0.1
|
||||
path: /status
|
||||
port: 6784
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: weavedb
|
||||
mountPath: /weavedb
|
||||
- name: cni-bin
|
||||
mountPath: /host/opt
|
||||
- name: cni-bin2
|
||||
mountPath: /host/home
|
||||
- name: cni-conf
|
||||
mountPath: /host/etc
|
||||
- name: dbus
|
||||
mountPath: /host/var/lib/dbus
|
||||
- name: lib-modules
|
||||
mountPath: /lib/modules
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
- name: weave-npc
|
||||
image: weaveworks/weave-npc:latest
|
||||
imagePullPolicy: Always
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
securityContext:
|
||||
privileged: true
|
||||
restartPolicy: Always
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
effect: NoSchedule
|
||||
serviceAccountName: weave-net
|
||||
securityContext:
|
||||
seLinuxOptions:
|
||||
type: spc_t
|
||||
volumes:
|
||||
- name: weavedb
|
||||
emptyDir: {}
|
||||
- name: cni-bin
|
||||
hostPath:
|
||||
path: /opt
|
||||
- name: cni-bin2
|
||||
hostPath:
|
||||
path: /home
|
||||
- name: cni-conf
|
||||
hostPath:
|
||||
path: /etc
|
||||
- name: dbus
|
||||
hostPath:
|
||||
path: /var/lib/dbus
|
||||
- name: lib-modules
|
||||
hostPath:
|
||||
path: /lib/modules
|
||||
+12
-4
@@ -80,14 +80,22 @@ func resetIPTables(ipt *iptables.IPTables) error {
|
||||
}
|
||||
|
||||
func resetIPSets(ips ipset.Interface) error {
|
||||
// TODO should restrict ipset operations to the `weave-` prefix:
|
||||
// Remove ipsets prefixed `weave-` only
|
||||
|
||||
if err := ips.FlushAll(); err != nil {
|
||||
sets, err := ips.List(npc.IpsetNamePrefix)
|
||||
if err != nil {
|
||||
common.Log.Errorf("Failed to retrieve list of ipsets")
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ips.DestroyAll(); err != nil {
|
||||
return err
|
||||
common.Log.Debugf("Got list of ipsets: %v", sets)
|
||||
|
||||
for _, s := range sets {
|
||||
common.Log.Debugf("Destroying ipsets '%s'", string(s))
|
||||
if err := ips.Destroy(s); err != nil {
|
||||
common.Log.Errorf("Failed to destroy ipset '%s'", string(s))
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -19,6 +19,7 @@ RUN apk add --update \
|
||||
curl \
|
||||
ethtool \
|
||||
iptables \
|
||||
ipset \
|
||||
iproute2 \
|
||||
util-linux \
|
||||
conntrack-tools \
|
||||
|
||||
@@ -3,7 +3,8 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
cni "github.com/appc/cni/pkg/skel"
|
||||
cni "github.com/containernetworking/cni/pkg/skel"
|
||||
"github.com/containernetworking/cni/pkg/version"
|
||||
|
||||
weaveapi "github.com/weaveworks/weave/api"
|
||||
"github.com/weaveworks/weave/common"
|
||||
@@ -14,13 +15,13 @@ import (
|
||||
func cniNet(args []string) error {
|
||||
weave := weaveapi.NewClient(os.Getenv("WEAVE_HTTP_ADDR"), common.Log)
|
||||
n := netplugin.NewCNIPlugin(weave)
|
||||
cni.PluginMain(n.CmdAdd, n.CmdDel)
|
||||
cni.PluginMain(n.CmdAdd, n.CmdDel, version.PluginSupports("0.1.0", "0.2.0", "0.3.0"))
|
||||
return nil
|
||||
}
|
||||
|
||||
func cniIPAM(args []string) error {
|
||||
weave := weaveapi.NewClient(os.Getenv("WEAVE_HTTP_ADDR"), common.Log)
|
||||
i := ipamplugin.NewIpam(weave)
|
||||
cni.PluginMain(i.CmdAdd, i.CmdDel)
|
||||
cni.PluginMain(i.CmdAdd, i.CmdDel, version.PluginSupports("0.1.0", "0.2.0", "0.3.0"))
|
||||
return nil
|
||||
}
|
||||
@@ -45,7 +45,6 @@ func dockerTLSArgs(args []string) error {
|
||||
switch {
|
||||
case arg == "-d" || arg == "daemon":
|
||||
isDaemon = true
|
||||
break
|
||||
case arg == "--tls", arg == "--tlsverify":
|
||||
tlsArgs = append(tlsArgs, arg)
|
||||
case strings.HasPrefix(arg, "--tls"):
|
||||
|
||||
@@ -16,6 +16,6 @@ func uniqueID(args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf(uid)
|
||||
fmt.Print(uid)
|
||||
return nil
|
||||
}
|
||||
+5
-3
@@ -577,8 +577,8 @@ type fastDatapathForwarder struct {
|
||||
confirmed bool
|
||||
remoteAddr *net.UDPAddr
|
||||
heartbeatInterval time.Duration
|
||||
heartbeatTimer *time.Timer
|
||||
heartbeatTimeout *time.Timer
|
||||
heartbeatTimer *time.Timer // for sending
|
||||
heartbeatTimeout *time.Timer // for receiving
|
||||
ackedHeartbeat bool
|
||||
stopChan chan struct{}
|
||||
stopped bool
|
||||
@@ -856,7 +856,9 @@ func (fwd *fastDatapathForwarder) handleCryptoInitSARemote(msg []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
if !fwd.isOutboundIPSecEstablished {
|
||||
// FastDatapathCryptoInitSARemote can be received before Confirm'ing
|
||||
// connection, thus before InitSALocal.
|
||||
if fwd.confirmed && !fwd.isOutboundIPSecEstablished {
|
||||
fwd.isOutboundIPSecEstablished = true
|
||||
fwd.heartbeatTimer.Reset(0)
|
||||
}
|
||||
|
||||
+5
-3
@@ -6,7 +6,6 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -1039,6 +1038,9 @@ func (sender *udpSenderDF) dial() error {
|
||||
laddr := &net.IPAddr{IP: sender.localIP}
|
||||
raddr := &net.IPAddr{IP: sender.remoteIP}
|
||||
s, err := net.DialIP("ip4:UDP", laddr, raddr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f, err := s.File()
|
||||
if err != nil {
|
||||
@@ -1059,7 +1061,7 @@ func (sender *udpSenderDF) dial() error {
|
||||
|
||||
func (sender *udpSenderDF) send(msg []byte, raddr *net.UDPAddr) error {
|
||||
// Ensure we have a socket sending to the right IP address
|
||||
if sender.socket == nil || !bytes.Equal(sender.remoteIP, raddr.IP) {
|
||||
if sender.socket == nil || !sender.remoteIP.Equal(raddr.IP) {
|
||||
sender.remoteIP = raddr.IP
|
||||
if err := sender.dial(); err != nil {
|
||||
return err
|
||||
@@ -1111,7 +1113,7 @@ func (sender *udpSenderDF) close() error {
|
||||
}
|
||||
|
||||
func udpAddrsEqual(a *net.UDPAddr, b *net.UDPAddr) bool {
|
||||
return bytes.Equal(a.IP, b.IP) && a.Port == b.Port && a.Zone == b.Zone
|
||||
return a.IP.Equal(b.IP) && a.Port == b.Port && a.Zone == b.Zone
|
||||
}
|
||||
|
||||
func allZeros(s []byte) bool {
|
||||
|
||||
@@ -15,23 +15,21 @@ or
|
||||
host1$ export WEAVE_PASSWORD=wfvAwt7sj
|
||||
host1$ weave launch
|
||||
|
||||
>**NOTE**: The command line option takes precedence over the environment variable._
|
||||
>**NOTE**: The command line option takes precedence over the environment variable.
|
||||
|
||||
> To avoid leaking your password via the kernel process table or your
|
||||
> shell history, we recommend you store it in a file and capture it
|
||||
> in a shell variable prior to launching weave: `export
|
||||
> WEAVE_PASSWORD=$(cat /path/to/password-file)`
|
||||
|
||||
To guard against dictionary attacks, the password needs to be reasonably strong with at least 50 bits of entropy is recommended. An easy way to generate a random password that satisfies this requirement is:
|
||||
To guard against dictionary attacks, the password needs to be reasonably strong,
|
||||
with at least 50 bits of entropy. An easy way to generate a random password that
|
||||
satisfies this requirement is:
|
||||
|
||||
< /dev/urandom tr -dc A-Za-z0-9 | head -c9 ; echo
|
||||
|
||||
The same password must be specified for all Weave Net peers, by default both control and data plane traffic will then use authenticated encryption.
|
||||
|
||||
[Fast datapath](/site/using-weave/fastdp.md) does not support
|
||||
encryption. If you supply a password at `weave launch`, Weave Net
|
||||
falls back to the slower `sleeve` mode for encrypted communication.
|
||||
|
||||
As an optimization, you can selectively disable data plane encryption
|
||||
if some of your peers are co-located in a trusted network, for example
|
||||
within the boundary of your own data center. List these networks using
|
||||
@@ -40,9 +38,8 @@ the `--trusted-subnets` argument with `weave launch`:
|
||||
weave launch --password wfvAwt7sj --trusted-subnets 10.0.2.0/24,192.168.48.0/24
|
||||
|
||||
If *both* peers at the end of a connection consider the other to be in
|
||||
a trusted subnet, Weave Net attempts to establish fast datapath
|
||||
connectivity, which is unencrypted. Otherwise communication is encrypted which
|
||||
imposes overheads.
|
||||
the same trusted subnet, Weave Net attempts to establish non-encrypted
|
||||
connectivity. Otherwise communication is encrypted which imposes overheads.
|
||||
|
||||
Configured trusted subnets are shown in [`weave status`](/site/troubleshooting.md#weave-status).
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ start_suite "Test CNI plugin"
|
||||
cni_connect() {
|
||||
pid=$(container_pid $1 $2)
|
||||
id=$(docker_on $1 inspect -f '{{.Id}}' $2)
|
||||
run_on $1 sudo CNI_VERSION=1 CNI_COMMAND=ADD CNI_CONTAINERID=$id CNI_IFNAME=eth0 \
|
||||
run_on $1 sudo CNI_COMMAND=ADD CNI_CONTAINERID=$id CNI_IFNAME=eth0 \
|
||||
CNI_NETNS=/proc/$pid/ns/net CNI_PATH=/opt/cni/bin /opt/cni/bin/weave-net
|
||||
}
|
||||
|
||||
@@ -16,11 +16,23 @@ run_on $HOST1 sudo mkdir -p /opt/cni/bin
|
||||
weave_on $HOST1 setup-cni
|
||||
weave_on $HOST1 launch
|
||||
|
||||
C0=$(docker_on $HOST1 run --net=none --name=c0 -dt $SMALL_IMAGE /bin/sh)
|
||||
C1=$(docker_on $HOST1 run --net=none --privileged --name=c1 -dt $SMALL_IMAGE /bin/sh)
|
||||
C2=$(docker_on $HOST1 run --net=none --name=c2 -dt $SMALL_IMAGE /bin/sh)
|
||||
# Enable unsolicited ARPs so that ping after the address reuse does not time out
|
||||
exec_on $HOST1 c1 sysctl -w net.ipv4.conf.all.arp_accept=1
|
||||
|
||||
# Contrived example to trigger the bug in #2839
|
||||
cni_connect $HOST1 c0 <<EOF
|
||||
{
|
||||
"name": "weave",
|
||||
"type": "weave-net",
|
||||
"ipam": {
|
||||
"type": "weave-ipam"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cni_connect $HOST1 c1 <<EOF
|
||||
{
|
||||
"name": "weave",
|
||||
@@ -30,6 +42,7 @@ EOF
|
||||
|
||||
cni_connect $HOST1 c2 <<EOF
|
||||
{
|
||||
"cniVersion": "0.3.0",
|
||||
"name": "weave",
|
||||
"type": "weave-net",
|
||||
"ipam": {
|
||||
@@ -39,9 +52,16 @@ cni_connect $HOST1 c2 <<EOF
|
||||
}
|
||||
EOF
|
||||
|
||||
C0IP=$(container_ip $HOST1 c0)
|
||||
C1IP=$(container_ip $HOST1 c1)
|
||||
C2IP=$(container_ip $HOST1 c2)
|
||||
|
||||
# Check the bridge IP is different from the container IPs
|
||||
BRIP=$(container_ip $HOST1 weave:expose)
|
||||
assert_raises "[ $BRIP != $C0IP ]"
|
||||
assert_raises "[ $BRIP != $C1IP ]"
|
||||
assert_raises "[ $BRIP != $C2IP ]"
|
||||
|
||||
assert_raises "exec_on $HOST1 c1 $PING $C2IP"
|
||||
assert_raises "exec_on $HOST1 c2 $PING $C1IP"
|
||||
# Check if the route to the outside world works
|
||||
@@ -62,6 +82,7 @@ C3IP=$(container_ip $HOST1 c3)
|
||||
|
||||
# CNI shouldn't re-use the address until we call DEL
|
||||
assert_raises "[ $C2IP != $C3IP ]"
|
||||
assert_raises "[ $BRIP != $C3IP ]"
|
||||
assert_raises "exec_on $HOST1 c1 $PING $C3IP"
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ SUCCESS="6 established"
|
||||
|
||||
tear_down_kubeadm
|
||||
|
||||
# Make an ipset, so we can check it doesn't get wiped out by Weave Net
|
||||
docker_on $HOST1 run --rm --privileged --net=host --entrypoint=/usr/sbin/ipset weaveworks/weave-npc create test_840_ipset bitmap:ip range 192.168.1.0/24 || true
|
||||
docker_on $HOST1 run --rm --privileged --net=host --entrypoint=/usr/sbin/ipset weaveworks/weave-npc add test_840_ipset 192.168.1.11
|
||||
|
||||
run_on $HOST1 "sudo systemctl start kubelet && sudo kubeadm init --token=$TOKEN"
|
||||
run_on $HOST2 "sudo systemctl start kubelet && sudo kubeadm join --token=$TOKEN $HOST1IP"
|
||||
run_on $HOST3 "sudo systemctl start kubelet && sudo kubeadm join --token=$TOKEN $HOST1IP"
|
||||
@@ -52,6 +56,11 @@ assert_raises "run_on $HOST1 $PING $HOST2EXPIP"
|
||||
assert_raises "run_on $HOST2 $PING $HOST1EXPIP"
|
||||
assert_raises "run_on $HOST3 $PING $HOST2EXPIP"
|
||||
|
||||
# Ensure we do not generate any defunct process (e.g. launch.sh) after starting weaver:
|
||||
assert "run_on $HOST1 ps aux | grep -c '[d]efunct'" "0"
|
||||
assert "run_on $HOST2 ps aux | grep -c '[d]efunct'" "0"
|
||||
assert "run_on $HOST3 ps aux | grep -c '[d]efunct'" "0"
|
||||
|
||||
# See if we can get some pods running that connect to the network
|
||||
run_on $HOST1 "kubectl run hello --image=weaveworks/hello-world --replicas=3"
|
||||
|
||||
@@ -71,4 +80,7 @@ assert_raises wait_for_pods
|
||||
|
||||
tear_down_kubeadm
|
||||
|
||||
# Destroy our test ipset, and implicitly check it is still there
|
||||
assert_raises "docker_on $HOST1 run --rm --privileged --net=host --entrypoint=/usr/sbin/ipset weaveworks/weave-npc destroy test_840_ipset"
|
||||
|
||||
end_suite
|
||||
@@ -274,11 +274,21 @@ start_suite() {
|
||||
PLUGIN_FILTER=$(docker_on $host inspect -f 'grep -v {{printf "%.12s" .Id}}' weaveplugin 2>/dev/null) || PLUGIN_FILTER=cat
|
||||
rm_containers $host $(docker_on $host ps -aq 2>/dev/null | $PLUGIN_FILTER)
|
||||
weave_on $host reset 2>/dev/null
|
||||
run_on $host sudo rm -f /opt/cni/bin/weave-plugin-latest /opt/cni/bin/weave-net /opt/cni/bin/weave-ipam /etc/cni/net.d/10-weave.conf
|
||||
done
|
||||
whitely echo "$@"
|
||||
}
|
||||
|
||||
# Common postconditions to assert on each host, after each test:
|
||||
assert_common_postconditions() {
|
||||
# Ensure we do not generate any defunct (a.k.a. zombie) process:
|
||||
assert "run_on $1 ps aux | grep -c '[d]efunct'" "0"
|
||||
}
|
||||
|
||||
end_suite() {
|
||||
for host in $HOSTS; do
|
||||
assert_common_postconditions "$host"
|
||||
done
|
||||
whitely assert_end
|
||||
for host in $HOSTS; do
|
||||
stop_weave_on $host
|
||||
|
||||
+1
-1
Submodule tools updated: 51785b5fc9...310f53dc10.
-1
Submodule vendor/github.com/appc/cni deleted from 8bb41b9d6f.
+1
Submodule vendor/github.com/containernetworking/cni added at 4ce9b019aa.
Reference in new issue
Block a user