Fix to use 10-weave.conflist instead of 10-weave.conf as CNI config file.

Also adds support for portmap as additional plugin along with weave-net

Fixes #3016
This commit is contained in:
Murali Reddy committed 2018-08-31 16:11:24 +05:30
1 parent ad4e4238a5
commit 90907a7647
4 files changed
+28 -10

No files matched your search

+4 -4
View File
@@ -35,21 +35,21 @@ weave-kube is an image with the weave binaries and a wrapper script installed. I
1. Setting up the weave network 1. Setting up the weave network
2. Connecting to peers 2. Connecting to peers
3. Copy the weave CNI-compatible binary plugin `weaveutil` to `/opt/cni/bin/weave-net` and weave config in `/etc/cni/net.d/10-weave.conf` 3. Copy the weave CNI-compatible binary plugin `weaveutil` to `/opt/cni/bin/weave-net` and weave config in `/etc/cni/net.d/10-weave.conflist`
4. Running the weave network policy controller (weave-npc) to implement kubernetes' `NetworkPolicy` 4. Running the weave network policy controller (weave-npc) to implement kubernetes' `NetworkPolicy`
Once installation is complete, each network-relevant change in a container leads `kubelet` to: Once installation is complete, each network-relevant change in a container leads `kubelet` to:
1. Set certain environment variables to configure the CNI plugin, mostly related to the container ID 1. Set certain environment variables to configure the CNI plugin, mostly related to the container ID
2. Launch `/opt/cni/bin/weave-net` 2. Launch `/opt/cni/bin/weave-net`
3. Pass the CNI config - the contents of `/etc/cni/net.d/10-weave.conf` to `weave-net` 3. Pass the CNI config - the contents of `/etc/cni/net.d/10-weave.conflist` to `weave-net`
Thus, when each container is changed, and `kubelet` calls weave as a CNI plugin, it really just is launching `weaveutil` as `weave-net`. Thus, when each container is changed, and `kubelet` calls weave as a CNI plugin, it really just is launching `weaveutil` as `weave-net`.
The installation and setup of all of the above - and therefore the entrypoint to the weave-kube image - is the script `prog/weave-kube/launch.sh`. `launch.sh` does the following: The installation and setup of all of the above - and therefore the entrypoint to the weave-kube image - is the script `prog/weave-kube/launch.sh`. `launch.sh` does the following:
1. Read configuration variables from the environment. When the documentation for `weave-kube` describes configuring the weave network by changing the environment variables in the daemonset in the `.yml` file, `launch.sh` reads these environment variables. 1. Read configuration variables from the environment. When the documentation for `weave-kube` describes configuring the weave network by changing the environment variables in the daemonset in the `.yml` file, `launch.sh` reads these environment variables.
2. Set up the config file at `/etc/cni/net.d/10-weave.conf` 2. Set up the config file at `/etc/cni/net.d/10-weave.conflist`
3. Run the `weave` initialization script 3. Run the `weave` initialization script
4. Run `weaver` with the correct configuration passed as command-line options 4. Run `weaver` with the correct configuration passed as command-line options
@@ -66,5 +66,5 @@ To add new options to how weave should run with each invocation, you would do th
* have `prog/weave-kube/launch.sh` read it as an environment variable and set inside * have `prog/weave-kube/launch.sh` read it as an environment variable and set inside
* set a default for the environment variable in `prog/weave-kube/weave-daemonset-k8s-1.6.yaml` and `weave-daemonset.yaml` * set a default for the environment variable in `prog/weave-kube/weave-daemonset-k8s-1.6.yaml` and `weave-daemonset.yaml`
* if it should be set via `weaver` globally on its one-time initialization invocation, pass it on in `launch.sh` * if it should be set via `weaver` globally on its one-time initialization invocation, pass it on in `launch.sh`
* if it needs to be set via `weaveutil` on each invocation of `weave-net`, have `launch.sh` save it as an option in the CNI config file `/etc/cni/net.d/10-weave.conf` and then have the CNI code in `plugin/net/cni.go` in `weaveutil` read it and use where appropriate * if it needs to be set via `weaveutil` on each invocation of `weave-net`, have `launch.sh` save it as an option in the CNI config file `/etc/cni/net.d/10-weave.conflist` and then have the CNI code in `plugin/net/cni.go` in `weaveutil` read it and use where appropriate
7. Document it! 7. Document it!
+3 -1
View File
@@ -30,6 +30,8 @@ Then run:
weave setup weave setup
Weave net depends on the *portmap* [standard](https://github.com/containernetworking/plugins) CNI plugin to support *hostport* functionality. Please ensure that *portmap* CNI plugin is installed in `/opt/cni/bin` directory.
#### Launching Weave Net #### Launching Weave Net
To create a network that spans multiple hosts, the Weave peers must be connected to each other. To create a network that spans multiple hosts, the Weave peers must be connected to each other.
@@ -45,7 +47,7 @@ for a discussion on peer connections.
All CNI plugins are configured by a JSON file in the directory All CNI plugins are configured by a JSON file in the directory
`/etc/cni/net.d/`. `weave setup` installs a minimal configuration `/etc/cni/net.d/`. `weave setup` installs a minimal configuration
file named `10-weave.conf`, which you can alter to suit your needs. file named `10-weave.conflist`, which you can alter to suit your needs.
See the [CNI Spec](https://github.com/appc/cni/blob/master/SPEC.md#network-configuration) See the [CNI Spec](https://github.com/appc/cni/blob/master/SPEC.md#network-configuration)
for details on the format and contents of this file. for details on the format and contents of this file.
+1 -1
View File
@@ -329,7 +329,7 @@ start_suite() {
[ -z "$DEBUG" ] || echo "Cleaning up on $host: removing all containers and resetting weave" [ -z "$DEBUG" ] || echo "Cleaning up on $host: removing all containers and resetting weave"
rm_containers $host $(docker_on $host ps -aq 2>/dev/null) rm_containers $host $(docker_on $host ps -aq 2>/dev/null)
weave_on $host reset 2>/dev/null 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 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.conflist
done done
whitely echo "$@" whitely echo "$@"
} }
+20 -4
View File
@@ -729,9 +729,20 @@ upgrade_cni_plugin() {
create_cni_config() { create_cni_config() {
cat >"$1" <<EOF cat >"$1" <<EOF
{ {
"cniVersion": "0.3.0",
"name": "weave", "name": "weave",
"type": "weave-net", "plugins": [
"hairpinMode": $2 {
"name": "weave",
"type": "weave-net",
"hairpinMode": $2
},
{
"type": "portmap",
"capabilities": {"portMappings": true},
"snat": true
}
]
} }
EOF EOF
} }
@@ -742,8 +753,13 @@ setup_cni() {
if install_cni_plugin $CNI_PLUGIN_DIR ; then if install_cni_plugin $CNI_PLUGIN_DIR ; then
upgrade_cni_plugin $CNI_PLUGIN_DIR upgrade_cni_plugin $CNI_PLUGIN_DIR
fi fi
if [ -d $HOST_ROOT/etc/cni/net.d -a ! -f $HOST_ROOT/etc/cni/net.d/10-weave.conf ] ; then
create_cni_config $HOST_ROOT/etc/cni/net.d/10-weave.conf $HAIRPIN_MODE # Weave will use .conflist for versions > 2.4.0. So in case of upgrade of old
# clusters with Weave version <= 2.4.0 remove existing 10-weave.conf
rm -f $HOST_ROOT/etc/cni/net.d/10-weave.conf
if [ -d $HOST_ROOT/etc/cni/net.d -a ! -f $HOST_ROOT/etc/cni/net.d/10-weave.conflist ] ; then
create_cni_config $HOST_ROOT/etc/cni/net.d/10-weave.conflist $HAIRPIN_MODE
fi fi
} }