Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): build mc from master, push, make pod available for testing #19

Merged
merged 12 commits into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ genssl/server.csr
genssl/server.key
genssl/server.pem
manifests/deis-minio-secretssl-final.yaml
mc/mc
27 changes: 22 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,6 +15,8 @@ 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}
MC_INTEGRATION_IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/mc-integration:${VERSION}

all: build docker-build docker-push

Expand Down Expand Up @@ -64,9 +66,24 @@ kube-clean:
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
perl -pi -e "s|image: [a-z0-9.:]+\/|image: ${DEIS_REGISTRY}/|g" manifests/deis-mc-pod.yaml
kube-mc-integration:
kubectl create -f manifests/deis-mc-integration-pod.yaml

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: ${MC_IMAGE}/|g" manifests/deis-mc-pod.yaml

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: ${MC_INTEGRATION_IMAGE}/|g" manifests/deis-mc-integration-pod.yaml

.PHONY: all build docker-compile kube-up kube-down deploy mc kube-mc
26 changes: 26 additions & 0 deletions manifests/deis-mc-integration-pod.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions manifests/deis-mc-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ metadata:
name: deis-mc
labels:
heritage: deis
version: 2015-sept
version: v2-alpha
spec:
restartPolicy: Never
containers:
- name: mc
imagePullPolicy: Always
image: smothiki/minio:v2
image: quay.io/deisci/mc:v2-alpha
command:
- 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
18 changes: 10 additions & 8 deletions mc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM golang:1.5

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 make install
FROM ubuntu-debootstrap:14.04

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
17 changes: 17 additions & 0 deletions mc/install.sh
Original file line number Diff line number Diff line change
@@ -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
71 changes: 71 additions & 0 deletions mc/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/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.
#
# TODO: probably rewrite this script in Go!

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