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

Support building images with a provided k8s version #2

Merged
merged 4 commits into from
Sep 12, 2017
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 @@ -2,3 +2,4 @@
/_cache
/e2e.test
/kubectl
/cluster
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
COPY e2e.test /usr/local/bin/
COPY kubectl /usr/local/bin/
COPY run_e2e.sh /run_e2e.sh
COPY cluster /kubernetes/cluster
WORKDIR /usr/local/bin

ENV E2E_FOCUS="Conformance"
# NOTE: kubectl tests are temporarily disabled due to the fact that they do not use the in-cluster
Expand Down
49 changes: 33 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
TARGET = kube-conformance
GOTARGET = github.com/heptio/$(TARGET)
REGISTRY ?= gcr.io/heptio-images
KVER = v1.7.3
latest_stable = 1.7
KUBE_VERSION ?= $(latest_stable)
kube_version = $(subst v,,$(KUBE_VERSION))
kube_version_full = $(shell curl -Ss https://storage.googleapis.com/kubernetes-release/release/stable-$(kube_version).txt)
IMAGE = $(REGISTRY)/$(BIN)
DOCKER ?= docker
in_docker_group=$(filter docker,$(shell groups))
is_root=$(filter 0,$(shell id -u))
DOCKER?=$(if $(or $(in_docker_group),$(is_root)),docker,sudo docker)
DIR := ${CURDIR}

.PHONY: all container getbins clean
Expand All @@ -31,25 +36,37 @@ all: container
e2e.test: getbins
kubectl: getbins

getbins: | _cache/.getbins.$(KVER).timestamp
getbins: | _cache/.getbins.$(kube_version_full).timestamp

_cache/.getbins.$(KVER).timestamp:
mkdir -p _cache/$(KVER)
curl -L -o _cache/$(KVER)/kubernetes.tar.gz http://gcsweb.k8s.io/gcs/kubernetes-release/release/$(KVER)/kubernetes.tar.gz
tar -C _cache/$(KVER) -xzf _cache/$(KVER)/kubernetes.tar.gz
cd _cache/$(KVER) && KUBERNETES_DOWNLOAD_TESTS=true KUBERNETES_SKIP_CONFIRM=true ./kubernetes/cluster/get-kube-binaries.sh
mv _cache/$(KVER)/kubernetes/platforms/linux/amd64/e2e.test ./
mv _cache/$(KVER)/kubernetes/platforms/linux/amd64/kubectl ./
rm -rf _cache/$(KVER)
_cache/.getbins.$(kube_version_full).timestamp: clean
mkdir -p _cache/$(kube_version_full)
curl -SsL -o _cache/$(kube_version_full)/kubernetes.tar.gz http://gcsweb.k8s.io/gcs/kubernetes-release/release/$(kube_version_full)/kubernetes.tar.gz
tar -C _cache/$(kube_version_full) -xzf _cache/$(kube_version_full)/kubernetes.tar.gz
cd _cache/$(kube_version_full) && KUBE_VERSION="${kube_version_full}" \
KUBERNETES_DOWNLOAD_TESTS=true \
KUBERNETES_SKIP_CONFIRM=true ./kubernetes/cluster/get-kube-binaries.sh
mv _cache/$(kube_version_full)/kubernetes/cluster ./
mv _cache/$(kube_version_full)/kubernetes/platforms/linux/amd64/e2e.test ./
mv _cache/$(kube_version_full)/kubernetes/platforms/linux/amd64/kubectl ./
rm -rf _cache/$(kube_version_full)
touch $@

container: e2e.test kubectl
$(DOCKER) build -t $(REGISTRY)/$(TARGET):latest -t $(REGISTRY)/$(TARGET):$(KVER) .
$(DOCKER) build -t $(REGISTRY)/$(TARGET):v$(kube_version) \
-t $(REGISTRY)/$(TARGET):$(kube_version_full) .
if [ "$(kube_version)" = "$(latest_stable)" ]; then \
$(DOCKER) tag $(REGISTRY)/$(TARGET):v$(kube_version) $(REGISTRY)/$(TARGET):latest; \
fi

push:
$(DOCKER) push $(REGISTRY)/$(TARGET):latest
$(DOCKER) push $(REGISTRY)/$(TARGET):$(KVER)
$(DOCKER) push $(REGISTRY)/$(TARGET):v$(kube_version)
$(DOCKER) push $(REGISTRY)/$(TARGET):$(kube_version_full)
if [ "$(kube_version)" = "$(latest_stable)" ]; then \
$(DOCKER) push $(REGISTRY)/$(TARGET):latest; \
fi

clean:
rm -rf _cache e2e.test kubectl
$(DOCKER) rmi $(REGISTRY)/$(TARGET):latest $(REGISTRY)/$(TARGET):$(KVER) || true
rm -rf _cache e2e.test kubectl cluster
$(DOCKER) rmi $(REGISTRY)/$(TARGET):latest \
$(REGISTRY)/$(TARGET):v$(kube_version) \
$(REGISTRY)/$(TARGET):$(kube_version_full) || true
4 changes: 2 additions & 2 deletions run_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

echo "/usr/local/bin/e2e.test --ginkgo.skip=\"${E2E_SKIP}\" --ginkgo.focus=\"${E2E_FOCUS}\" --provider=\"${E2E_PROVIDER}\" --report-dir=\"${RESULTS_DIR}\" --ginkgo.noColor=true"
/usr/local/bin/e2e.test --ginkgo.skip="${E2E_SKIP}" --ginkgo.focus="${E2E_FOCUS}" --provider="${E2E_PROVIDER}" --report-dir="${RESULTS_DIR}" --ginkgo.noColor=true | tee ${RESULTS_DIR}/e2e.log
echo "/usr/local/bin/e2e.test --repo-root=/kubernetes --ginkgo.skip=\"${E2E_SKIP}\" --ginkgo.focus=\"${E2E_FOCUS}\" --provider=\"${E2E_PROVIDER}\" --report-dir=\"${RESULTS_DIR}\" --ginkgo.noColor=true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is repo-root added back somehow as a hard dep in the tests? We spent a lot of time sifting through removing those deps year+ ago.

/usr/local/bin/e2e.test --repo-root=/kubernetes --ginkgo.skip="${E2E_SKIP}" --ginkgo.focus="${E2E_FOCUS}" --provider="${E2E_PROVIDER}" --report-dir="${RESULTS_DIR}" --ginkgo.noColor=true | tee ${RESULTS_DIR}/e2e.log
# tar up the results for transmission back
cd ${RESULTS_DIR}
tar -czf e2e.tar.gz *
Expand Down