Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
use 'swarmctl' for 17.06 and estimate peers when we don't get ipam info
Browse files Browse the repository at this point in the history
merge fcrisciani/ip-util-check:fix-peers-list and adamancini/ip-util-check:swarmctl
  • Loading branch information
adamancini committed Feb 2, 2019
1 parent 565f27e commit e376efd
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
35 changes: 32 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
FROM ctelfer/swarmctl:latest
RUN apk add --update bash docker jq
FROM golang:1.11-alpine as build-swarmctl
WORKDIR /go/src/github.com/docker

RUN apk add --no-cache --update bash ca-certificates curl make git openssh-client
RUN git clone https://github.com/docker/swarmkit.git swarmkit && cd swarmkit && make bin/swarmctl && cp bin/swarmctl /usr/bin/swarmctl && rm -rf /go/src/github.com/docker/swarmkit

FROM alpine:3.9 as build-protoc
ARG PROTOC_VERSION=3.6.1
RUN apk add --update --no-cache unzip curl
# download and install protoc binary and .proto files
RUN curl --silent --show-error --location --output protoc.zip \
https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip \
&& unzip -d /usr/local protoc.zip include/\* bin/\* \
&& rm -f protoc.zip

FROM alpine:3.9 as build-docker
ARG DOCKER_CLIENT_VERSION=18.09.1
RUN apk add --update --no-cache curl
RUN curl -SsL --output docker.tgz \
https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_CLIENT_VERSION.tgz \
&& tar xvzf docker.tgz \
&& cp docker/docker /usr/bin/docker \
&& rm -f docker.tgz

FROM alpine:3.9
RUN apk add --no-cache --update bash jq
# WORKDIR /go/src/github.com/docker
# RUN git clone https://github.com/docker/swarmkit.git swarmkit && cd swarmkit && make bin/swarmctl && cp bin/swarmctl /usr/bin/swarmctl && rm -rf /go/src/github.com/docker/swarmkit
COPY --from=build-swarmctl /usr/bin/swarmctl /usr/bin
COPY --from=build-protoc /usr/local/. /usr/local
COPY --from=build-docker /usr/bin/docker /usr/bin
COPY ip-util-check /usr/bin
ENTRYPOINT [ "/usr/bin/ip-util-check" ]
CMD [ "/usr/bin/ip-util-check" ]
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,29 @@ The script flags several potential conditions for each overlay:
cluster size scales up to a certain number of nodes
* IP address space is allocated to > 80% capacity

#### Note:
Under certain conditions, it may not be possible to accurately
count the number of IP addresses on a network due to Docker's
networking state distribution architecture.

Gossip protocol only distributes network programming to nodes that
participate in an overlay network. A node must have a container or
service task scheduled on it attached to an overlay network to be
considered an overlay network peer. Manager nodes that are not running
workloads may not be able to accurately count the number of IP addresses
on overlay networks scheduled on worker nodes. In this case, we approximate.

Building the Container
======================
docker image build -t docker/ip-util-check .

```
docker build -t docker/ip-util-check .
```

Running the Container
=====================

docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/docker/swarm/control.sock:/var/run/swarmd.sock \
docker/ip-util-check
```
docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/run/docker/swarm/control.sock:/var/run/swarmd.sock \
docker/ip-util-check
```
9 changes: 5 additions & 4 deletions ip-util-check
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ for net in $NETS ; do
NET2NAME[$net]=$(echo $networkInspect | jq -r '.[].Name')
set +e
NET2SUB[$net]=$(echo $networkInspect | jq -r '.[].IPAM.Config[].Subnet' 2>/dev/null)
if [ -z "${NET2SUB[$net]}" ] ; then
NET2SUB[$net]=$(docker network inspect ${NET2NAME[$net]} | jq -r '.[].IPAM.Config[].Subnet' 2>/dev/null)
fi
set -e

if [ -z "${NET2SUB[$net]}" ] ; then
NET2SUB[$net]=$(/usr/bin/swarmctl network inspect ${NET2NAME[$net]} | grep Subnet | awk -F ": " '{print $2}' 2>/dev/null)
fi
set -e
NET2CAP[$net]=0
NET2NCIP[$net]=0
NET2NVIP[$net]=0
Expand Down

0 comments on commit e376efd

Please sign in to comment.