2.7 KiB
title, menu_order
| title | menu_order |
|---|---|
| Integrating Kubernetes via the CNI Plugin | 65 |
CNI, the Container Network Interface, is a proposed standard for configuring network interfaces for Linux application containers. CNI is supported by Kubernetes, an open source container cluster manager built by Google.
###Installing the Weave Net CNI plugin
The Weave Net CNI plugin is installed when you run weave setup, if
your machine has the directories normally used to host CNI plugins.
To create those directories, run (as root):
mkdir -p /opt/cni/bin
mkdir -p /etc/cni/net.d
Then run:
weave setup
###Launching Weave Net
To create a network which can span multiple hosts, the Weave peers must be connected to each other, by specifying the other hosts during weave launch or via
weave connect.
See Using Weave Net for a discussion on peer connections.
As well as launching Weave Net, you have to run an extra command to perform some additional configuration of the Weave bridge:
weave launch <peer hosts>
weave expose
###Configuring Kubernetes to use the CNI Plugin
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 kubelet documentation
for more details.
Now, whenever Kubernetes starts a pod, it will be attached to the Weave network.
###Using the CNI network configuration file
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.conf, which you can alter to suit your needs.
See the CNI Spec for details on the format and contents of this file.
By default, the Weave CNI plugin adds a default route out via 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 IPAMipam / subnet- default is to use Weave's IPAM default subnetipam / gateway- default is to use the Weave bridge IP address (allocated byweave expose)
###Caveats
- The Weave Net router container must be running for CNI to allocate addresses
- The CNI plugin does not add entries to weaveDNS.