Compare commits

...
80 Commits
Author SHA1 Message Date
Bryan Boreham afb0d5bd3d Add release v1.9.6 2017-05-30 16:28:11 +00:00
Bryan Boreham 2d3e070288 Let through connections from local pods to non-local pods
This means we only filter connections at the destination end,
which is a better match for the ingress-only rules.
2017-05-30 14:11:35 +00:00
Bryan Boreham 138141ac9b Ignore updates for pods on other nodes 2017-05-30 14:11:34 +00:00
Bryan Boreham fa56ad8bc3 Refactor: move logging of ipset entries down to ipset package 2017-05-30 14:11:33 +00:00
Bryan Boreham 9d29da8d27 Refactor creation of base iptables rules 2017-05-30 14:11:31 +00:00
Bryan Boreham 68f2cb9caa Merge pull request #2993 from weaveworks/hairpin-option-1.9
Turn on hairpin mode on veth bridge ports
2017-05-30 14:50:37 +01:00
Avi Deitcher d13c7ea7ee Make hairpin mode default true in CNI 2017-05-30 10:30:54 +00:00
Avi Deitcher 4c7c702b6d Test of hairpin mode in CNI 2017-05-30 10:30:54 +00:00
Avi Deitcher c05955d598 First cut of adding hairpin functionality to weave 2017-05-30 10:30:49 +00:00
Bryan Boreham ca64ab54e7 Remove trailing space 2017-05-30 10:30:02 +00:00
Àbéjídé Àyodélé e64442f6de Highlight the forward rules 2017-05-25 13:43:51 +00:00
Bryan Boreham 987a1618e9 Merge pull request #2985 from weaveworks/fix-broken-url-to-ecs-guide
Fix broken link to ECS guide
2017-05-23 17:59:49 +01:00
Marc CARRE 0ab95cdd27 Fix broken URL to ECS guide. 2017-05-23 16:58:36 +00:00
Marc Carré b0d0c3d731 Merge pull request #2986 from weaveworks/remove-wordepress
Stop doing Wordpress previews on Pantheon
2017-05-23 12:01:05 +01:00
Bryan Boreham 534dd8e16a Stop doing Wordpress previews on Pantheon
Now we are using Netlify instead
2017-05-23 11:33:57 +01:00
Marc Carré 79e703c8ac Merge pull request #2987 from weaveworks/use-fixed-version-of-shfmt
Use shfmt v1.3.0 instead of latest from master
2017-05-23 11:31:03 +01:00
Marc CARRE d4a98a58f4 Use shfmt v1.3.0 instead of latest from master.
Before this change, `go get`-ting` would pick the latest version of `shfmt` which keeps changing, hence frequently breaking our builds.

After this change, we download the `shfmt` binary from its GitHub releases page which is fast and locks the version we use. Note that `RUN` does not like herestrings, hence `echo "..." | sha256sum -c` for checksum.

Alternatives considered:
- `go get gopkg.in/mvdan/sh.v1/cmd/shfmt` -- but `gopkg.in` currently doesn't behave well for this tool
- `go build` from a `git` tag -- but this is much more involved.
2017-05-23 10:59:11 +01:00
Bryan Boreham 72532324ed Give up on versioned copy of shfmt; it doesn't build 2017-05-18 10:18:11 +00:00
Marc Carré 68106d804e Merge pull request #2959 from ocadotechnology/wip-2958
fix(npc): create ipsets with only valid xml characters
2017-05-15 13:30:10 +01:00
Bryan Boreham efff6d6e63 Merge pull request #2962 from weaveworks/fix-shfmt-lint-error
Fix shfmt lint error by escaping $ in sed expression
2017-05-15 13:21:12 +01:00
Marc CARRE 6bbd8d7a4c Escape $ in sed expression.
This fixes new error raised by latest version of shfmt, leading to build failures.
2017-05-15 12:36:55 +01:00
stuart.warren 9cbf0289d8 fix(npc): create ipsets with only valid xml characters
Why:
* xml output of ipset is invalid because ipset itself doesn't appear to
 escape invalid chars

* fixes #2958
2017-05-15 11:20:04 +01:00
Bryan Boreham 255d087416 Merge pull request #2949 from ocadotechnology/wip-2915
Flush weave ipsets before destroying
2017-05-12 13:15:09 +01:00
Mike Bryant 8668f6bb1e Flush weave ipsets before destroying
ipsets can't be destroyed when there are references to them.
This takes the easy way out and flushes all weave ipsets first.

Fixes #2915
2017-05-12 09:44:26 +01:00
Mike Bryant 95ee99d652 style: singular vs plural 2017-05-12 09:44:18 +01:00
Bryan Boreham 30583ec8f2 Merge pull request #2930 from weaveworks/fix-broken-links
Fix some broken links in documentation
2017-05-11 16:24:00 +01:00
Bryan Boreham e370ef7007 Fix 'How Weave Finds Containers' link 2017-05-11 15:06:29 +00:00
Ilya Dmitrichenko 42953faf70 Fix some broken links in documentation 2017-05-11 15:06:20 +00:00
Bryan Boreham 6c29a1f648 Merge pull request #2940 from weaveworks/fix_libssl_mismatch
Fix build libssl issue: Use cross-compilers from debian rather than ubuntu
2017-05-09 13:37:10 +01:00
Marcus Cobden fa29b18be7 Use cross-compilers from debian rather than ubuntu 2017-05-09 09:32:54 +00:00
Bryan Boreham 40db885b3a Merge pull request #2935 from ocadotechnology/wip-2934
Clean up xt_set_exists components in advance
2017-05-09 10:04:56 +01:00
Bryan Boreham ae0c16f375 Merge pull request #2884 from weaveworks/issues/2794-kube-evict-docs
Add pod resources and eviction to weave-kube doc
2017-05-09 10:02:54 +01:00
Bryan Boreham 909b751d6d Explain how to see Evicted pods 2017-05-08 13:14:59 +00:00
Mike Bryant 9419ad16bf Clean up xt_set_exists components in advance
If this function dies in the middle, the leftover weave-kube-test set
causes this function and weave-npc to break. In particular
this means we can never restart weave with the launch script.

Here we clean up in advance, in case there's leftovers from a previous run

Fixes #2934
2017-05-08 12:15:23 +01:00
Bryan Boreham 2c12c4f67e Merge pull request #2928 from weaveworks/issues/2921-ignore-enoent-on-iface-del
Ignore errors on network interface delete during CNI Delete
2017-05-05 20:45:38 +01:00
Marc CARRE be11db45d8 Ignore error when deleting a container's interface.
Fixes #2921, as all errors are now ignored, including `ENOENT`.
This command typically attempts to delete the network interface `eth0` of a container being destroyed by Kubernetes.
If this interface has already been destroyed or is missing for whatever reason, we still want to remove this container's entry from IPAM in order to free associated resources.
2017-05-05 17:24:08 +00:00
Marc CARRE 30213bd71e Comply to CNI 0.5 spec by always returning nil on DEL.
See also:
  "Plugins should generally complete a DEL action without error even if some resources are missing."
in:
  https://github.com/containernetworking/cni/blob/v0.5.0/SPEC.md
2017-05-05 17:24:08 +00:00
Bryan Boreham b14501f358 Merge pull request #2931 from weaveworks/patch-wordepress
Use a version of wordepress that handles 'search-type' attribute
2017-05-05 18:21:42 +01:00
Bryan Boreham e93a145bab Build a version of wordepress that handles 'search-type' attribute 2017-05-05 16:58:33 +00:00
Ilya Dmitrichenko 8b245a442c Add website preview 2017-05-05 15:23:08 +01:00
Bryan Boreham 041b6fe251 Add release v1.9.5 2017-05-04 08:49:15 +00:00
Marc Carré d128488339 Merge pull request #2926 from weaveworks/issues/2808-improve-hairpin-messages
Fixes #2808. Improve hairpin log messages.
2017-05-03 20:21:20 +01:00
Marc Carré c8c61adca4 Merge pull request #2907 from weaveworks/issues/2771-checkpoint-net-modes
Add checkpoint flag per connection type
2017-05-03 18:20:30 +01:00
Bryan Boreham 7c8f33f525 Add checkpoint flag per connection type 2017-05-03 16:56:49 +00:00
Bryan Boreham 15bf6eab1e Merge pull request #2925 from weaveworks/doc-search-tag
added search tag type
2017-05-03 17:35:00 +01:00
abuehrle 10333b0f3e added search tag type 2017-05-03 16:33:40 +00:00
Ilya Dmitrichenko 52a5ca8f88 Fix broken link in docs 2017-05-03 16:43:57 +01:00
Bryan Boreham b19f2df6f8 Improve hairpin log messages 2017-05-03 14:35:20 +00:00
Bryan Boreham b3ac56e3d2 Update mesh library and check for errors newly returned 2017-05-03 11:08:28 +00:00
Marc Carré cc77ad2c65 Merge pull request #2912 from weaveworks/issues/2904-filter-ipv6-kube-peers
Filter out IPv6 addresses from kube-peers
2017-05-02 11:45:31 +01:00
Bryan Boreham 24c2743a58 Check addresses are IPv4 in kube-peers 2017-04-28 11:05:38 +00:00
Bryan Boreham b49f5bdb99 Merge pull request #2916 from ocadotechnology/allow-for-externalip
fix(kube-peers): Add support for ExternalIP addresses
2017-04-27 15:29:02 +01:00
Marc CARRE 28a1578d20 Please ./tools/lint -nocomment -notestpackage.
Fixes:
- `test/run-integration-tests.sh:160:75: arithmetic expressions must consist of names and numbers`
- `test/run-integration-tests.sh:265:56: arithmetic expressions must consist of names and numbers`
- `test/run-integration-tests.sh:295:61: arithmetic expressions must consist of names and numbers`
- `test/run-integration-tests.sh:309:49: arithmetic expressions must consist of names and numbers`
- `test/run-integration-tests.sh:316:41: arithmetic expressions must consist of names and numbers`
- `test/run-integration-tests.sh: run shfmt -i 4 -w test/run-integration-tests.sh`

See also: https://circleci.com/gh/weaveworks/weave/8685
2017-04-27 14:06:42 +00:00
Mike Bryant e78be1fc35 fix(kube-peers): Add support for ExternalIP addresses
Why:
* In some environments Nodes have an ExternalIP but no InternalIP

This change addresses the need by:
* Falling back to ExternalIP addresses if there isn't an InternalIP for a node
2017-04-27 13:56:23 +01:00
Bryan Boreham 109e249aa6 Review feedback 2017-04-25 14:08:25 +00:00
Marc Carré 402fe094f4 Merge pull request #2893 from weaveworks/ipam-ops-reentrant. Fixes #2892.
IPAM: Make sure we have a ring before calling tryOps()
2017-04-12 13:25:32 +01:00
Bryan Boreham 1c1b3248c0 Make sure we have a ring before calling tryOps()
because otherwise the pending ops can be modified from inside Try()
2017-04-11 15:36:53 +00:00
Bryan Boreham 60c5e11871 Add pod resources and eviction to weave-kube doc 2017-04-11 12:29:27 +00:00
Ilya Dmitrichenko 5cae747b36 Consisten spacing in Markdown headings
Jekyll doesn't tolerate this, and it's generally cosidered a cleaner
style, we've had a bit of mixed style and this makes it consistent.
2017-04-10 12:44:38 +00:00
Bryan Boreham ef0dae4ed3 Simple example is only on two hosts 2017-04-10 11:37:06 +00:00
Bryan Boreham 2686be1b93 Update mention of Docker 1.6 to 1.10 2017-04-10 10:45:42 +00:00
Marc Carré b845360091 Merge pull request #2887 from weaveworks/issues/add-gcloud-to-circle-path
Fix gcloud dependency for CI builds
2017-04-07 15:01:20 +01:00
Martynas Pumputis 953d451105 Check for gcloud in verify_dependencies
In CI builds, we rely on gcloud installed by Circle CI. Any change to
Circle $PATH or the installation might break CI builds in non-obvious
way.
2017-04-07 14:44:31 +01:00
Martynas Pumputis 75d80c4828 Add /opt/google-cloud-sk/bin to PATH of circle.yml
Otherwise, "gcloud" cannot be found.
2017-04-07 14:43:35 +01:00
Bryan Boreham 877658d22e Merge pull request #2886 from weaveworks/lock-kubeadm-version
Lock kubeadm's Kubernetes version
2017-04-06 14:37:58 +01:00
Marc CARRE 1c797ca901 Upgrade to latest version of build-tools.
This brings a fix to the Ansible playbook which enables locking of `kubeadm`'s Kubernetes version.
2017-04-06 13:49:51 +01:00
Marc CARRE 520a72c8e6 Lock kubeadm's Kubernetes version.
Without this commit, `kubeadm` typically upgrades whichever version of Kubernetes is installed, sometimes leading to conflicts in between components' version.

This fixes the issue behind #2876 and should avoid build failures like [weave/8373](https://circleci.com/gh/weaveworks/weave/8373).
2017-04-06 13:49:48 +01:00
Marc CARRE 98fec7e5aa Revert "Disable temporary 840 smoke tests"
This reverts commit b687484dda.
2017-04-06 10:43:56 +01:00
Bryan Boreham 038aac41fd Fix weave-kube doc table of contents 2017-04-05 13:56:17 +00:00
Martynas Pumputis c54fe016b1 Merge pull request #2880 from weaveworks/upgrade-build-tools
Upgrade to latest build-tools.
2017-04-04 15:44:05 +01:00
Marc CARRE 9c9b46479d Upgrade to latest build-tools.
Adds better support for CentOS, for Kubernetes 1.6 (default: 1.6.1), and makes Docker installation role configurable, among others.
2017-04-04 15:13:41 +01:00
Bryan Boreham 28c290074b Merge pull request #2876 from weaveworks/issues/disable-840
Disable temporary the 840 weave kube smoke test
2017-03-31 18:55:59 +02:00
Martynas Pumputis b687484dda Disable temporary 840 smoke tests
To trigger doc publishing
2017-03-30 17:45:20 +01:00
Bryan Boreham fd731beb87 Merge pull request #2871 from weaveworks/weave-kube-formatting
Fix formatting of code snippets in site/kube-addon.md.
2017-03-29 11:53:07 +01:00
Marc CARRE 35cc653737 Add links to URLs and relevant resources. 2017-03-29 11:28:49 +01:00
Marc CARRE 1254d680ed Fix formatting of env. vars. in site/kube-addon.md. 2017-03-29 11:28:42 +01:00
Marc CARRE 23c0b6a04b Fix formatting of kubectl apply snippets in site/kube-addon.md. 2017-03-29 11:28:36 +01:00
Martynas Pumputis ede1ec970c Merge pull request #2861 from weaveworks/weave-kube-1.6-docs
Update weave-kube docs for k8s  1.6
2017-03-29 10:36:49 +01:00
Bryan Boreham fbab5a7280 Review feedback 2017-03-29 08:37:28 +00:00
Bryan Boreham a92cfc1ffe Added instructions for Kubernetes 1.6 changes 2017-03-21 15:28:41 +00:00
93 changed files with 506 additions and 230 deletions

No files matched your search

+3
View File
@@ -70,3 +70,6 @@ test/coverage.*
*qemu-*-static *qemu-*-static
terraform.tfstate terraform.tfstate
terraform.tfstate.backup terraform.tfstate.backup
# Website
site-build
+1
View File
@@ -0,0 +1 @@
2.3.0
+50
View File
@@ -1,3 +1,53 @@
## Release 1.9.6
Bug fixes and minor improvements
* Ensure that Kubernetes pods can contact a service implemented within
the same pod, by turning on "hairpin mode". This is required because
of a quiet change between Kubernetes 1.5 and 1.6. #2993
* Network Policy Controller (`weave-npc`) now checks local addresses
only, so it doesn't interfere with cross-cluster traffic. It should
be more efficient too #2622,#2973,#2979
* Stop reporting back to Kubernetes any issues encountered when
deleting a pod's network interface. This is required because
of a quiet change between Kubernetes 1.5 and 1.6. #2921,#2928
* Fixed an issue whereby `weave-npc` couldn't start because one
`ipset` was referring to another one and could not be destroyed #2915,#2949
* Improved the code which checks whether the kernel supports `ipset` #2934,#2935
* `weave-npc` now creates ipsets with only valid xml characters in the
name #2958,#2959
Build and Testing
* In build container use cross-compilers from debian package
repository, so they match other components #2940
* Pin the version of the linting tool `shfmt` so the set of things it
checks is stable #2987
* Fix lint error in script that runs smoke-tests #2962
* Moved website publishing from Wordpress to Netlify #2986
[Full list of changes](https://github.com/weaveworks/weave/milestone/55?closed=1).
## Release 1.9.5
Bug fixes and minor improvements
* Improve log messages generated if "hairpin" conditions are detected,
to make clear which kind is likely to cause problems #2808/#2926
* Filter out IPv6 peer addresses from Kubernetes; Weave Net currently
only supports IPv4 #2904/#2912
* Fix rare crash during initialization of weave-kube #2893/#2892
* Include overlay and encryption modes in checkpoint reports, in case
this is relevant to a version upgrade #2771/#2907
Build and Testing
* Ensure CI build can run gcloud tools #2887
* Prevent kubeadm from upgrading Kubernetes if we are trying to test an older version #2886
* Upgrade build scripts to support Kubernetes 1.6 #2880
[Full list of changes](https://github.com/weaveworks/weave/milestone/54?closed=1).
## Release 1.9.4 ## Release 1.9.4
Bug fixes and minor improvements Bug fixes and minor improvements
+11
View File
@@ -378,3 +378,14 @@ integration-tests: all testrunner
# integration-tests # integration-tests
# #
RUNNER_ARGS="-parallel" ./test/run-integration-tests.sh RUNNER_ARGS="-parallel" ./test/run-integration-tests.sh
# This target is only intended for use in Netlify CI environment for generating preview pages on feature branches and pull requests.
# We need to obtain website repository (checked out under `site-build`) and place `site` directory into the context (`site-build/_weave_net_docs`).
# We then run make in `site-build` and Netlify will publish the output (`site-build/_site`).
netlify-site-preview:
@mkdir -p site-build
@curl --user $(WEBSITE_GITHUB_USER) --silent 'https://codeload.github.com/weaveworks/website-next/tar.gz/$(WEBSITE_BRANCH)' \
| tar --extract --gunzip --directory site-build --strip 1
@cp -r site site-build/_weave_net_docs
@$(MAKE) -C site-build netlify_ensure_install
@$(MAKE) -C site-build BUILD_ENV=netlify
-43
View File
@@ -1,43 +0,0 @@
#!/bin/bash
set -e
set -o pipefail
source "$STATE"
site_changes() {
curl -s https://api.github.com/repos/weaveworks/weave/pulls/$1/files |
jq -r '.[]|.status + " " + .filename' |
grep -oP '^(added|modified|removed) site/.*(?=\.md$)'
}
format_comment() {
if [ ! -d .git ] || ! BRANCH=$(git symbolic-ref --short HEAD) || [ -z "$BRANCH" ] ; then
echo "Could not determine branch" >&2
return 1
fi
echo "#### Documentation changes:"
while read ACTION PAGE; do
echo "$ACTION [${PAGE#site/}]($WP_DEV_URL/docs/net/${BRANCH#issues/}/${PAGE#site/}/)"
done | sort
}
post_comment() {
jq -s -R '. | tostring | { body: . }' |
curl -s -d @- \
-H "Authorization: Bearer $WP_GH_COMMENT_TOKEN" \
-H 'Content-Type: application/json' \
https://api.github.com/repos/weaveworks/weave/issues/$GH_PR/comments > /dev/null
}
cd $SRCDIR
bin/install-wordepress v1.0.0
bin/publish-site "$WP_DEV_URL" "$WP_DEV_USER" "$WP_DEV_PASSWORD"
if [ -n "$WP_GH_COMMENT_TOKEN" -a -n "$GH_PR" ] ; then
echo ">>> Adding doc changelog to GitHub PR $GH_PR"
if CHANGES=$(site_changes $GH_PR) && [ -n "$CHANGES" ] ; then
echo "$CHANGES" | format_comment | post_comment
fi
fi
-4
View File
@@ -11,7 +11,3 @@ if [ -n "$TEST_AND_PUBLISH" ] ; then
# CircleCI doesn't let us install the qemu module to do ARM docker builds # CircleCI doesn't let us install the qemu module to do ARM docker builds
make publish ALL_ARCHITECTURES=amd64 UPDATE_LATEST=latest-only make publish ALL_ARCHITECTURES=amd64 UPDATE_LATEST=latest-only
fi fi
cd $SRCDIR
bin/install-wordepress v1.0.0
bin/publish-site "$WP_DEV_URL" "$WP_DEV_USER" "$WP_DEV_PASSWORD"
-7
View File
@@ -1,7 +0,0 @@
#!/bin/bash
set -e
cd $SRCDIR
bin/install-wordepress v1.0.0
bin/publish-site "$WP_LIVE_URL" "$WP_LIVE_USER" "$WP_LIVE_PASSWORD"
-12
View File
@@ -1,12 +0,0 @@
#!/bin/bash
if [ $# -ne 1 ] ; then
echo USAGE: install-wordepress [COMMIT-ISH] >&2
exit 1
fi
go get github.com/weaveworks/wordepress
cd /home/ubuntu/src/github.com/weaveworks/wordepress
git checkout $1
cd cmd/wordepress
go get
-46
View File
@@ -1,46 +0,0 @@
#!/bin/bash
set -e
set -o pipefail
PRODUCT=net
fatal() {
echo "$@" >&2
exit 1
}
if [ ! -d .git ] ; then
fatal "Current directory is not a git clone"
fi
if ! BRANCH=$(git symbolic-ref --short HEAD) || [ -z "$BRANCH" ] ; then
fatal "Could not determine branch"
fi
case "$BRANCH" in
issues/*)
VERSION="${BRANCH#issues/}"
TAGS="$VERSION"
;;
*)
if echo "$BRANCH" | grep -qE '^[0-9]+\.[0-9]+' ; then
DESCRIBE=$(git describe --match 'v*')
if ! VERSION=$(echo "$DESCRIBE" | grep -oP '(?<=^v)[0-9]+\.[0-9]+\.[0-9]+') ; then
fatal "Could not infer latest $BRANCH version from $DESCRIBE"
fi
TAGS="latest"
else
VERSION="$BRANCH"
TAGS="$VERSION"
fi
;;
esac
for TAG in $TAGS ; do
echo ">>> Publishing $PRODUCT $VERSION to $1/docs/$PRODUCT/$TAG"
wordepress \
--url "$1" --user "$2" --password "$3" \
--product "$PRODUCT" --version "$VERSION" --tag "$TAG" \
publish site
done
+8 -5
View File
@@ -20,13 +20,12 @@ ENV GCC_CROSSCOMPILERS \
# Temporarily add the Ubuntu repositories, because we're going to install gcc cross-compilers from there # Temporarily add the Ubuntu repositories, because we're going to install gcc cross-compilers from there
# Install the build-essential and crossbuild-essential-ARCH packages # Install the build-essential and crossbuild-essential-ARCH packages
RUN echo "deb http://archive.ubuntu.com/ubuntu xenial main universe" > /etc/apt/sources.list.d/cgocrosscompiling.list \ RUN echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/cgocrosscompiling.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 3B4FE6ACC0B21F32 \ && curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add - \
&& for platform in ${DEB_CROSSPLATFORMS}; do dpkg --add-architecture $platform; done \
&& apt-get update \ && apt-get update \
&& apt-get install -y build-essential \ && apt-get install -y build-essential \
&& for platform in ${DEB_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \ && for platform in ${DEB_CROSSPLATFORMS}; do apt-get install -y crossbuild-essential-${platform}; done \
&& rm /etc/apt/sources.list.d/cgocrosscompiling.list \
&& apt-get update \
&& apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get clean && rm -rf /var/lib/apt/lists/*
# Install some required packages # Install some required packages
@@ -41,11 +40,15 @@ RUN apt-get update \
flex \ flex \
bison bison
RUN curl -fsSLo shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64 && \
echo "b1925c2c405458811f0c227266402cf1868b4de529f114722c2e3a5af4ac7bb2 shfmt" | sha256sum -c && \
chmod +x shfmt && \
mv shfmt /usr/bin
# Install common Go tools # Install common Go tools
RUN go get \ RUN go get \
github.com/golang/lint/golint \ github.com/golang/lint/golint \
github.com/fzipp/gocyclo \ github.com/fzipp/gocyclo \
gopkg.in/mvdan/sh.v1/cmd/shfmt \
github.com/fatih/hclfmt \ github.com/fatih/hclfmt \
github.com/client9/misspell/cmd/misspell github.com/client9/misspell/cmd/misspell
+1 -11
View File
@@ -11,7 +11,7 @@ machine:
environment: environment:
GOPATH: /home/ubuntu:$GOPATH GOPATH: /home/ubuntu:$GOPATH
SRCDIR: /home/ubuntu/src/github.com/weaveworks/weave SRCDIR: /home/ubuntu/src/github.com/weaveworks/weave
PATH: $PATH:$HOME/.local/bin PATH: $PATH:$HOME/.local/bin:/opt/google-cloud-sdk/bin
CLOUDSDK_CORE_DISABLE_PROMPTS: 1 CLOUDSDK_CORE_DISABLE_PROMPTS: 1
STATE: /home/ubuntu/state.env STATE: /home/ubuntu/state.env
# Base name of VMs for integration tests: # Base name of VMs for integration tests:
@@ -59,18 +59,8 @@ teardown:
parallel: true parallel: true
deployment: deployment:
release:
branch: /[0-9]+\.[0-9]+/
owner: weaveworks
commands:
- "$SRCDIR/bin/circle-deploy-release"
master: master:
branch: master branch: master
owner: weaveworks owner: weaveworks
commands: commands:
- "$SRCDIR/bin/circle-deploy-master" - "$SRCDIR/bin/circle-deploy-master"
issues:
branch: /.*/
owner: weaveworks
commands:
- "$SRCDIR/bin/circle-deploy-issues"
+2
View File
@@ -77,8 +77,10 @@ iptables -A WEAVE-NPC -m state --state NEW -j WEAVE-NPC-INGRESS
To direct traffic into the policy engine: To direct traffic into the policy engine:
```
iptables -A FORWARD -o weave -m physdev ! --physdev-out vethwe-bridge -j WEAVE-NPC iptables -A FORWARD -o weave -m physdev ! --physdev-out vethwe-bridge -j WEAVE-NPC
iptables -A FORWARD -o weave -m physdev ! --physdev-out vethwe-bridge -j DROP iptables -A FORWARD -o weave -m physdev ! --physdev-out vethwe-bridge -j DROP
```
Note this only affects traffic which egresses the bridge on a physical Note this only affects traffic which egresses the bridge on a physical
port which is not the Weave Net router - in other words, it is port which is not the Weave Net router - in other words, it is
+8
View File
@@ -265,6 +265,10 @@ func (alloc *Allocator) tryPendingOps() {
alloc.tryOps(&alloc.pendingAllocates) alloc.tryOps(&alloc.pendingAllocates)
} }
func (alloc *Allocator) havePendingOps() bool {
return len(alloc.pendingPrimes)+len(alloc.pendingClaims)+len(alloc.pendingAllocates) > 0
}
func (alloc *Allocator) spaceRequestDenied(sender mesh.PeerName, r address.Range) { func (alloc *Allocator) spaceRequestDenied(sender mesh.PeerName, r address.Range) {
for i := 0; i < len(alloc.pendingClaims); { for i := 0; i < len(alloc.pendingClaims); {
claim := alloc.pendingClaims[i].(*claim) claim := alloc.pendingClaims[i].(*claim)
@@ -696,9 +700,13 @@ func (alloc *Allocator) actorLoop(actionChan <-chan func(), stopChan <-chan stru
// Retry things in case messages got lost between here and recipients // Retry things in case messages got lost between here and recipients
if alloc.awaitingConsensus { if alloc.awaitingConsensus {
alloc.propose() alloc.propose()
} else if alloc.havePendingOps() {
if alloc.ring.Empty() {
alloc.establishRing()
} else { } else {
alloc.tryPendingOps() alloc.tryPendingOps()
} }
}
alloc.removeDeadContainers() alloc.removeDeadContainers()
} }
+6 -2
View File
@@ -113,7 +113,7 @@ func interfaceExistsInNamespace(netNSPath string, ifName string) bool {
// NB: This function can be used only by a process that terminates immediately // NB: This function can be used only by a process that terminates immediately
// after calling the function as it changes netns via WithNetNSLinkUnsafe. // after calling the function as it changes netns via WithNetNSLinkUnsafe.
func AttachContainer(netNSPath, id, ifName, bridgeName string, mtu int, withMulticastRoute bool, cidrs []*net.IPNet, keepTXOn bool) error { func AttachContainer(netNSPath, id, ifName, bridgeName string, mtu int, withMulticastRoute bool, cidrs []*net.IPNet, keepTXOn bool, hairpinMode bool) error {
ns, err := netns.GetFromPath(netNSPath) ns, err := netns.GetFromPath(netNSPath)
if err != nil { if err != nil {
return err return err
@@ -131,7 +131,7 @@ func AttachContainer(netNSPath, id, ifName, bridgeName string, mtu int, withMult
id = id[:maxIDLen] // trim passed ID if too long id = id[:maxIDLen] // trim passed ID if too long
} }
name, peerName := vethPrefix+"pl"+id, vethPrefix+"pg"+id name, peerName := vethPrefix+"pl"+id, vethPrefix+"pg"+id
_, err := CreateAndAttachVeth(name, peerName, bridgeName, mtu, keepTXOn, func(veth netlink.Link) error { veth, err := CreateAndAttachVeth(name, peerName, bridgeName, mtu, keepTXOn, func(veth netlink.Link) error {
if err := netlink.LinkSetNsFd(veth, int(ns)); err != nil { if err := netlink.LinkSetNsFd(veth, int(ns)); err != nil {
return fmt.Errorf("failed to move veth to container netns: %s", err) return fmt.Errorf("failed to move veth to container netns: %s", err)
} }
@@ -143,6 +143,10 @@ func AttachContainer(netNSPath, id, ifName, bridgeName string, mtu int, withMult
if err != nil { if err != nil {
return err return err
} }
if err = netlink.LinkSetHairpin(veth, hairpinMode); err != nil {
return fmt.Errorf("unable to set hairpin mode to %t for bridge side of veth %s: %s", hairpinMode, name, err)
}
} }
if err := WithNetNSLinkUnsafe(ns, ifName, func(veth netlink.Link) error { if err := WithNetNSLinkUnsafe(ns, ifName, func(veth netlink.Link) error {
+2
View File
@@ -8,4 +8,6 @@ const (
IngressChain = "WEAVE-NPC-INGRESS" IngressChain = "WEAVE-NPC-INGRESS"
IpsetNamePrefix = "weave-" IpsetNamePrefix = "weave-"
LocalIpset = IpsetNamePrefix + "local-pods"
) )
+22 -1
View File
@@ -29,6 +29,8 @@ type NetworkPolicyController interface {
type controller struct { type controller struct {
sync.Mutex sync.Mutex
nodeName string // my node name
ipt *iptables.IPTables ipt *iptables.IPTables
ips ipset.Interface ips ipset.Interface
@@ -36,8 +38,9 @@ type controller struct {
nsSelectors *selectorSet // selector string -> nsSelector nsSelectors *selectorSet // selector string -> nsSelector
} }
func New(ipt *iptables.IPTables, ips ipset.Interface) NetworkPolicyController { func New(nodeName string, ipt *iptables.IPTables, ips ipset.Interface) NetworkPolicyController {
c := &controller{ c := &controller{
nodeName: nodeName,
ipt: ipt, ipt: ipt,
ips: ips, ips: ips,
nss: make(map[string]*ns)} nss: make(map[string]*ns)}
@@ -82,10 +85,21 @@ func (npc *controller) withNS(name string, f func(ns *ns) error) error {
return nil return nil
} }
func (npc *controller) checkLocalPod(obj *coreapi.Pod, event string) bool {
if obj.Spec.NodeName != npc.nodeName {
common.Log.Debugf("%s ignored for pod %s/%s on node %s", event, obj.ObjectMeta.Namespace, obj.ObjectMeta.Name, obj.Spec.NodeName)
return false
}
return true
}
func (npc *controller) AddPod(obj *coreapi.Pod) error { func (npc *controller) AddPod(obj *coreapi.Pod) error {
npc.Lock() npc.Lock()
defer npc.Unlock() defer npc.Unlock()
if !npc.checkLocalPod(obj, "AddPod") {
return nil
}
common.Log.Debugf("EVENT AddPod %s", js(obj)) common.Log.Debugf("EVENT AddPod %s", js(obj))
return npc.withNS(obj.ObjectMeta.Namespace, func(ns *ns) error { return npc.withNS(obj.ObjectMeta.Namespace, func(ns *ns) error {
return errors.Wrap(ns.addPod(obj), "add pod") return errors.Wrap(ns.addPod(obj), "add pod")
@@ -96,6 +110,10 @@ func (npc *controller) UpdatePod(oldObj, newObj *coreapi.Pod) error {
npc.Lock() npc.Lock()
defer npc.Unlock() defer npc.Unlock()
// Pods don't move across nodes so we only check the new version
if !npc.checkLocalPod(newObj, "UpdatePod") {
return nil
}
common.Log.Debugf("EVENT UpdatePod %s %s", js(oldObj), js(newObj)) common.Log.Debugf("EVENT UpdatePod %s %s", js(oldObj), js(newObj))
return npc.withNS(oldObj.ObjectMeta.Namespace, func(ns *ns) error { return npc.withNS(oldObj.ObjectMeta.Namespace, func(ns *ns) error {
return errors.Wrap(ns.updatePod(oldObj, newObj), "update pod") return errors.Wrap(ns.updatePod(oldObj, newObj), "update pod")
@@ -106,6 +124,9 @@ func (npc *controller) DeletePod(obj *coreapi.Pod) error {
npc.Lock() npc.Lock()
defer npc.Unlock() defer npc.Unlock()
if !npc.checkLocalPod(obj, "DeletePod") {
return nil
}
common.Log.Debugf("EVENT DeletePod %s", js(obj)) common.Log.Debugf("EVENT DeletePod %s", js(obj))
return npc.withNS(obj.ObjectMeta.Namespace, func(ns *ns) error { return npc.withNS(obj.ObjectMeta.Namespace, func(ns *ns) error {
return errors.Wrap(ns.deletePod(obj), "delete pod") return errors.Wrap(ns.deletePod(obj), "delete pod")
+6 -2
View File
@@ -1,6 +1,7 @@
package ipset package ipset
import ( import (
"log"
"os/exec" "os/exec"
"strings" "strings"
@@ -31,10 +32,11 @@ type Interface interface {
type ipset struct { type ipset struct {
refCount refCount
*log.Logger
} }
func New() Interface { func New(logger *log.Logger) Interface {
return &ipset{refCount: newRefCount()} return &ipset{refCount: newRefCount(), Logger: logger}
} }
func (i *ipset) Create(ipsetName Name, ipsetType Type) error { func (i *ipset) Create(ipsetName Name, ipsetType Type) error {
@@ -42,6 +44,7 @@ func (i *ipset) Create(ipsetName Name, ipsetType Type) error {
} }
func (i *ipset) AddEntry(ipsetName Name, entry string) error { func (i *ipset) AddEntry(ipsetName Name, entry string) error {
i.Logger.Printf("adding entry %s to %s", entry, ipsetName)
if i.inc(ipsetName, entry) > 1 { // already in the set if i.inc(ipsetName, entry) > 1 { // already in the set
return nil return nil
} }
@@ -49,6 +52,7 @@ func (i *ipset) AddEntry(ipsetName Name, entry string) error {
} }
func (i *ipset) DelEntry(ipsetName Name, entry string) error { func (i *ipset) DelEntry(ipsetName Name, entry string) error {
i.Logger.Printf("deleting entry %s from %s", entry, ipsetName)
if i.dec(ipsetName, entry) > 0 { // still needed if i.dec(ipsetName, entry) > 0 { // still needed
return nil return nil
} }
+4
View File
@@ -88,6 +88,7 @@ func (ns *ns) addPod(obj *coreapi.Pod) error {
return nil return nil
} }
ns.ips.AddEntry(LocalIpset, obj.Status.PodIP)
return ns.podSelectors.addToMatching(obj.ObjectMeta.Labels, obj.Status.PodIP) return ns.podSelectors.addToMatching(obj.ObjectMeta.Labels, obj.Status.PodIP)
} }
@@ -100,10 +101,12 @@ func (ns *ns) updatePod(oldObj, newObj *coreapi.Pod) error {
} }
if hasIP(oldObj) && !hasIP(newObj) { if hasIP(oldObj) && !hasIP(newObj) {
ns.ips.DelEntry(LocalIpset, oldObj.Status.PodIP)
return ns.podSelectors.delFromMatching(oldObj.ObjectMeta.Labels, oldObj.Status.PodIP) return ns.podSelectors.delFromMatching(oldObj.ObjectMeta.Labels, oldObj.Status.PodIP)
} }
if !hasIP(oldObj) && hasIP(newObj) { if !hasIP(oldObj) && hasIP(newObj) {
ns.ips.AddEntry(LocalIpset, newObj.Status.PodIP)
return ns.podSelectors.addToMatching(newObj.ObjectMeta.Labels, newObj.Status.PodIP) return ns.podSelectors.addToMatching(newObj.ObjectMeta.Labels, newObj.Status.PodIP)
} }
@@ -139,6 +142,7 @@ func (ns *ns) deletePod(obj *coreapi.Pod) error {
return nil return nil
} }
ns.ips.DelEntry(LocalIpset, obj.Status.PodIP)
return ns.podSelectors.delFromMatching(obj.ObjectMeta.Labels, obj.Status.PodIP) return ns.podSelectors.delFromMatching(obj.ObjectMeta.Labels, obj.Status.PodIP)
} }
-2
View File
@@ -43,12 +43,10 @@ func (s *selector) matches(labelMap map[string]string) bool {
} }
func (s *selector) addEntry(entry string) error { func (s *selector) addEntry(entry string) error {
common.Log.Infof("adding entry %s to %s", entry, s.spec.ipsetName)
return s.ips.AddEntry(s.spec.ipsetName, entry) return s.ips.AddEntry(s.spec.ipsetName, entry)
} }
func (s *selector) delEntry(entry string) error { func (s *selector) delEntry(entry string) error {
common.Log.Infof("deleting entry %s from %s", entry, s.spec.ipsetName)
return s.ips.DelEntry(s.spec.ipsetName, entry) return s.ips.DelEntry(s.spec.ipsetName, entry)
} }
+3 -2
View File
@@ -7,12 +7,13 @@ import (
const ( const (
// This array: // This array:
// * Must include only printable UTF8 characters that are represented with a single byte // * Must include only printable UTF8 characters that are represented with a single byte (http://www.utf8-chartable.de/)
// * Must be at least of length 85 (`len("weave-") + l(2^160)/l(85)` equals 31, the maximum ipset name length) // * Must be at least of length 85 (`len("weave-") + l(2^160)/l(85)` equals 31, the maximum ipset name length)
// * Must not include commas as those are treated specially by `ipset add` when adding a named set to a list:set // * Must not include commas as those are treated specially by `ipset add` when adding a named set to a list:set
// * Should not include space for readability // * Should not include space for readability
// * Should not include invalid chars for XML `<>&"'`
// * Should not include single quote or backslash to be nice to shell users // * Should not include single quote or backslash to be nice to shell users
ShortNameSymbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789(){}[]<>_$%^&*|/?.;:@#~" ShortNameSymbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789(){}[]+=_$%^!*|/?.;:@#~"
) )
// sha1 hash an arbitrary string and represent it using the full range of // sha1 hash an arbitrary string and represent it using the full range of
+17 -11
View File
@@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"net" "net"
"os" "os"
"strings"
"syscall" "syscall"
"github.com/containernetworking/cni/pkg/ipam" "github.com/containernetworking/cni/pkg/ipam"
@@ -36,6 +35,7 @@ func NewCNIPlugin(weave *weaveapi.Client) *CNIPlugin {
func loadNetConf(bytes []byte) (*NetConf, error) { func loadNetConf(bytes []byte) (*NetConf, error) {
n := &NetConf{ n := &NetConf{
BrName: weavenet.WeaveBridgeName, BrName: weavenet.WeaveBridgeName,
HairpinMode: true,
} }
if err := json.Unmarshal(bytes, n); err != nil { if err := json.Unmarshal(bytes, n); err != nil {
return nil, fmt.Errorf("failed to load netconf: %v", err) return nil, fmt.Errorf("failed to load netconf: %v", err)
@@ -129,7 +129,7 @@ func (c *CNIPlugin) CmdAdd(args *skel.CmdArgs) error {
id = fmt.Sprintf("%x", data) id = fmt.Sprintf("%x", data)
} }
if err := weavenet.AttachContainer(args.Netns, id, args.IfName, conf.BrName, conf.MTU, false, []*net.IPNet{&ip.Address}, false); err != nil { if err := weavenet.AttachContainer(args.Netns, id, args.IfName, conf.BrName, conf.MTU, false, []*net.IPNet{&ip.Address}, false, conf.HairpinMode); err != nil {
return err return err
} }
if err := weavenet.WithNetNSLinkUnsafe(ns, args.IfName, func(link netlink.Link) error { if err := weavenet.WithNetNSLinkUnsafe(ns, args.IfName, func(link netlink.Link) error {
@@ -183,16 +183,21 @@ func assignBridgeIP(bridgeName string, ipnet net.IPNet) error {
return nil return nil
} }
// As of CNI 0.5 spec:
// "Plugins should generally complete a DEL action without error even if some resources are missing"
// this method should therefore return nil in most, if not all, cases.
func (c *CNIPlugin) CmdDel(args *skel.CmdArgs) error { func (c *CNIPlugin) CmdDel(args *skel.CmdArgs) error {
conf, err := loadNetConf(args.StdinData) conf, err := loadNetConf(args.StdinData)
if err != nil { if err != nil {
return err logOnStderr(err)
return nil
} }
// As of CNI 0.3 spec, runtimes can send blank if they just want the address deallocated // As of CNI 0.3 spec, runtimes can send blank if they just want the address deallocated
if args.Netns != "" { if args.Netns != "" {
if _, err = weavenet.WithNetNS(args.Netns, "del-iface", args.IfName); err != nil { if _, err = weavenet.WithNetNS(args.Netns, "del-iface", args.IfName); err != nil {
return fmt.Errorf("error removing interface %q: %s", args.IfName, err) // We log the error and carry on instead of returning nil, as there may still be resources to free in IPAM.
logOnStderr(fmt.Errorf("error removing interface %q: %s", args.IfName, err))
} }
} }
@@ -202,20 +207,21 @@ func (c *CNIPlugin) CmdDel(args *skel.CmdArgs) error {
} else { } else {
err = ipam.ExecDel(conf.IPAM.Type, args.StdinData) err = ipam.ExecDel(conf.IPAM.Type, args.StdinData)
} }
// Hack - don't know how we should detect this situation properly logOnStderr(fmt.Errorf("unable to release IP address: %s", err))
if args.Netns == "" && strings.Contains(err.Error(), "no addresses") {
err = nil
}
if err != nil {
return fmt.Errorf("unable to release IP address: %s", err)
}
return nil return nil
} }
// Standard error is inherited from the caller (e.g. Kubelet, when running Weave Net's CNI plugin
// under Kubernetes) hence provided errors should eventually appear in the caller's log files.
func logOnStderr(err error) {
fmt.Fprintln(os.Stderr, "weave-cni:", err)
}
type NetConf struct { type NetConf struct {
types.NetConf types.NetConf
BrName string `json:"bridge"` BrName string `json:"bridge"`
IsGW bool `json:"isGateway"` IsGW bool `json:"isGateway"`
IPMasq bool `json:"ipMasq"` IPMasq bool `json:"ipMasq"`
MTU int `json:"mtu"` MTU int `json:"mtu"`
HairpinMode bool `json:"hairpinMode"`
} }
+18 -2
View File
@@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"log" "log"
"net"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
api "k8s.io/client-go/pkg/api/v1" api "k8s.io/client-go/pkg/api/v1"
@@ -35,10 +36,25 @@ func getKubePeers() ([]string, error) {
} }
addresses := make([]string, 0, len(nodeList.Items)) addresses := make([]string, 0, len(nodeList.Items))
for _, peer := range nodeList.Items { for _, peer := range nodeList.Items {
var internalIP, externalIP string
for _, addr := range peer.Status.Addresses { for _, addr := range peer.Status.Addresses {
if addr.Type == "InternalIP" { // Check it's a valid ipv4 address
addresses = append(addresses, addr.Address) ip := net.ParseIP(addr.Address)
if ip == nil || ip.To4() == nil {
continue
} }
if addr.Type == "InternalIP" {
internalIP = ip.To4().String()
} else if addr.Type == "ExternalIP" {
externalIP = ip.To4().String()
}
}
// Fallback for cases where a Node has an ExternalIP but no InternalIP
if internalIP != "" {
addresses = append(addresses, internalIP)
} else if externalIP != "" {
addresses = append(addresses, externalIP)
} }
} }
return addresses, nil return addresses, nil
+5
View File
@@ -8,6 +8,11 @@ modprobe_safe() {
# Check whether xt_set actually exists # Check whether xt_set actually exists
xt_set_exists() { xt_set_exists() {
# Clean everything up in advance, in case there's leftovers
iptables -F WEAVE-KUBE-TEST 2>/dev/null || true
iptables -X WEAVE-KUBE-TEST 2>/dev/null || true
ipset destroy weave-kube-test 2>/dev/null || true
ipset create weave-kube-test hash:ip ipset create weave-kube-test hash:ip
iptables -t filter -N WEAVE-KUBE-TEST iptables -t filter -N WEAVE-KUBE-TEST
if ! iptables -A WEAVE-KUBE-TEST -m set --match-set weave-kube-test src -j DROP; then if ! iptables -A WEAVE-KUBE-TEST -m set --match-set weave-kube-test src -j DROP; then
+53 -20
View File
@@ -28,6 +28,7 @@ var (
metricsAddr string metricsAddr string
logLevel string logLevel string
allowMcast bool allowMcast bool
nodeName string
) )
func handleError(err error) { common.CheckFatal(err) } func handleError(err error) { common.CheckFatal(err) }
@@ -53,6 +54,41 @@ func resetIPTables(ipt *iptables.IPTables) error {
return err return err
} }
return nil
}
func resetIPSets(ips ipset.Interface) error {
// Remove ipsets prefixed `weave-` only
sets, err := ips.List(npc.IpsetNamePrefix)
if err != nil {
common.Log.Errorf("Failed to retrieve list of ipsets")
return err
}
common.Log.Debugf("Got list of ipsets: %v", sets)
// Must remove references to ipsets by other ipsets before they're destroyed
for _, s := range sets {
common.Log.Debugf("Flushing ipset '%s'", string(s))
if err := ips.Flush(s); err != nil {
common.Log.Errorf("Failed to flush ipset '%s'", string(s))
return err
}
}
for _, s := range sets {
common.Log.Debugf("Destroying ipset '%s'", string(s))
if err := ips.Destroy(s); err != nil {
common.Log.Errorf("Failed to destroy ipset '%s'", string(s))
return err
}
}
return nil
}
func createBaseRules(ipt *iptables.IPTables, ips ipset.Interface) error {
// Configure main chain static rules // Configure main chain static rules
if err := ipt.Append(npc.TableFilter, npc.MainChain, if err := ipt.Append(npc.TableFilter, npc.MainChain,
"-m", "state", "--state", "RELATED,ESTABLISHED", "-j", "ACCEPT"); err != nil { "-m", "state", "--state", "RELATED,ESTABLISHED", "-j", "ACCEPT"); err != nil {
@@ -76,34 +112,29 @@ func resetIPTables(ipt *iptables.IPTables) error {
return err return err
} }
return nil // If the destination address is not any of the local pods, let it through
} if err := ips.Create(npc.LocalIpset, ipset.HashIP); err != nil {
func resetIPSets(ips ipset.Interface) error {
// Remove ipsets prefixed `weave-` only
sets, err := ips.List(npc.IpsetNamePrefix)
if err != nil {
common.Log.Errorf("Failed to retrieve list of ipsets")
return err return err
} }
if err := ipt.Append(npc.TableFilter, npc.MainChain,
common.Log.Debugf("Got list of ipsets: %v", sets) "-m", "set", "--match-set", npc.LocalIpset, "src",
"-m", "set", "!", "--match-set", npc.LocalIpset, "dst", "-j", "ACCEPT"); err != nil {
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 err
} }
}
return nil return nil
} }
func root(cmd *cobra.Command, args []string) { func root(cmd *cobra.Command, args []string) {
common.SetLogLevel(logLevel) common.SetLogLevel(logLevel)
common.Log.Infof("Starting Weaveworks NPC %s", version) if nodeName == "" {
// HOSTNAME is set by Kubernetes for pods in the host network namespace
nodeName = os.Getenv("HOSTNAME")
}
if nodeName == "" {
common.Log.Fatalf("Must set node name via --node-name or $HOSTNAME")
}
common.Log.Infof("Starting Weaveworks NPC %s; node name %q", version, nodeName)
if err := metrics.Start(metricsAddr); err != nil { if err := metrics.Start(metricsAddr); err != nil {
common.Log.Fatalf("Failed to start metrics: %v", err) common.Log.Fatalf("Failed to start metrics: %v", err)
@@ -122,12 +153,13 @@ func root(cmd *cobra.Command, args []string) {
ipt, err := iptables.New() ipt, err := iptables.New()
handleError(err) handleError(err)
ips := ipset.New() ips := ipset.New(common.LogLogger())
handleError(resetIPTables(ipt)) handleError(resetIPTables(ipt))
handleError(resetIPSets(ips)) handleError(resetIPSets(ips))
handleError(createBaseRules(ipt, ips))
npc := npc.New(ipt, ips) npc := npc.New(nodeName, ipt, ips)
nsController := makeController(client.Core().RESTClient(), "namespaces", &coreapi.Namespace{}, nsController := makeController(client.Core().RESTClient(), "namespaces", &coreapi.Namespace{},
cache.ResourceEventHandlerFuncs{ cache.ResourceEventHandlerFuncs{
@@ -207,6 +239,7 @@ func main() {
rootCmd.PersistentFlags().StringVar(&metricsAddr, "metrics-addr", ":6781", "metrics server bind address") rootCmd.PersistentFlags().StringVar(&metricsAddr, "metrics-addr", ":6781", "metrics server bind address")
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "debug", "logging level (debug, info, warning, error)") rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "debug", "logging level (debug, info, warning, error)")
rootCmd.PersistentFlags().BoolVar(&allowMcast, "allow-mcast", true, "allow all multicast traffic") rootCmd.PersistentFlags().BoolVar(&allowMcast, "allow-mcast", true, "allow all multicast traffic")
rootCmd.PersistentFlags().StringVar(&nodeName, "node-name", "", "only generate rules that apply to this node")
handleError(rootCmd.Execute()) handleError(rootCmd.Execute())
} }
+17 -4
View File
@@ -6,6 +6,7 @@ import (
"time" "time"
"github.com/weaveworks/go-checkpoint" "github.com/weaveworks/go-checkpoint"
weave "github.com/weaveworks/weave/router"
) )
var checker *checkpoint.Checker var checker *checkpoint.Checker
@@ -16,7 +17,7 @@ const (
updateCheckPeriod = 6 * time.Hour updateCheckPeriod = 6 * time.Hour
) )
func checkForUpdates(dockerVersion string, network string) { func checkForUpdates(dockerVersion string, router *weave.NetworkRouter) {
newVersion.Store("") newVersion.Store("")
success.Store(true) success.Store(true)
@@ -51,9 +52,6 @@ func checkForUpdates(dockerVersion string, network string) {
"docker-version": dockerVersion, "docker-version": dockerVersion,
"kernel-version": kernelVersion, "kernel-version": kernelVersion,
} }
if network != "" {
flags["network"] = network
}
// Start background version checking // Start background version checking
params := checkpoint.CheckParams{ params := checkpoint.CheckParams{
@@ -61,6 +59,21 @@ func checkForUpdates(dockerVersion string, network string) {
Version: version, Version: version,
SignatureFile: "", SignatureFile: "",
Flags: flags, Flags: flags,
ExtraFlags: func() []checkpoint.Flag { return checkpointFlags(router) },
} }
checker = checkpoint.CheckInterval(&params, updateCheckPeriod, handleResponse) checker = checkpoint.CheckInterval(&params, updateCheckPeriod, handleResponse)
} }
func checkpointFlags(router *weave.NetworkRouter) []checkpoint.Flag {
flags := []checkpoint.Flag{}
status := weave.NewNetworkRouterStatus(router)
for _, conn := range status.Connections {
if connectionName, ok := conn.Attrs["name"].(string); ok {
if _, encrypted := conn.Attrs["encrypted"]; encrypted {
connectionName = connectionName + " encrypted"
}
flags = append(flags, checkpoint.Flag{Key: "network", Value: connectionName})
}
}
return flags
}
+11 -9
View File
@@ -231,7 +231,8 @@ func main() {
if bridge != nil { if bridge != nil {
if err := weavenet.DetectHairpin("vethwe-bridge", Log); err != nil { if err := weavenet.DetectHairpin("vethwe-bridge", Log); err != nil {
Log.Errorf("DetectHairpin failed: %s", err) Log.Errorf("Setting may cause connectivity issues : %s", err)
Log.Infof("Hairpin mode may have been enabled by other software on this machine")
} }
} }
@@ -254,7 +255,8 @@ func main() {
checkFatal(err) checkFatal(err)
defer db.Close() defer db.Close()
router := weave.NewNetworkRouter(config, networkConfig, name, nickName, overlay, db) router, err := weave.NewNetworkRouter(config, networkConfig, name, nickName, overlay, db)
checkFatal(err)
Log.Println("Our name is", router.Ourself) Log.Println("Our name is", router.Ourself)
if peers, err = router.InitialPeers(resume, peers); err != nil { if peers, err = router.InitialPeers(resume, peers); err != nil {
@@ -274,11 +276,7 @@ func main() {
dockerVersion = dockerCli.DockerVersion() dockerVersion = dockerCli.DockerVersion()
} }
network := "" checkForUpdates(dockerVersion, router)
if isAWSVPC {
network = "awsvpc"
}
checkForUpdates(dockerVersion, network)
observeContainers := func(o docker.ContainerObserver) { observeContainers := func(o docker.ContainerObserver) {
if dockerCli != nil { if dockerCli != nil {
@@ -476,7 +474,9 @@ func createAllocator(router *weave.NetworkRouter, config ipamConfig, preClaims [
allocator := ipam.NewAllocator(c) allocator := ipam.NewAllocator(c)
allocator.SetInterfaces(router.NewGossip("IPallocation", allocator)) gossip, err := router.NewGossip("IPallocation", allocator)
checkFatal(err)
allocator.SetInterfaces(gossip)
allocator.Start() allocator.Start()
router.Peers.OnGC(func(peer *mesh.Peer) { allocator.PeerGone(peer.Name) }) router.Peers.OnGC(func(peer *mesh.Peer) { allocator.PeerGone(peer.Name) })
@@ -486,7 +486,9 @@ func createAllocator(router *weave.NetworkRouter, config ipamConfig, preClaims [
func createDNSServer(config dnsConfig, router *mesh.Router, isKnownPeer func(mesh.PeerName) bool) (*nameserver.Nameserver, *nameserver.DNSServer) { func createDNSServer(config dnsConfig, router *mesh.Router, isKnownPeer func(mesh.PeerName) bool) (*nameserver.Nameserver, *nameserver.DNSServer) {
ns := nameserver.New(router.Ourself.Peer.Name, config.Domain, isKnownPeer) ns := nameserver.New(router.Ourself.Peer.Name, config.Domain, isKnownPeer)
router.Peers.OnGC(func(peer *mesh.Peer) { ns.PeerGone(peer.Name) }) router.Peers.OnGC(func(peer *mesh.Peer) { ns.PeerGone(peer.Name) })
ns.SetGossip(router.NewGossip("nameserver", ns)) gossip, err := router.NewGossip("nameserver", ns)
checkFatal(err)
ns.SetGossip(gossip)
upstream := nameserver.NewUpstream(config.ResolvConf, config.EffectiveListenAddress) upstream := nameserver.NewUpstream(config.ResolvConf, config.EffectiveListenAddress)
dnsserver, err := nameserver.NewDNSServer(ns, config.Domain, config.ListenAddress, dnsserver, err := nameserver.NewDNSServer(ns, config.Domain, config.ListenAddress,
upstream, uint32(config.TTL), config.ClientTimeout) upstream, uint32(config.TTL), config.ClientTimeout)
+6 -2
View File
@@ -14,11 +14,12 @@ import (
func attach(args []string) error { func attach(args []string) error {
if len(args) < 4 { if len(args) < 4 {
cmdUsage("attach-container", "[--no-multicast-route] [--keep-tx-on] <container-id> <bridge-name> <mtu> <cidr>...") cmdUsage("attach-container", "[--no-multicast-route] [--keep-tx-on] [--hairpin-mode=true|false] <container-id> <bridge-name> <mtu> <cidr>...")
} }
keepTXOn := false keepTXOn := false
withMulticastRoute := true withMulticastRoute := true
hairpinMode := true
for i := 0; i < len(args); { for i := 0; i < len(args); {
switch args[i] { switch args[i] {
case "--no-multicast-route": case "--no-multicast-route":
@@ -27,6 +28,9 @@ func attach(args []string) error {
case "--keep-tx-on": case "--keep-tx-on":
keepTXOn = true keepTXOn = true
args = append(args[:i], args[i+1:]...) args = append(args[:i], args[i+1:]...)
case "--hairpin-mode=false":
hairpinMode = false
args = append(args[:i], args[i+1:]...)
default: default:
i++ i++
} }
@@ -55,7 +59,7 @@ func attach(args []string) error {
return err return err
} }
err = weavenet.AttachContainer(weavenet.NSPathByPid(pid), fmt.Sprint(pid), weavenet.VethName, args[1], mtu, withMulticastRoute, cidrs, keepTXOn) err = weavenet.AttachContainer(weavenet.NSPathByPid(pid), fmt.Sprint(pid), weavenet.VethName, args[1], mtu, withMulticastRoute, cidrs, keepTXOn, hairpinMode)
// If we detected an error but the container has died, tell the user that instead. // If we detected an error but the container has died, tell the user that instead.
if err != nil && !processExists(pid) { if err != nil && !processExists(pid) {
err = fmt.Errorf("Container %s died", args[0]) err = fmt.Errorf("Container %s died", args[0])
+1 -1
View File
@@ -1224,7 +1224,7 @@ func (fastdp *FastDatapath) send(fops FlowOp, frame []byte, lock *fastDatapathLo
} }
if fastdp.isHairpinFlow(&flow) { if fastdp.isHairpinFlow(&flow) {
log.Error("Vetoed installation of hairpin flow ", flow) log.Warning("Vetoed installation of hairpin flow ", flow)
return return
} }
+7 -3
View File
@@ -51,7 +51,7 @@ type NetworkRouter struct {
db db.DB db db.DB
} }
func NewNetworkRouter(config mesh.Config, networkConfig NetworkConfig, name mesh.PeerName, nickName string, overlay NetworkOverlay, db db.DB) *NetworkRouter { func NewNetworkRouter(config mesh.Config, networkConfig NetworkConfig, name mesh.PeerName, nickName string, overlay NetworkOverlay, db db.DB) (*NetworkRouter, error) {
if overlay == nil { if overlay == nil {
overlay = NullNetworkOverlay{} overlay = NullNetworkOverlay{}
} }
@@ -59,7 +59,11 @@ func NewNetworkRouter(config mesh.Config, networkConfig NetworkConfig, name mesh
networkConfig.Bridge = NullBridge{} networkConfig.Bridge = NullBridge{}
} }
router := &NetworkRouter{Router: mesh.NewRouter(config, name, nickName, overlay, common.LogLogger()), NetworkConfig: networkConfig, db: db} meshRouter, err := mesh.NewRouter(config, name, nickName, overlay, common.LogLogger())
if err != nil {
return nil, err
}
router := &NetworkRouter{Router: meshRouter, NetworkConfig: networkConfig, db: db}
router.Peers.OnInvalidateShortIDs(overlay.InvalidateShortIDs) router.Peers.OnInvalidateShortIDs(overlay.InvalidateShortIDs)
router.Routes.OnChange(overlay.InvalidateRoutes) router.Routes.OnChange(overlay.InvalidateRoutes)
router.Macs = NewMacCache(macMaxAge, router.Macs = NewMacCache(macMaxAge,
@@ -67,7 +71,7 @@ func NewNetworkRouter(config mesh.Config, networkConfig NetworkConfig, name mesh
log.Println("Expired MAC", mac, "at", peer) log.Println("Expired MAC", mac, "at", peer)
}) })
router.Peers.OnGC(func(peer *mesh.Peer) { router.Macs.Delete(peer) }) router.Peers.OnGC(func(peer *mesh.Peer) { router.Macs.Delete(peer) })
return router return router, nil
} }
// Start listening for TCP connections, locally captured packets, and // Start listening for TCP connections, locally captured packets, and
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Building Weave Net title: Building Weave Net
menu_order: 120 menu_order: 120
search_type: Documentation
--- ---
You only need to build Weave Net if you want to work on the Weave Net codebase You only need to build Weave Net if you want to work on the Weave Net codebase
(or you just enjoy building software). (or you just enjoy building software).
+2 -1
View File
@@ -1,6 +1,7 @@
--- ---
title: Integrating Kubernetes and Mesos via the CNI Plugin title: Integrating Kubernetes and Mesos via the CNI Plugin
menu_order: 65 menu_order: 65
search_type: Documentation
--- ---
> The recommended way of using Weave with Kubernetes is via the new > The recommended way of using Weave with Kubernetes is via the new
@@ -11,7 +12,7 @@ menu_order: 65
CNI, the [_Container Network Interface_](https://github.com/containernetworking/cni), CNI, the [_Container Network Interface_](https://github.com/containernetworking/cni),
is a proposed standard for configuring network interfaces for Linux is a proposed standard for configuring network interfaces for Linux
application containers. CNI is supported by application containers. CNI is supported by
[Kubernetes](http://kubernetes.io/), [Apache Mesos](mesos.apache.org) [Kubernetes](http://kubernetes.io/), [Apache Mesos](http://mesos.apache.org)
and and
[others](https://github.com/containernetworking/cni#who-is-using-cni). [others](https://github.com/containernetworking/cni#who-is-using-cni).
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: FAQ title: FAQ
menu_order: 200 menu_order: 200
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Feature Overview title: Feature Overview
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
* [Virtual Ethernet Switch](#virtual-ethernet-switch) * [Virtual Ethernet Switch](#virtual-ethernet-switch)
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Understanding how Weave Net Works title: Understanding how Weave Net Works
menu_order: 90 menu_order: 90
search_type: Documentation
--- ---
@@ -1,6 +1,7 @@
--- ---
title: How Weave Net Implements Encryption title: How Weave Net Implements Encryption
menu_order: 70 menu_order: 70
search_type: Documentation
--- ---
This section describes some details of Weave Net's built-in This section describes some details of Weave Net's built-in
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Encryption and Weave Net title: Encryption and Weave Net
menu_order: 60 menu_order: 60
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: How Fast Datapath Works title: How Fast Datapath Works
menu_order: 30 menu_order: 30
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: IP Addresses, Routes and Networks title: IP Addresses, Routes and Networks
menu_order: 50 menu_order: 50
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: How Weave Net Interprets Network Topology title: How Weave Net Interprets Network Topology
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
This section contains the following topics: This section contains the following topics:
@@ -1,6 +1,7 @@
--- ---
title: Weave Net Router Sleeve Encapsulation title: Weave Net Router Sleeve Encapsulation
menu_order: 10 menu_order: 10
search_type: Documentation
--- ---
When the Weave Net router forwards packets to peers in `sleeve` mode When the Weave Net router forwards packets to peers in `sleeve` mode
+3 -2
View File
@@ -1,11 +1,12 @@
--- ---
title: Installing Weave Net title: Installing Weave Net
menu_order: 30 menu_order: 30
search_type: Documentation
--- ---
Ensure you are running Linux (kernel 3.8 or later) and have Docker Ensure you are running Linux (kernel 3.8 or later) and have Docker
(version 1.6.0 or later) installed. (version 1.10.0 or later) installed.
Install Weave Net by running the following: Install Weave Net by running the following:
@@ -50,7 +51,7 @@ To disable this check, run the following before launching Weave Net:
CoreOS users see [here](/guides/networking-docker-containers-with-weave-on-coreos/) for an example of installing Weave using cloud-config. CoreOS users see [here](/guides/networking-docker-containers-with-weave-on-coreos/) for an example of installing Weave using cloud-config.
Amazon ECS users see [here](https://github.com/weaveworks/integrations/blob/master/aws/ecs/README.md) Amazon ECS users see [here](https://github.com/weaveworks/integrations/blob/master/aws/ecs/README.md)
for the latest Weave AMIs and [here](http://weave.works/guides/service-discovery-with-weave-aws-ecs.html) to get started with Weave Net on ECS. for the latest Weave AMIs and [here](https://www.weave.works/docs/tutorials/old-guides/ecs/) to get started with Weave Net on ECS.
If you're on Amazon EC2, the standard installation instructions at the If you're on Amazon EC2, the standard installation instructions at the
top of this page, provide the simplest setup and the most flexibility. top of this page, provide the simplest setup and the most flexibility.
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Using Weave with Systemd title: Using Weave with Systemd
menu_order: 130 menu_order: 130
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Introducing Weave Net title: Introducing Weave Net
menu_order: 10 menu_order: 10
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Allocating IP Addresses title: Allocating IP Addresses
menu_order: 70 menu_order: 70
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Automatic Allocation Across Multiple Subnets title: Automatic Allocation Across Multiple Subnets
menu_order: 10 menu_order: 10
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Starting, Stopping and Removing Peers title: Starting, Stopping and Removing Peers
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Troubleshooting the IP Allocator title: Troubleshooting the IP Allocator
menu_order: 30 menu_order: 30
search_type: Documentation
--- ---
+103 -14
View File
@@ -1,13 +1,16 @@
--- ---
title: Integrating Kubernetes via the Addon title: Integrating Kubernetes via the Addon
menu_order: 63 menu_order: 63
search_type: Documentation
--- ---
The following topics are discussed: The following topics are discussed:
* [Installation](#install) * [Installation](#install)
* [Network Policy Controller](#npc) * [Upgrading Kubernetes to version 1.6](#kube-1.6-upgrade)
* [Upgrading the Daemon Sets](#daemon-sets) * [Upgrading the Daemon Sets](#daemon-sets)
* [CPU and Memory Requirements](#resources)
* [Pod Eviction](#eviction)
* [Network Policy Controller](#npc) * [Network Policy Controller](#npc)
* [Troubleshooting Blocked Connections](#blocked-connections) * [Troubleshooting Blocked Connections](#blocked-connections)
* [Changing Configuration Options](#configuration-options) * [Changing Configuration Options](#configuration-options)
@@ -18,15 +21,24 @@ The following topics are discussed:
Weave Net can be installed onto your CNI-enabled Kubernetes cluster Weave Net can be installed onto your CNI-enabled Kubernetes cluster
with a single command: with a single command:
* Kubernetes versions `1.6` and above:
``` ```
kubectl apply -f https://git.io/weave-kube $ kubectl apply -f https://git.io/weave-kube-1.6
```
* Kubernetes versions up to `1.5`:
```
$ kubectl apply -f https://git.io/weave-kube
``` ```
After a few seconds, a Weave Net pod should be running on each After a few seconds, a Weave Net pod should be running on each
Node and any further pods you create will be automatically attached to the Weave Node and any further pods you create will be automatically attached to the Weave
network. network.
**Note:** This command requires Kubernetes 1.4 or later. **Note:** This command requires Kubernetes 1.4 or later, and we
recommend your master node has at least two CPU cores.
> CNI, the [_Container Network Interface_](https://github.com/containernetworking/cni), > CNI, the [_Container Network Interface_](https://github.com/containernetworking/cni),
> is a proposed standard for configuring network interfaces for Linux > is a proposed standard for configuring network interfaces for Linux
@@ -51,11 +63,26 @@ Shut down Kubernetes, and _on all nodes_ perform the following:
Then relaunch Kubernetes and install the addon as described Then relaunch Kubernetes and install the addon as described
above. above.
The URL [https://git.io/weave-kube](https://git.io/weave-kube) points The URLs [https://git.io/weave-kube](https://git.io/weave-kube) and [https://git.io/weave-kube-1.6](https://git.io/weave-kube-1.6) point
to the YAML file for the latest release of the Weave Net addon. to the YAML file for the [latest release](https://github.com/weaveworks/weave/releases/tag/latest_release) of the Weave Net addon.
Historic versions are archived on our [GitHub release Historic versions are archived on our [GitHub release
page](https://github.com/weaveworks/weave/releases). page](https://github.com/weaveworks/weave/releases).
## <a name="kube-1.6-upgrade"></a> Upgrading Kubernetes to version 1.6
In version 1.6, Kubernetes has increased security, so we need to
create a special service account to run Weave Net. This is done in
the file `weave-daemonset-k8s-1.6.yaml` attached to the [Weave Net
release](https://github.com/weaveworks/weave/releases/latest).
Also, the
[toleration](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/taint-toleration-dedicated.md)
required to let Weave Net run on master nodes has moved from an
annotation to a field on the DaemonSet spec object.
If you have edited the Weave Net DaemonSet from a previous release,
you will need to re-make your changes against the new version.
### <a name="daemon-sets"></a> Upgrading the Daemon Sets ### <a name="daemon-sets"></a> Upgrading the Daemon Sets
Kubernetes does not currently support rolling upgrades of daemon sets, Kubernetes does not currently support rolling upgrades of daemon sets,
@@ -68,6 +95,64 @@ and so you will need to perform the procedure manually:
lose track of IP address range ownership, possibly leading to lose track of IP address range ownership, possibly leading to
duplicate IP addresses if you then start a new copy of Weave Net. duplicate IP addresses if you then start a new copy of Weave Net.
## <a name="resources"></a>CPU and Memory Requirements
Kubernetes manages
[resources](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
on each node, and only schedules pods to run on nodes that have enough
free resources.
The components of a typical Kubernetes installation (with the master
node running etcd, scheduler, api-server, etc.) take up about 95% of a
CPU, which leaves little room to run anything else. For all of Weave
Net's features to work, it must run on every node, including the
master.
The best way to resolve this issue is to use machines with at least
two CPU cores. However if you are installing Kubernetes and Weave Net
for the first time, you may not be aware of this requirement. For this
reason, Weave Net launches as a DaemonSet with a specification that
reserves at least 1% CPU for each container. This enables Weave Net to
start up seamlessly on a single-CPU node.
Depending on the workload, Weave Net may need more than 1% of the
CPU. The percentage set in the DaemonSet is the minimum and not a
limit. This minimum setting allows Weave Net to take advantage of
available CPU and "burst" above that limit if it needs to.
## <a name="eviction"></a>Pod Eviction
If a node runs out of CPU, memory or disk, Kubernetes may [decide to
evict](https://kubernetes.io/docs/concepts/cluster-administration/out-of-resource/)
one or more pods. It may choose to evict the Weave Net pod, which will
disrupt pod network operations.
You can reduce the chance of eviction by changing the DaemonSet to
have a much bigger request, and a limit of the same value.
This causes Kubernetes to apply a ["guaranteed" rather than a
"burstable" policy](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/resource-qos.md).
However a similar request for disk space can not
be made, and so please be aware of this issue and monitor your
resources to ensure that they stay below 100%.
You can see when pods have been evicted via the `kubectl get events` command
```
LASTSEEN COUNT NAME KIND TYPE REASON SOURCE MESSAGE
1m 1 mypod-09vkd Pod Warning Evicted kubelet, node-1 The node was low on resource: memory.
```
or `kubectl get pods`
```
NAME READY STATUS RESTARTS AGE IP NODE
mypod-09vkd 0/1 Evicted 0 1h <none> node-1
```
If you see this in your cluster, consider some of the above steps to
reduce disruption.
## <a name="npc"></a>Network Policy Controller ## <a name="npc"></a>Network Policy Controller
The addon also supports the [Kubernetes policy The addon also supports the [Kubernetes policy
@@ -138,21 +223,25 @@ inserted into the YAML file like this:
The list of variables you can set is: The list of variables you can set is:
* CHECKPOINT\_DISABLE - if set to 1, disable checking for new Weave Net * `CHECKPOINT_DISABLE` - if set to 1, disable checking for new Weave Net
versions (default is blank, i.e. check is enabled) versions (default is blank, i.e. check is enabled)
* IPALLOC\_RANGE - the range of IP addresses used by Weave Net * `IPALLOC_RANGE` - the range of IP addresses used by Weave Net
and the subnet they are placed in (CIDR format; default 10.32.0.0/12) and the subnet they are placed in (CIDR format; default `10.32.0.0/12`)
* EXPECT\_NPC - set to 0 to disable Network Policy Controller (default is on) * `EXPECT_NPC` - set to 0 to disable Network Policy Controller (default is on)
* KUBE\_PEERS - list of addresses of peers in the Kubernetes cluster * `KUBE_PEERS` - list of addresses of peers in the Kubernetes cluster
(default is to fetch the list from the api-server) (default is to fetch the list from the api-server)
* IPALLOC\_INIT - set the initialization mode of the [IP Address * `IPALLOC_INIT` - set the initialization mode of the [IP Address
Manager](/site/operational-guide/concepts.md#ip-address-manager) Manager](/site/operational-guide/concepts.md#ip-address-manager)
(defaults to consensus amongst the KUBE\_PEERS) (defaults to consensus amongst the `KUBE_PEERS`)
* WEAVE\_EXPOSE\_IP - set the IP address used as a gateway from the * `WEAVE_EXPOSE_IP` - set the IP address used as a gateway from the
Weave network to the host network - this is useful if you are Weave network to the host network - this is useful if you are
configuring the addon as a static pod. configuring the addon as a static pod.
* WEAVE\_MTU - Weave Net defaults to 1376 bytes, but you can set a * `WEAVE_MTU` - Weave Net defaults to 1376 bytes, but you can set a
smaller size if your underlying network has a tighter limit, or set smaller size if your underlying network has a tighter limit, or set
a larger size for better performance if your network supports jumbo a larger size for better performance if your network supports jumbo
frames - see [here](/site/using-weave/fastdp.md#mtu) for more frames - see [here](/site/using-weave/fastdp.md#mtu) for more
details. details.
* `HAIRPIN_MODE` - Weave Net defaults to enabling hairpin on the bridge side of
the `veth` pair for containers attached. If you need to disable hairpin, e.g. your
kernel is one of those that can panic if hairpin is enabled, then you can disable it
by setting `HAIRPIN_MODE=false`.
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Monitoring with Prometheus title: Monitoring with Prometheus
menu_order: 105 menu_order: 105
search_type: Documentation
--- ---
Two endpoints are exposed: one for the Weave Net router, and, when deployed as Two endpoints are exposed: one for the Weave Net router, and, when deployed as
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Operational Guide title: Operational Guide
menu_order: 45 menu_order: 45
search_type: Documentation
--- ---
This operational guide is intended to give you an overview of how to This operational guide is intended to give you an overview of how to
operate and manage a Weave Network in production. It consists of three operate and manage a Weave Network in production. It consists of three
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Autoscaling title: Autoscaling
menu_order: 40 menu_order: 40
search_type: Documentation
--- ---
### Bootstrapping ### Bootstrapping
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Concepts title: Concepts
menu_order: 10 menu_order: 10
search_type: Documentation
--- ---
This section describes some of the essential concepts with which you will This section describes some of the essential concepts with which you will
need to be familiar before continuing to the example deployment need to be familiar before continuing to the example deployment
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Interactive Deployment title: Interactive Deployment
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
Weave Net can be launched interactively on the command line, and as Weave Net can be launched interactively on the command line, and as
long as Docker is configured to start on boot, the network will survive long as Docker is configured to start on boot, the network will survive
+2 -1
View File
@@ -1,6 +1,7 @@
--- ---
title: Administrative Tasks title: Administrative Tasks
menu_order: 60 menu_order: 60
search_type: Documentation
--- ---
The following administrative tasks are discussed: The following administrative tasks are discussed:
@@ -43,7 +44,7 @@ or possible:
In some cases you may already be aware of the problem, as you were In some cases you may already be aware of the problem, as you were
unable to execute `weave reset` successfully or because you know unable to execute `weave reset` successfully or because you know
through other channels that the host has died. In these cases you can through other channels that the host has died. In these cases you can
proceed straight to [Manually Reclaiming Lost Address Space](#reclaim-address-space). proceed straight to [Manually Reclaiming Lost Address Space](#manually-reclaim-address-space).
However in some scenarios it may not be obvious that space has been However in some scenarios it may not be obvious that space has been
lost, in which case you can check for it periodically with the lost, in which case you can check for it periodically with the
@@ -1,6 +1,7 @@
--- ---
title: Uniform Dynamic Clusters title: Uniform Dynamic Clusters
menu_order: 50 menu_order: 50
search_type: Documentation
--- ---
A uniform dynamic cluster has the following characteristics: A uniform dynamic cluster has the following characteristics:
@@ -1,6 +1,7 @@
--- ---
title: Uniform Fixed Clusters title: Uniform Fixed Clusters
menu_order: 30 menu_order: 30
search_type: Documentation
--- ---
This scenario describes a production deployment of a fixed number of N This scenario describes a production deployment of a fixed number of N
+1 -1
View File
@@ -1,11 +1,11 @@
--- ---
title: Integrating Docker via the Network Plugin title: Integrating Docker via the Network Plugin
menu_order: 60 menu_order: 60
search_type: Documentation
--- ---
* [Launching Weave Net and Running Containers Using the Plugin](#launching) * [Launching Weave Net and Running Containers Using the Plugin](#launching)
* [Restarting the Plugin](#restarting) * [Restarting the Plugin](#restarting)
* [Configuring the Plugin](#configuring)
Docker versions 1.9 and later have a plugin mechanism for adding Docker versions 1.9 and later have a plugin mechanism for adding
different network providers. Weave Net installs itself as a network different network providers. Weave Net installs itself as a network
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: How the Weave Net Docker Network Plugin Works title: How the Weave Net Docker Network Plugin Works
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Troubleshooting Weave Net title: Troubleshooting Weave Net
menu_order: 110 menu_order: 110
search_type: Documentation
--- ---
+2 -1
View File
@@ -1,9 +1,10 @@
--- ---
title: Using Weave Net title: Using Weave Net
menu_order: 40 menu_order: 40
search_type: Documentation
--- ---
Weave Net provides a simple to deploy networking solution for containerized apps. Here, we describe how to manage a Weave container network using a sample application which consists of two simple `netcat` services deployed to containers on two separate hosts, and sometimes extended across three hosts. Weave Net provides a simple to deploy networking solution for containerized apps. Here, we describe how to manage a Weave container network using a sample application which consists of two simple `netcat` services deployed to containers on two separate hosts.
This section contains the following topics: This section contains the following topics:
@@ -1,6 +1,7 @@
--- ---
title: Isolating Applications on a Weave Network title: Isolating Applications on a Weave Network
menu_order: 30 menu_order: 30
search_type: Documentation
--- ---
A single Weave network can host multiple, isolated applications where each application's containers are able A single Weave network can host multiple, isolated applications where each application's containers are able
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Using IP Routing on an Amazon Web Services Virtual Private Cloud title: Using IP Routing on an Amazon Web Services Virtual Private Cloud
menu_order: 110 menu_order: 110
search_type: Documentation
--- ---
If your container infrastructure is running entirely within Amazon Web Services (AWS) If your container infrastructure is running entirely within Amazon Web Services (AWS)
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Allocating IPs in a Specific Range title: Allocating IPs in a Specific Range
menu_order: 15 menu_order: 15
search_type: Documentation
--- ---
The default configurations for both Weave Net and Docker use [Private The default configurations for both Weave Net and Docker use [Private
@@ -1,6 +1,7 @@
--- ---
title: Dynamically Attaching and Detaching Applications title: Dynamically Attaching and Detaching Applications
menu_order: 40 menu_order: 40
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Using Fast Datapath title: Using Fast Datapath
menu_order: 96 menu_order: 96
search_type: Documentation
--- ---
@@ -1,6 +1,7 @@
--- ---
title: Adding and Removing Hosts Dynamically title: Adding and Removing Hosts Dynamically
menu_order: 90 menu_order: 90
search_type: Documentation
--- ---
To add a host to an existing Weave network, launch Weave Net on the To add a host to an existing Weave network, launch Weave Net on the
@@ -1,6 +1,7 @@
--- ---
title: Integrating with the Host Network title: Integrating with the Host Network
menu_order: 60 menu_order: 60
search_type: Documentation
--- ---
Weave application networks can be integrated with an external host network, establishing connectivity between the host and with application containers running anywhere. Weave application networks can be integrated with an external host network, establishing connectivity between the host and with application containers running anywhere.
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Manually Specifying the IP Address of a Container title: Manually Specifying the IP Address of a Container
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
Containers are automatically allocated an IP address that is unique across the Weave network. You can see which address was allocated by running, [`weave ps`](/site/troubleshooting.md#weave-status): Containers are automatically allocated an IP address that is unique across the Weave network. You can see which address was allocated by running, [`weave ps`](/site/troubleshooting.md#weave-status):
@@ -1,6 +1,7 @@
--- ---
title: Enabling Multi-Cloud, Multi-Hop Networking and Routing title: Enabling Multi-Cloud, Multi-Hop Networking and Routing
menu_order: 100 menu_order: 100
search_type: Documentation
--- ---
@@ -1,6 +1,7 @@
--- ---
title: Securing Connections Across Untrusted Networks title: Securing Connections Across Untrusted Networks
menu_order: 80 menu_order: 80
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Managing Services - Exporting, Importing, Binding and Routing title: Managing Services - Exporting, Importing, Binding and Routing
menu_order: 70 menu_order: 70
search_type: Documentation
--- ---
This section contains the following topics: This section contains the following topics:
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Integrating Docker via the API Proxy title: Integrating Docker via the API Proxy
menu_order: 50 menu_order: 50
search_type: Documentation
--- ---
The Docker API proxy automatically attaches containers to the Weave The Docker API proxy automatically attaches containers to the Weave
@@ -1,6 +1,7 @@
--- ---
title: Using Automatic Discovery With the Weave Net Proxy title: Using Automatic Discovery With the Weave Net Proxy
menu_order: 30 menu_order: 30
search_type: Documentation
--- ---
Containers launched via the proxy use [weaveDNS](/site/weavedns.md) Containers launched via the proxy use [weaveDNS](/site/weavedns.md)
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Automatic IP Allocation and the Weave Proxy title: Automatic IP Allocation and the Weave Proxy
menu_order: 25 menu_order: 25
search_type: Documentation
--- ---
@@ -1,6 +1,7 @@
--- ---
title: Launching Containers With Weave Run (without the Proxy) title: Launching Containers With Weave Run (without the Proxy)
menu_order: 50 menu_order: 50
search_type: Documentation
--- ---
@@ -1,6 +1,7 @@
--- ---
title: Name resolution via `/etc/hosts` title: Name resolution via `/etc/hosts`
menu_order: 40 menu_order: 40
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Securing the Docker Communications With TLS title: Securing the Docker Communications With TLS
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
If you are [connecting to the docker daemon with If you are [connecting to the docker daemon with
@@ -1,6 +1,7 @@
--- ---
title: Troubleshooting title: Troubleshooting
menu_order: 60 menu_order: 60
search_type: Documentation
--- ---
The command The command
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Using The Weave Docker API Proxy title: Using The Weave Docker API Proxy
menu_order: 10 menu_order: 10
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: Discovering Containers with WeaveDNS title: Discovering Containers with WeaveDNS
menu_order: 80 menu_order: 80
search_type: Documentation
--- ---
+1
View File
@@ -1,6 +1,7 @@
--- ---
title: How Weave Finds Containers title: How Weave Finds Containers
menu_order: 10 menu_order: 10
search_type: Documentation
--- ---
+2 -1
View File
@@ -1,6 +1,7 @@
--- ---
title: Load Balancing and Fault Resilience with weaveDNS title: Load Balancing and Fault Resilience with weaveDNS
menu_order: 20 menu_order: 20
search_type: Documentation
--- ---
@@ -48,7 +49,7 @@ WeaveDNS removes the addresses of any container that dies. This offers
a simple way to implement redundancy. E.g. if in our example we stop a simple way to implement redundancy. E.g. if in our example we stop
one of the `pingme` containers and re-run the ping tests, eventually one of the `pingme` containers and re-run the ping tests, eventually
(within ~30s at most, since that is the weaveDNS (within ~30s at most, since that is the weaveDNS
[cache expiry time](#ttl)) we will only be hitting the address of the [cache expiry time](/site/weavedns/managing-entries-weavedns.md#ttl)) we will only be hitting the address of the
container that is still alive. container that is still alive.
**See Also** **See Also**
+2 -1
View File
@@ -1,6 +1,7 @@
--- ---
title: Managing Domains title: Managing Domains
menu_order: 30 menu_order: 30
search_type: Documentation
--- ---
The following topics are discussed: The following topics are discussed:
@@ -44,6 +45,6 @@ link-local as per [RFC6762](https://tools.ietf.org/html/rfc6762),
(though this is not strictly necessary). (though this is not strictly necessary).
* [How Weave Finds Containers](/site/how-works-weavedns.md.md) * [How Weave Finds Containers](/site/how-works-weavedns.md)
* [Load Balancing and Fault Resilience with WeaveDNS](/site/weavedns/load-balance-fault-weavedns.md) * [Load Balancing and Fault Resilience with WeaveDNS](/site/weavedns/load-balance-fault-weavedns.md)
* [Managing Domain Entries](/site/weavedns/managing-entries-weavedns.md) * [Managing Domain Entries](/site/weavedns/managing-entries-weavedns.md)
+2 -5
View File
@@ -1,19 +1,16 @@
--- ---
title: Managing Domain Entries title: Managing Domain Entries
menu_order: 40 menu_order: 40
search_type: Documentation
--- ---
The following topics are discussed: The following topics are discussed:
* [Adding and removing extra DNS entries](#add-remove) * [Adding and removing extra DNS entries](#add-remove)
* [Resolving WeaveDNS entries from the Host](#resolve-weavedns-entries-from-host) * [Resolving WeaveDNS entries from the Host](#resolve-weavedns-entries-from-host)
* [Hot-swapping Service Containers](#hot-swapping) * [Hot-swapping Service Containers](#hot-swapping)
* [Retaining DNS Entries When Containers Stop](#retain-stopped)
* [Configuring a Custom TTL](#ttl) * [Configuring a Custom TTL](#ttl)
### <a name="add-remove"></a>Adding and Removing Extra DNS Entries ### <a name="add-remove"></a>Adding and Removing Extra DNS Entries
If you want to give the container a name in DNS *other* than its If you want to give the container a name in DNS *other* than its
@@ -81,6 +78,6 @@ weaveDNS instance will receive.
**See Also** **See Also**
* [How Weave Finds Containers](/site/how-works-weavedns.md) * [How Weave Finds Containers](/site/weavedns/how-works-weavedns.md)
* [Load Balancing and Fault Resilience with WeaveDNS](/site/weavedns/load-balance-fault-weavedns.md) * [Load Balancing and Fault Resilience with WeaveDNS](/site/weavedns/load-balance-fault-weavedns.md)
* [Managing Domains](/site/weavedns/managing-domains-weavedns.md) * [Managing Domains](/site/weavedns/managing-domains-weavedns.md)
@@ -1,6 +1,7 @@
--- ---
title: Troubleshooting and Present Limitations title: Troubleshooting and Present Limitations
menu_order: 50 menu_order: 50
search_type: Documentation
--- ---
+51
View File
@@ -19,6 +19,11 @@ weave_on $HOST1 launch
C0=$(docker_on $HOST1 run --net=none --name=c0 -dt $SMALL_IMAGE /bin/sh) 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) 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) C2=$(docker_on $HOST1 run --net=none --name=c2 -dt $SMALL_IMAGE /bin/sh)
CH0=$(docker_on $HOST1 run --net=none --name=ch0 -dt $SMALL_IMAGE /bin/sh)
CH1=$(docker_on $HOST1 run --net=none --name=ch1 -dt $SMALL_IMAGE /bin/sh)
CH2=$(docker_on $HOST1 run --net=none --name=ch2 -dt $SMALL_IMAGE /bin/sh)
# Enable unsolicited ARPs so that ping after the address reuse does not time out # 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 exec_on $HOST1 c1 sysctl -w net.ipv4.conf.all.arp_accept=1
@@ -52,6 +57,29 @@ cni_connect $HOST1 c2 <<EOF
} }
EOF EOF
# examples to test hairpin
cni_connect $HOST1 ch0 <<EOF
{
"name": "weave",
"type": "weave-net",
"hairpinMode": true
}
EOF
cni_connect $HOST1 ch1 <<EOF
{
"name": "weave",
"type": "weave-net",
"hairpinMode": false
}
EOF
cni_connect $HOST1 ch2 <<EOF
{
"name": "weave",
"type": "weave-net"
}
EOF
C0IP=$(container_ip $HOST1 c0) C0IP=$(container_ip $HOST1 c0)
C1IP=$(container_ip $HOST1 c1) C1IP=$(container_ip $HOST1 c1)
C2IP=$(container_ip $HOST1 c2) C2IP=$(container_ip $HOST1 c2)
@@ -85,6 +113,29 @@ assert_raises "[ $C2IP != $C3IP ]"
assert_raises "[ $BRIP != $C3IP ]" assert_raises "[ $BRIP != $C3IP ]"
assert_raises "exec_on $HOST1 c1 $PING $C3IP" assert_raises "exec_on $HOST1 c1 $PING $C3IP"
#####
#
# Hairpin mode tests
#
# here we check that the bridge side of the veth is set to hairpin mode (true or false) correctly
# check for each of
# - ch0 explicitly true
# - ch1 explicitly false
# - ch2 unset, which should default to true
#
# we take advantage of the veth name being constructed from the container ID)
#
# should this reliance ever fail and we need to get it from the system, do the following for each:
# CH0_PEER_ID=$(exec_on $HOST1 ch0 cat /sys/class/net/eth0/iflink)
# CH0_PEER=$($SSH $HOST1 ip link show | awk "/^${CH0_PEER_ID}:/"' {print $2}' | sed 's/@.*$//g' )
# CH0_HAIRPIN=$($SSH $HOST1 cat /sys/devices/virtual/net/weave/brif/$CH0_PEER/hairpin_mode)
# assert_raises "[ $CH0_HAIRPIN == 1 ]"
#
assert "$SSH $HOST1 cat /sys/devices/virtual/net/weave/brif/vethwepl${CH0:0:7}/hairpin_mode" "1"
assert "$SSH $HOST1 cat /sys/devices/virtual/net/weave/brif/vethwepl${CH1:0:7}/hairpin_mode" "0"
assert "$SSH $HOST1 cat /sys/devices/virtual/net/weave/brif/vethwepl${CH2:0:7}/hairpin_mode" "1"
# Ensure existing containers can reclaim their IP addresses after CNI has been used -- see #2548 # Ensure existing containers can reclaim their IP addresses after CNI has been used -- see #2548
stop_weave_on $HOST1 stop_weave_on $HOST1
+5 -1
View File
@@ -24,7 +24,11 @@ tear_down_kubeadm
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 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 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" # kubeadm init upgrades to latest Kubernetes version by default, therefore we try to lock the version using the below option:
k8s_version="$(run_on $HOST1 "kubelet --version" | grep -oP "(?<=Kubernetes )v[\d\.\-beta]+")"
k8s_version_option="$([[ "$k8s_version" > "v1.6" ]] && echo "kubernetes-version" || echo "use-kubernetes-version")"
run_on $HOST1 "sudo systemctl start kubelet && sudo kubeadm init --$k8s_version_option=$k8s_version --token=$TOKEN"
run_on $HOST2 "sudo systemctl start kubelet && sudo kubeadm join --token=$TOKEN $HOST1IP" 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" run_on $HOST3 "sudo systemctl start kubelet && sudo kubeadm join --token=$TOKEN $HOST1IP"
+1 -1
View File
@@ -2,7 +2,7 @@ This directory contains integration tests for weave.
## Requirements ## Requirements
You need three VMs with `docker` (`>=1.6.0`) installed and listening on TCP You need three VMs with `docker` (`>=1.10.0`) installed and listening on TCP
port `2375` (see below). You also need to be able to SSH to these VMs without port `2375` (see below). You also need to be able to SSH to these VMs without
having to input anything. having to input anything.
+13 -7
View File
@@ -65,7 +65,7 @@ function print_vars() {
} }
function verify_dependencies() { function verify_dependencies() {
local deps=(python terraform ansible-playbook) local deps=(python terraform ansible-playbook gcloud)
for dep in "${deps[@]}"; do for dep in "${deps[@]}"; do
if [ ! "$(which "$dep")" ]; then if [ ! "$(which "$dep")" ]; then
echo >&2 "$dep is not installed or not in PATH." echo >&2 "$dep is not installed or not in PATH."
@@ -157,7 +157,8 @@ function create_image() {
terraform destroy -force "$DIR/../tools/provisioning/gcp" terraform destroy -force "$DIR/../tools/provisioning/gcp"
rm terraform.tfstate* rm terraform.tfstate*
echo echo
greenly echo "> Created GCP image $IMAGE_NAME in $(date -u -d @$(($(date +%s) - begin_img)) +"%T")." local end_img=$(date +%s)
greenly echo "> Created GCP image $IMAGE_NAME in $(date -u -d @$((end_img - begin_img)) +"%T")."
else else
wait_for_image wait_for_image
fi fi
@@ -261,7 +262,8 @@ function provision() {
esac esac
[ "$1" == "on" ] && set_hosts [ "$1" == "on" ] && set_hosts
echo echo
greenly echo "> Provisioning took $(date -u -d @$(($(date +%s) - begin_prov)) +"%T")." local end_prov=$(date +%s)
greenly echo "> Provisioning took $(date -u -d @$((end_prov - begin_prov)) +"%T")."
} }
function configure_with_ansible() { function configure_with_ansible() {
@@ -282,7 +284,7 @@ function configure() {
local inventory_file=$(mktemp /tmp/ansible_inventory_XXXXX) local inventory_file=$(mktemp /tmp/ansible_inventory_XXXXX)
echo "[all]" >"$inventory_file" echo "[all]" >"$inventory_file"
# shellcheck disable=SC2001 # shellcheck disable=SC2001
echo "$2" | sed "s/$/:$3/" >>"$inventory_file" echo "$2" | sed "s/\$/:$3/" >>"$inventory_file"
# Configure the provisioned machines using Ansible, allowing up to 3 retries upon failure (e.g. APT connectivity issues, etc.): # Configure the provisioned machines using Ansible, allowing up to 3 retries upon failure (e.g. APT connectivity issues, etc.):
for i in $(seq 3); do for i in $(seq 3); do
@@ -290,7 +292,8 @@ function configure() {
done done
echo echo
greenly echo "> Configuration took $(date -u -d @$(($(date +%s) - begin_conf)) +"%T")." local end_conf=$(date +%s)
greenly echo "> Configuration took $(date -u -d @$((end_conf - begin_conf)) +"%T")."
fi fi
} }
@@ -303,13 +306,16 @@ function run_tests() {
"$DIR/run_all.sh" "$@" "$DIR/run_all.sh" "$@"
local status=$? local status=$?
echo echo
greenly echo "> Tests took $(date -u -d @$(($(date +%s) - begin_tests)) +"%T")." local end_tests=$(date +%s)
greenly echo "> Tests took $(date -u -d @$((end_tests - begin_tests)) +"%T")."
return $status return $status
} }
# shellcheck disable=SC2155
function end() { function end() {
echo echo
echo "> Build took $(date -u -d @$(($(date +%s) - begin)) +"%T")." local end_time=$(date +%s)
echo "> Build took $(date -u -d @$((end_time - begin)) +"%T")."
} }
function echo_export_hosts() { function echo_export_hosts() {
+1 -1
Submodule tools updated: 310f53dc10...cf87ca33a1.
+5 -2
View File
@@ -1070,17 +1070,20 @@ create_cni_config() {
cat >"$1" <<EOF cat >"$1" <<EOF
{ {
"name": "weave", "name": "weave",
"type": "weave-net" "type": "weave-net",
"hairpinMode": $2
} }
EOF EOF
} }
setup_cni() { setup_cni() {
# if env var HAIRPIN_MODE is not set, default it to true
HAIRPIN_MODE=${HAIRPIN_MODE:-true}
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 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 create_cni_config $HOST_ROOT/etc/cni/net.d/10-weave.conf $HAIRPIN_MODE
fi fi
} }