diff --git a/.gitignore b/.gitignore index 488fc5f281..2b5f8acf32 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ dist/*.tar.gz dist/flanneld* dist/iptables-* dist/libpthread* +dist/ld64* +dist/libc* dist/*.aci dist/*.docker cover.out diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index d3be5f988c..11948d0426 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -1,10 +1,12 @@ -FROM busybox:1.25.0-glibc +FROM frolvlad/alpine-glibc MAINTAINER Tom Denham -COPY dist/flanneld-amd64 /opt/bin/flanneld -COPY dist/iptables-amd64 /usr/local/bin/iptables +ENV FLANNEL_ARCH=amd64 + +COPY dist/flanneld-$FLANNEL_ARCH /opt/bin/flanneld +COPY dist/iptables-$FLANNEL_ARCH /usr/local/bin/iptables COPY dist/mk-docker-opts.sh /opt/bin/ -COPY dist/libpthread.so.0-amd64 /lib/libpthread.so.0 + CMD ["/opt/bin/flanneld"] diff --git a/Dockerfile.arm b/Dockerfile.arm index d0d56a0259..98f8df03f8 100644 --- a/Dockerfile.arm +++ b/Dockerfile.arm @@ -2,8 +2,14 @@ FROM armel/busybox:glibc MAINTAINER Tom Denham -COPY dist/flanneld-arm /opt/bin/flanneld -COPY dist/iptables-arm /usr/local/bin/iptables +ENV FLANNEL_ARCH=arm + +COPY dist/flanneld-$FLANNEL_ARCH /opt/bin/flanneld +COPY dist/iptables-$FLANNEL_ARCH /usr/local/bin/iptables COPY dist/mk-docker-opts.sh /opt/bin/ -COPY dist/libpthread.so.0-arm /lib/libpthread.so.0 +COPY dist/libpthread.so.0-$FLANNEL_ARCH /lib/libpthread.so.0 +COPY dist/ld64.so.1-$FLANNEL_ARCH /lib/ld64.so.1 +COPY dist/libc.so.6-$FLANNEL_ARCH /lib/libc.so.6 + + CMD ["/opt/bin/flanneld"] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 6413b7891b..21ed72ab2d 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -2,9 +2,11 @@ FROM aarch64/busybox:glibc MAINTAINER Tom Denham -COPY dist/flanneld-arm64 /opt/bin/flanneld -COPY dist/iptables-arm64 /usr/local/bin/iptables -COPY dist/mk-docker-opts.sh /opt/bin/ -COPY dist/libpthread.so.0-arm64 /lib/libpthread.so.0 -CMD ["/opt/bin/flanneld"] +ENV FLANNEL_ARCH=arm64 +COPY dist/flanneld-$FLANNEL_ARCH /opt/bin/flanneld +COPY dist/iptables-$FLANNEL_ARCH /usr/local/bin/iptables +COPY dist/mk-docker-opts.sh /opt/bin/ +COPY dist/libpthread.so.0-$FLANNEL_ARCH /lib/libpthread.so.0 +COPY dist/ld64.so.1-$FLANNEL_ARCH /lib/ld64.so.1 +COPY dist/libc.so.6-$FLANNEL_ARCH /lib/libc.so.6 diff --git a/Dockerfile.ppc64le b/Dockerfile.ppc64le index ed6ce2c8c6..0cfdae023c 100644 --- a/Dockerfile.ppc64le +++ b/Dockerfile.ppc64le @@ -2,9 +2,11 @@ FROM ppc64le/busybox:glibc MAINTAINER Tom Denham -COPY dist/flanneld-ppc64le /opt/bin/flanneld -COPY dist/iptables-ppc64le /usr/local/bin/iptables -COPY dist/mk-docker-opts.sh /opt/bin/ -COPY dist/libpthread.so.0-ppc64le /lib/libpthread.so.0 -CMD ["/opt/bin/flanneld"] +ENV FLANNEL_ARCH=ppc64le +COPY dist/flanneld-$FLANNEL_ARCH /opt/bin/flanneld +COPY dist/iptables-$FLANNEL_ARCH /usr/local/bin/iptables +COPY dist/mk-docker-opts.sh /opt/bin/ +COPY dist/libpthread.so.0-$FLANNEL_ARCH /lib/libpthread.so.0 +COPY dist/ld64.so.1-$FLANNEL_ARCH /lib/ld64.so.1 +COPY dist/libc.so.6-$FLANNEL_ARCH /lib/libc.so.6 diff --git a/Dockerfile.s390x b/Dockerfile.s390x new file mode 100644 index 0000000000..6d5d3eed9e --- /dev/null +++ b/Dockerfile.s390x @@ -0,0 +1,14 @@ +FROM s390x/busybox:glibc + +MAINTAINER Tom Denham + +ENV FLANNEL_ARCH=s390x + +COPY dist/flanneld-$FLANNEL_ARCH /opt/bin/flanneld +COPY dist/iptables-$FLANNEL_ARCH /usr/local/bin/iptables +COPY dist/mk-docker-opts.sh /opt/bin/ +COPY dist/libpthread.so.0-$FLANNEL_ARCH /lib/libpthread.so.0 +COPY dist/ld64.so.1-$FLANNEL_ARCH /lib/ld64.so.1 +COPY dist/libc.so.6-$FLANNEL_ARCH /lib/libc.so.6 + +CMD ["/opt/bin/flanneld"] diff --git a/Documentation/kube-flannel-rbac.yml b/Documentation/kube-flannel-rbac.yml index 9f328b2db7..d66465cdd4 100644 --- a/Documentation/kube-flannel-rbac.yml +++ b/Documentation/kube-flannel-rbac.yml @@ -20,8 +20,13 @@ rules: - nodes verbs: - list - - update - watch + - apiGroups: + - "" + resources: + - nodes/status + verbs: + - patch --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1beta1 diff --git a/Makefile b/Makefile index 7c09ba2b71..8f5ecfe5e5 100644 --- a/Makefile +++ b/Makefile @@ -15,23 +15,30 @@ PACKAGES_EXPANDED=$(PACKAGES:%=github.com/coreos/flannel/%) # Set the (cross) compiler to use for different architectures ifeq ($(ARCH),amd64) - LIB_DIR=x86_64-linux-gnu + LIB_DIR=/lib/x86_64-linux-gnu CC=gcc endif ifeq ($(ARCH),arm) - LIB_DIR=arm-linux-gnueabi - CC=arm-linux-gnueabi-gcc + LIB_DIR=/usr/arm-linux-gnueabihf/lib + CC=arm-linux-gnueabihf-gcc endif ifeq ($(ARCH),arm64) - LIB_DIR=aarch64-linux-gnu + LIB_DIR=/usr/aarch64-linux-gnu/lib CC=aarch64-linux-gnu-gcc endif ifeq ($(ARCH),ppc64le) - LIB_DIR=powerpc64le-linux-gnu + LIB_DIR=/usr/powerpc64le-linux-gnu/lib CC=powerpc64le-linux-gnu-gcc endif -GOARM=6 -KUBE_CROSS_TAG=v1.6.2-2 +ifeq ($(ARCH),s390x) + LIB_DIR=s390x-linux-gnu + CC=s390x-linux-gnu-gcc +endif + +GOARM=7 + +# List images with gcloud alpha container images list-tags gcr.io/google_containers/kube-cross +KUBE_CROSS_TAG=v1.7.5-3 IPTABLES_VERSION=1.4.21 dist/flanneld: $(shell find . -type f -name '*.go') @@ -97,7 +104,7 @@ endif ## Build an architecture specific flanneld binary dist/flanneld-$(ARCH): # Build for other platforms with 'ARCH=$$ARCH make dist/flanneld-$$ARCH' - # valid values for $$ARCH are [amd64 arm arm64 ppc64le] + # valid values for $$ARCH are [amd64 arm arm64 ppc64le s390x] docker run -e CC=$(CC) -e GOARM=$(GOARM) -e GOARCH=$(ARCH) \ -u $(shell id -u):$(shell id -g) \ -v $(CURDIR):/go/src/github.com/coreos/flannel:ro \ @@ -108,9 +115,11 @@ dist/flanneld-$(ARCH): mv dist/flanneld dist/flanneld-$(ARCH) && \ file dist/flanneld-$(ARCH)' -## Busybox images are missing pthread. Pull it out of the kube-cross image -dist/libpthread.so.0-$(ARCH): - docker run --rm -v `pwd`:/host gcr.io/google_containers/kube-cross:$(KUBE_CROSS_TAG) cp /lib/$(LIB_DIR)/libpthread.so.0 /host/dist/libpthread.so.0-$(ARCH) +## Busybox images need updated libs. Pull them out of the kube-cross image +dist/libpthread.so.0-$(ARCH) dist/libc.so.6-$(ARCH) dist/ld64.so.1-$(ARCH): + docker run --rm -v $(CURDIR):/host gcr.io/google_containers/kube-cross:$(KUBE_CROSS_TAG) cp $(LIB_DIR)/libc-2.23.so /host/dist/libc.so.6-$(ARCH) + docker run --rm -v $(CURDIR):/host gcr.io/google_containers/kube-cross:$(KUBE_CROSS_TAG) cp $(LIB_DIR)/ld-2.23.so /host/dist/ld64.so.1-$(ARCH) + docker run --rm -v $(CURDIR):/host gcr.io/google_containers/kube-cross:$(KUBE_CROSS_TAG) cp $(LIB_DIR)/libpthread.so.0 /host/dist/libpthread.so.0-$(ARCH) ## Build an architecture specific iptables binary dist/iptables-$(ARCH): @@ -148,6 +157,9 @@ tar.gz: ARCH=arm64 make dist/flanneld-arm64 tar --transform='flags=r;s|-arm64||' -zcvf dist/flannel-$(TAG)-linux-arm64.tar.gz -C dist flanneld-arm64 mk-docker-opts.sh ../README.md tar -tvf dist/flannel-$(TAG)-linux-arm64.tar.gz + ARCH=s390x make dist/flanneld-s390x + tar --transform='flags=r;s|-s390x||' -zcvf dist/flannel-$(TAG)-linux-s390x.tar.gz -C dist flanneld-s390x mk-docker-opts.sh ../README.md + tar -tvf dist/flannel-$(TAG)-linux-s390x.tar.gz ## Make a release after creating a tag release: tar.gz @@ -155,6 +167,7 @@ release: tar.gz ARCH=arm make dist/flanneld-$(TAG)-arm.aci ARCH=arm64 make dist/flanneld-$(TAG)-arm64.aci ARCH=ppc64le make dist/flanneld-$(TAG)-ppc64le.aci + ARCH=s390x make dist/flanneld-$(TAG)-s390x.aci @echo "Everything should be built for $(TAG)" @echo "Add all *.aci, flanneld-* and *.tar.gz files from dist/ to the Github release" @echo "Use make docker-push-all to push the images to a registry" @@ -164,6 +177,7 @@ docker-push-all: ARCH=arm make docker-push ARCH=arm64 make docker-push ARCH=ppc64le make docker-push + ARCH=s390x make docker-push flannel-git: ARCH=amd64 REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-amd64.docker docker-push @@ -172,3 +186,4 @@ flannel-git: ARCH=arm REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-arm.docker docker-push ARCH=arm64 REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-arm64.docker docker-push ARCH=ppc64le REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-ppc64le.docker docker-push + ARCH=s390x REGISTRY=quay.io/coreos/flannel-git make clean dist/flanneld-$(TAG)-s390x.docker docker-push diff --git a/subnet/kube/kube.go b/subnet/kube/kube.go index 9d38502797..5261da8aea 100644 --- a/subnet/kube/kube.go +++ b/subnet/kube/kube.go @@ -29,12 +29,14 @@ import ( "github.com/golang/glog" "golang.org/x/net/context" "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/client/cache" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/controller/framework" "k8s.io/kubernetes/pkg/runtime" utilruntime "k8s.io/kubernetes/pkg/util/runtime" + "k8s.io/kubernetes/pkg/util/strategicpatch" "k8s.io/kubernetes/pkg/util/wait" "k8s.io/kubernetes/pkg/watch" ) @@ -231,7 +233,31 @@ func (ksm *kubeSubnetManager) AcquireLease(ctx context.Context, network string, n.Annotations[backendDataAnnotation] = string(bd) n.Annotations[backendPublicIPAnnotation] = attrs.PublicIP.String() n.Annotations[subnetKubeManagedAnnotation] = "true" - n, err = ksm.client.Core().Nodes().Update(n) + + var oldNode, newNode v1.Node + if err := api.Scheme.Convert(cacheNode, &oldNode, nil); err != nil { + return nil, err + } + if err := api.Scheme.Convert(n, &newNode, nil); err != nil { + return nil, err + } + + oldData, err := json.Marshal(oldNode) + if err != nil { + return nil, err + } + + newData, err := json.Marshal(newNode) + if err != nil { + return nil, err + } + + patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldData, newData, v1.Node{}) + if err != nil { + return nil, fmt.Errorf("failed to create patch for node %q: %v", ksm.nodeName, err) + } + + _, err = ksm.client.Core().Nodes().Patch(ksm.nodeName, api.StrategicMergePatchType, patchBytes, "status") if err != nil { return nil, err }