* highlight the need for `weave expose` in CNI/k8s Fixes #2405 * Extend error message * rearranged the sentences weave launch <peer hosts> seems a bit orphaned here maybe include the weave connect command as well, since it's being mentioned.
2.8 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
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
###Launching Weave Net
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
weave connect.
See Creating Peer Connections Between Hosts for a discussion on peer connections.
weave launch <peer hosts>
Next, assign an IP address to the Weave bridge and enable access to containers from the host, which is required by Kubernetes, by running the following:
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.