From 0a91a1d275169ca4ea1c7a14c32c6fe860cbb825 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 14:25:36 -0800 Subject: [PATCH 01/12] fix(Makefile): build and push correct mc image --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b70454e..bba342c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ export GO15VENDOREXPERIMENT=1 # Note that Minio currently uses CGO. -VERSION := 0.0.1-$(shell date "+%Y%m%d%H%M%S") +VERSION ?= 0.0.1-$(shell date "+%Y%m%d%H%M%S") LDFLAGS := "-s -X main.version=${VERSION}" BINDIR := ./rootfs/bin DEV_REGISTRY ?= $(docker-machine ip deis):5000 @@ -15,6 +15,7 @@ SVC := manifests/deis-${SHORT_NAME}-service.yaml ADMIN_SEC := manifests/deis-${SHORT_NAME}-secretAdmin.yaml USER_SEC := manifests/deis-${SHORT_NAME}-secretUser.yaml IMAGE := ${DEIS_REGISTRY}${SHORT_NAME}:${VERSION} +MC_IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/mc:${VERSION} all: build docker-build docker-push @@ -65,8 +66,8 @@ kube-mc: kubectl create -f manifests/deis-mc-pod.yaml mc: - docker build -t ${DEIS_REGISTRY}/deis/minio-mc:latest mc - docker push ${DEIS_REGISTRY}/deis/minio-mc:latest + docker build -t ${MC_IMAGE} mc + docker push ${MC_IMAGE} perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${DEIS_REGISTRY}/|g" manifests/deis-mc-pod.yaml .PHONY: all build docker-compile kube-up kube-down deploy mc kube-mc From e7b673360a166cbac9bdbd84b33d47e51d352578 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 14:38:38 -0800 Subject: [PATCH 02/12] fix(deis-mc-pod.yaml): point to correct mc image --- manifests/deis-mc-pod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/deis-mc-pod.yaml b/manifests/deis-mc-pod.yaml index 21cd82b..dc8fb48 100644 --- a/manifests/deis-mc-pod.yaml +++ b/manifests/deis-mc-pod.yaml @@ -11,7 +11,7 @@ spec: containers: - name: mc imagePullPolicy: Always - image: smothiki/minio:v2 + image: quay.io/deisci/mc:v2-alpha command: - mc args: From ff98e498fd8b5b685d9a9c50b38454d5f84b2339 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 14:39:03 -0800 Subject: [PATCH 03/12] fix(deis-mc-pod.yaml): set correct version --- manifests/deis-mc-pod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/deis-mc-pod.yaml b/manifests/deis-mc-pod.yaml index dc8fb48..4147c40 100644 --- a/manifests/deis-mc-pod.yaml +++ b/manifests/deis-mc-pod.yaml @@ -5,7 +5,7 @@ metadata: name: deis-mc labels: heritage: deis - version: 2015-sept + version: v2-alpha spec: restartPolicy: Never containers: From 9f30255739ef300035f12ddd1c9012bbf64db406 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 15:11:46 -0800 Subject: [PATCH 04/12] feat(Dockerfile): start compiling mc binary from source --- mc/Dockerfile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/mc/Dockerfile b/mc/Dockerfile index 3bf9cd3..e9221c7 100644 --- a/mc/Dockerfile +++ b/mc/Dockerfile @@ -1,8 +1,19 @@ -FROM golang:1.5 +FROM golang:1.5.1-alpine + +RUN apk add --update-cache curl bash make git wget && rm -rf /var/cache/apk/* -WORKDIR /go/src/github.com/minio -RUN git clone https://github.com/minio/minio -WORKDIR /go/src/github.com/minio/minio ENV GOPATH /go ENV GOROOT /usr/local/go + +RUN mkdir -p ${GOPATH}/bin +ENV PATH=/usr/local/go/bin:{$GOPATH}/bin:$PATH + +RUN mkdir -p ${GOPATH}/src/github.com/minio +WORKDIR ${GOPATH}/src/github.com/minio + +WORKDIR ${GOPATH}/src/github.com/minio +RUN curl -L -O -s https://github.com/minio/mc/archive/master.tar.gz && tar -xvzf master.tar.gz && rm master.tar.gz && mv mc-master mc +WORKDIR ${GOPATH}/src/github.com/minio/mc RUN make install + +CMD ${GOPATH}/bin/mc From 0afc9dd81209aa0a272935700eb1540d7e0b0b97 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 15:17:19 -0800 Subject: [PATCH 05/12] fix(Dockerfile): configure paths correctly --- mc/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mc/Dockerfile b/mc/Dockerfile index e9221c7..866c6f7 100644 --- a/mc/Dockerfile +++ b/mc/Dockerfile @@ -6,7 +6,7 @@ ENV GOPATH /go ENV GOROOT /usr/local/go RUN mkdir -p ${GOPATH}/bin -ENV PATH=/usr/local/go/bin:{$GOPATH}/bin:$PATH +ENV PATH=${GOROOT}/bin:${GOPATH}/bin:$PATH RUN mkdir -p ${GOPATH}/src/github.com/minio WORKDIR ${GOPATH}/src/github.com/minio From f2f469f92d4daa51537298a6b2c4356cd573d42b Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 15:52:39 -0800 Subject: [PATCH 06/12] fix(mc/Dockerfile,Makefile): install Go according to minio instructions https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13 doing the install in a script instead of inside the docker build process. Fixes part of #7, but not all of it since mc is still not alpine compatible. see that issue for more information --- .gitignore | 1 + Makefile | 1 + mc/Dockerfile | 20 ++++---------------- mc/install.sh | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 16 deletions(-) create mode 100755 mc/install.sh diff --git a/.gitignore b/.gitignore index f8d52bc..f825aad 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ genssl/server.csr genssl/server.key genssl/server.pem manifests/deis-minio-secretssl-final.yaml +mc/mc diff --git a/Makefile b/Makefile index bba342c..cef8736 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,7 @@ kube-mc: kubectl create -f manifests/deis-mc-pod.yaml mc: + docker run -e GO15VENDOREXPERIMENT=1 -e GOROOT=/usr/local/go --rm -v "${PWD}/mc":/pwd -w /pwd golang:1.5.2 ./install.sh docker build -t ${MC_IMAGE} mc docker push ${MC_IMAGE} perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${DEIS_REGISTRY}/|g" manifests/deis-mc-pod.yaml diff --git a/mc/Dockerfile b/mc/Dockerfile index 866c6f7..cb4b165 100644 --- a/mc/Dockerfile +++ b/mc/Dockerfile @@ -1,19 +1,7 @@ -FROM golang:1.5.1-alpine +FROM ubuntu-debootstrap:14.04 -RUN apk add --update-cache curl bash make git wget && rm -rf /var/cache/apk/* +RUN apt-get update -y && apt-get install -y -q ca-certificates -ENV GOPATH /go -ENV GOROOT /usr/local/go +ADD mc /bin/mc -RUN mkdir -p ${GOPATH}/bin -ENV PATH=${GOROOT}/bin:${GOPATH}/bin:$PATH - -RUN mkdir -p ${GOPATH}/src/github.com/minio -WORKDIR ${GOPATH}/src/github.com/minio - -WORKDIR ${GOPATH}/src/github.com/minio -RUN curl -L -O -s https://github.com/minio/mc/archive/master.tar.gz && tar -xvzf master.tar.gz && rm master.tar.gz && mv mc-master mc -WORKDIR ${GOPATH}/src/github.com/minio/mc -RUN make install - -CMD ${GOPATH}/bin/mc +CMD mc diff --git a/mc/install.sh b/mc/install.sh new file mode 100755 index 0000000..d7319e9 --- /dev/null +++ b/mc/install.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# This script builds the minio mc client (https://github.com/minio/mc) inside a Docker container. It should be run inside a golang:1.5.2 container, with the following environment variables set. +# +# - GOROOT=/usr/local/go +# - GO15VENDOREXPERIMENT=1 +# +# It also expects the current directory (mc/) to be mounted at /pwd, and for /pwd to be the current working directory +# +# See the 'mc' build target in the Makefile (in the parent directory) for an example of how to use this script. + +mkdir -p $GOPATH/src/github.com/minio +cd $GOPATH/src/github.com/minio +curl -L -O -s https://github.com/minio/mc/archive/master.tar.gz && tar -xvzf master.tar.gz && rm master.tar.gz && mv mc-master mc +cd mc +make install +cp $GOPATH/bin/mc /pwd/mc From 1e46d48cba190511aea25a026165de10290353b9 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 16:39:30 -0800 Subject: [PATCH 07/12] feat(Dockerfile,integration.sh,deus-mc-integration-pod.yaml): add script, target and pod for doing integration tests --- manifests/deis-mc-integration-pod.yaml | 26 ++++++++++ mc/Dockerfile | 2 + mc/integration.sh | 69 ++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 manifests/deis-mc-integration-pod.yaml create mode 100644 mc/integration.sh diff --git a/manifests/deis-mc-integration-pod.yaml b/manifests/deis-mc-integration-pod.yaml new file mode 100644 index 0000000..c79e9cd --- /dev/null +++ b/manifests/deis-mc-integration-pod.yaml @@ -0,0 +1,26 @@ +# A debugging utility for testing Minio from within k8s. +apiVersion: v1 +kind: Pod +metadata: + name: deis-mc-integration + labels: + heritage: deis + version: v2-alpha +spec: + restartPolicy: Never + containers: + - name: mc + imagePullPolicy: Always + image: quay.io/deisci/mc-integration:v2-alpha + command: + - /bin/integration.sh + args: + - "mode memory limit 512MB" + volumeMounts: + - name: minio-user + mountPath: /var/run/secrets/deis/minio/user + readOnly: true + volumes: + - name: minio-user + secret: + secretName: minio-user diff --git a/mc/Dockerfile b/mc/Dockerfile index cb4b165..79b17f7 100644 --- a/mc/Dockerfile +++ b/mc/Dockerfile @@ -4,4 +4,6 @@ RUN apt-get update -y && apt-get install -y -q ca-certificates ADD mc /bin/mc +ADD ./integration.sh /bin/integration.sh + CMD mc diff --git a/mc/integration.sh b/mc/integration.sh new file mode 100644 index 0000000..4260e9b --- /dev/null +++ b/mc/integration.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# This script provides a simple integration test against the minio server (https://github.com/minio/minio). +# It uses the Minio 'mc' client (https://github.com/minio/mc) to do all its work. +# +# It's intended to be run inside a Docker container running an image built with the Dockerfile in this directory. +# The 'mc' target in the Makefile (in the parent directory) builds such an image. +# Finally, this script expects to run in a Kubernetes cluster with a Minio replication controller or pod running and a service called +# "deis-minio" running in front of running in front of it. +# +# You can launch this script by running 'make mc-integration' from the parent directory. + +SECRET_PREFIX="/var/run/secrets/deis/minio/user" +ACCESS_KEY_FILE="$SECRET_PREFIX/access-key-id" +ACCESS_SECRET_FILE="$SECRET_PREFIX/access-secret-key" + +if [ -z "$DEIS_MINIO_SERVICE_HOST" ]; then + echo "ERROR: no DEIS_MINIO_SERVICE_HOST env var " + exit 1 +elif [ -z "$DEIS_MINIO_SERVICE_PORT" ]; then + echo "ERROR: no DEIS_MINIO_SERVICE_PORT env var" + exit 1 +fi + +if ! [ -e $ACCESS_KEY_FILE ]; then + echo "ERROR: no access key file found at $ACCESS_KEY_FILE" + exit 1 +elif ! [ -e $ACCESS_SECRET_FILE ]; then + echo "ERROR: no access secret file found at $ACCESS_SECRET_FILE" + exit 1 +fi + +FULL_HOST="http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" +BUCKET=mybucket +ACCESS_KEY=`cat $ACCESS_KEY_FILE` +ACCESS_SECRET=`cat $ACCESS_SECRET_FILE` +mc config host add $FULL_HOST $ACCESS_KEY $ACCESS_SECRET + +echo "mc mb $FULL_HOST/$BUCKET" +MB_OUT=$(mc mb $FULL_HOST/$BUCKET) +if [ $? -ne 0 ]; then + echo "FAIL: exit code $?" + exit 1 +elif [ -z "$MB_OUT" ]; then + echo "FAIL: no output" + exit 1 +fi +echo "$MB_OUT" + +echo "abc" > file.txt + +echo "mc cp file.txt $FULL_HOST/$BUCKET/file.txt" +CP_OUT=$(mc cp file.txt $FULL_HOST/$BUCKET/file.txt) +if [ $? -ne 0 ]; then + echo "FAIL: exit code $?" + exit 1 +elif [ -z "$CP_OUT" ]; then + echo "FAIL: no output" + exit 1 +fi + +FILE=$(mc cat $FULL_HOST/$BUCKET/file.txt) +if [ $? -ne 0 ]; then + echo "FAIL: exit code $?" + exit 1 +elif [ -z "$FILE" ]; + echo "FAIL: no output" + exit 1 +fi From 5fd8502e74800bbd7972f32b624dcafc5f612330 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 16:40:06 -0800 Subject: [PATCH 08/12] feat(Makefile): add targets for creating and running mc integration tests --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index cef8736..7a1c601 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ ADMIN_SEC := manifests/deis-${SHORT_NAME}-secretAdmin.yaml USER_SEC := manifests/deis-${SHORT_NAME}-secretUser.yaml IMAGE := ${DEIS_REGISTRY}${SHORT_NAME}:${VERSION} MC_IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/mc:${VERSION} +MC_INTEGRATION_IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/mc-integration:${VERSION} all: build docker-build docker-push @@ -65,10 +66,18 @@ kube-clean: kube-mc: kubectl create -f manifests/deis-mc-pod.yaml +kube-mc-integration: + kubectl create -f manifests/deis-mc-integration-pod.yaml + mc: docker run -e GO15VENDOREXPERIMENT=1 -e GOROOT=/usr/local/go --rm -v "${PWD}/mc":/pwd -w /pwd golang:1.5.2 ./install.sh docker build -t ${MC_IMAGE} mc docker push ${MC_IMAGE} perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${DEIS_REGISTRY}/|g" manifests/deis-mc-pod.yaml +mc-integration: mc + docker build -t ${MC_INTEGRATION_IMAGE} mc + docker push ${MC_INTEGRATION_IMAGE} + perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${DEIS_REGISTRY}/|g" manifests/deis-mc-integration-pod.yaml + .PHONY: all build docker-compile kube-up kube-down deploy mc kube-mc From 8a11497d005a5aade7d36d406cd4cbfb5a77b48e Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 16:40:29 -0800 Subject: [PATCH 09/12] fix(deis-mc-pod.yaml): mount secrets for minio in mc pod --- manifests/deis-mc-pod.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/manifests/deis-mc-pod.yaml b/manifests/deis-mc-pod.yaml index 4147c40..476e73c 100644 --- a/manifests/deis-mc-pod.yaml +++ b/manifests/deis-mc-pod.yaml @@ -16,3 +16,11 @@ spec: - mc args: - "mode memory limit 512MB" + volumeMounts: + - name: minio-user + mountPath: /var/run/secrets/deis/minio/user + readOnly: true + volumes: + - name: minio-user + secret: + secretName: minio-user From 23ea8f94c9d135d43c7cd0b3c3586b44f2de88a2 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 16:49:23 -0800 Subject: [PATCH 10/12] fix(Dockerfile): make integration script executable --- mc/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/mc/Dockerfile b/mc/Dockerfile index 79b17f7..a80d973 100644 --- a/mc/Dockerfile +++ b/mc/Dockerfile @@ -5,5 +5,6 @@ RUN apt-get update -y && apt-get install -y -q ca-certificates ADD mc /bin/mc ADD ./integration.sh /bin/integration.sh +RUN chmod +x /bin/integration.sh CMD mc From bb41e98a52b1f9bf4c1f127d7eee75757684263a Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 16:57:24 -0800 Subject: [PATCH 11/12] doc(integration.sh): add shameless plug --- mc/integration.sh | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 mc/integration.sh diff --git a/mc/integration.sh b/mc/integration.sh old mode 100644 new mode 100755 index 4260e9b..ed962ef --- a/mc/integration.sh +++ b/mc/integration.sh @@ -9,6 +9,8 @@ # "deis-minio" running in front of running in front of it. # # You can launch this script by running 'make mc-integration' from the parent directory. +# +# TODO: probably rewrite this script in Go! SECRET_PREFIX="/var/run/secrets/deis/minio/user" ACCESS_KEY_FILE="$SECRET_PREFIX/access-key-id" From fc5f0a88bc608894a1aebd9c6cf443279933f6d7 Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Tue, 8 Dec 2015 16:57:56 -0800 Subject: [PATCH 12/12] feat(Makefile): add targets for mc integration and split up mc targets --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 7a1c601..cc12693 100644 --- a/Makefile +++ b/Makefile @@ -69,15 +69,21 @@ kube-mc: kube-mc-integration: kubectl create -f manifests/deis-mc-integration-pod.yaml -mc: +build-mc: docker run -e GO15VENDOREXPERIMENT=1 -e GOROOT=/usr/local/go --rm -v "${PWD}/mc":/pwd -w /pwd golang:1.5.2 ./install.sh + +docker-build-mc: docker build -t ${MC_IMAGE} mc + +docker-push-mc: docker push ${MC_IMAGE} - perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${DEIS_REGISTRY}/|g" manifests/deis-mc-pod.yaml + perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${MC_IMAGE}/|g" manifests/deis-mc-pod.yaml -mc-integration: mc +docker-build-mc-integration: docker build -t ${MC_INTEGRATION_IMAGE} mc + +docker-push-mc-integration: docker push ${MC_INTEGRATION_IMAGE} - perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${DEIS_REGISTRY}/|g" manifests/deis-mc-integration-pod.yaml + perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${MC_INTEGRATION_IMAGE}/|g" manifests/deis-mc-integration-pod.yaml .PHONY: all build docker-compile kube-up kube-down deploy mc kube-mc