Project: Weave Net (Runtime / Cloud Native Network)
File: kubernetes.md

title: Integrating Kubernetes and Mesos via the CNI Plugin menu_order: 40 search_type: Documentation The recommended way of using Weave with Kubernetes is via the new . The instructions below remain valid however, and are still the recommended method for integrating with Mesos. CNI, the , is a proposed standard for configuring network interfaces for Linux application containers. CNI is supported by , and . If your machine has the directories normally used to host CNI plugins, then the Weave Net CNI plugin is installed when you run `weave setup`. To create those directories, run (as root): mkdir -p /opt/cni/bin mkdir -p /etc/cni/net.d Then run: weave setup Weave net depends on the portmap CNI plugin to support hostport functionality. Please ensure that portmap CNI plugin is installed in `/opt/cni/bin` directory. To create a network that spans multiple hosts, the Weave peers must be connected to each other. This is accomplished by specifying the other hosts during `weave launch` or via . See for a discussion on peer connections. weave launch <peer hosts> All CNI plugins are configured by a JSON file in the directory `/etc/cni/net.d/`. `weave setup` installs a minimal configuration file named `10-weave.conflist`, which you can alter to suit your needs. See the for details on the format and contents of this file. By default, the Weave CNI plugin adds a default route out via an IP address on the Weave bridge, so your containers can access resources on the internet. If you do not want this, add a section to the config file that specifies no routes: "ipam": { "routes": [ ] } The following other fields in the spec are supported: `ipam / type` - default is to use Weave's own IPAM `ipam / subnet` - default is to use Weave's IPAM default subnet `ipam / gateway` - default is to use the Weave bridge IP address (allocated by `weave expose`) After you've launched Weave and peered your hosts, you can configure Kubernetes to use Weave, by adding the following options to the `kubelet` command: --network-plugin=cni --network-plugin-dir=/etc/cni/net.d See the for more details. Now, whenever Kubernetes starts a pod, it will be attached to the Weave network. To use the CNI plugin, the Mesos Agent must be started with reference to the CNI configuration and binary directories: sudo mesos-slave --networkcniconfig_dir=/etc/cni/net.d --networkcniplugins_dir=/opt/cni/bin ... To start a container that is connected to the Weave network via CNI, use the name specified in the configuration file. This example starts a alpine container running a `nc` server listening on port 1080 with the `mesos-execute` command. From the Master, run: nohup sudo mesos-execute --command="ifconfig; nc -k -l 0.0.0.0 1080" --docker_image=alpine --master=localhost:5050 --name=example --networks=weave --resources=cpus:0.1 --shell </dev/null >test.log 2>&1 & After this task has started, it is possible to obtain the ip address of the container and ping it from any of other agents (which are also connected to the weave network)" nc -z -v <IP FROM LOGS> 1080 For more information, see the . The program `nsenter` must be present on the host; it is required by the CNI plugin. In some distros (e.g. Alpine, Ubuntu) it is in the util-linux package The Weave Net router container must be running for CNI to allocate addresses The CNI plugin does not add entries to weaveDNS.