Skip to content

Instantly share code, notes, and snippets.

@jrnt30
Forked from mikebryant/Dockerfile
Last active May 15, 2018 10:51
Show Gist options
  • Save jrnt30/6e6b94d9caa7af0c663208fabef39344 to your computer and use it in GitHub Desktop.
Save jrnt30/6e6b94d9caa7af0c663208fabef39344 to your computer and use it in GitHub Desktop.
Hacky fix for weaveworks/weave#2797
FROM mirror-hub.docker.tech.lastmile.com/alpine:3.5
RUN apk add --no-cache curl jq
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.5.3/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
COPY rmpeers /
CMD ["/rmpeers"]
#!/bin/sh
set -e
set -u
set -x
# Ensure that a failure to reach the API server short-circuits the reconciliation loop
set -o pipefail
while true; do
curl -H "Accept: application/json" http://localhost:6784/report | jq -r .IPAM.Entries[].Nickname > /tmp/nicknames
kubectl get node -o custom-columns=name:.metadata.name --no-headers > /tmp/node-names
grep -v -f /tmp/node-names /tmp/nicknames | xargs -n 1 -I '{}' curl -H "Accept: application/json" -X DELETE 'http://localhost:6784/peer/{}'
sleep 60
done
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: weave-net-rmpeers
namespace: kube-system
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
template:
metadata:
labels:
app: weave-net-rmpeers
spec:
containers:
- name: rmpeers
image: hub.docker.tech.lastmile.com/mikebryant/rmpeers:v6
resources:
requests:
cpu: "0.01"
memory: "20Mi"
limits:
cpu: "0.1"
memory: "20Mi"
volumeMounts:
- name: fence
mountPath: /unused
hostNetwork: true
volumes:
- name: fence
persistentVolumeClaim:
claimName: weave-net-rmpeers-fence
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: weave-net-rmpeers-fence
namespace: kube-system
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment