diff --git a/cluster/images/conformance/Makefile b/cluster/images/conformance/Makefile index d6177aaac3..0a7673adca 100644 --- a/cluster/images/conformance/Makefile +++ b/cluster/images/conformance/Makefile @@ -15,14 +15,18 @@ # Build the conformance image. # # Usage: -# [ARCH=amd64] [REGISTRY="staging-k8s.gcr.io"] make (build|push) VERSION={some_released_version_of_kubernetes} +# [ARCH=amd64] [REGISTRY="k8s.gcr.io"] make (build|push) VERSION={some_released_version_of_kubernetes} -REGISTRY?=staging-k8s.gcr.io +REGISTRY?=k8s.gcr.io ARCH?=amd64 OUT_DIR?=_output -GINKGO_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/ginkgo -KUBECTL_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/kubectl -E2E_TEST_BIN?=$(shell pwd)/../../../$(OUT_DIR)/dockerized/bin/linux/$(ARCH)/e2e.test + +OUTPUT_PATH=$(shell pwd)/../../../$(OUT_DIR) +BINARY_PATH=$(shell test -d $(OUTPUT_PATH)/local && echo $(OUTPUT_PATH)/local || echo $(OUTPUT_PATH)/dockerized) + +GINKGO_BIN?=$(BINARY_PATH)/bin/linux/$(ARCH)/ginkgo +KUBECTL_BIN?=$(BINARY_PATH)/bin/linux/$(ARCH)/kubectl +E2E_TEST_BIN?=$(BINARY_PATH)/bin/linux/$(ARCH)/e2e.test CLUSTER_DIR?=$(shell pwd)/../../../cluster/ BASEIMAGE=k8s.gcr.io/debian-hyperkube-base-$(ARCH):0.12.1 diff --git a/cluster/images/conformance/README.md b/cluster/images/conformance/README.md index 3f8d5954bc..b5df5e8c1d 100644 --- a/cluster/images/conformance/README.md +++ b/cluster/images/conformance/README.md @@ -6,63 +6,36 @@ #### How to release by hand ```console -# First, build the binaries -$ build/run.sh make cross +# First, build the binaries by running make from the root directory +$ make WHAT="test/e2e/e2e.test vendor/github.com/onsi/ginkgo/ginkgo cmd/kubectl" # Build for linux/amd64 (default) -# export REGISTRY=$HOST/$ORG to switch from staging-k8s.gcr.io +# export REGISTRY=$HOST/$ORG to switch from k8s.gcr.io $ make push VERSION={target_version} ARCH=amd64 -# ---> staging-k8s.gcr.io/conformance-amd64:VERSION -# ---> staging-k8s.gcr.io/conformance:VERSION (image with backwards-compatible naming) +# ---> k8s.gcr.io/conformance-amd64:VERSION +# ---> k8s.gcr.io/conformance:VERSION (image with backwards-compatible naming) $ make push VERSION={target_version} ARCH=arm -# ---> staging-k8s.gcr.io/conformance-arm:VERSION +# ---> k8s.gcr.io/conformance-arm:VERSION $ make push VERSION={target_version} ARCH=arm64 -# ---> staging-k8s.gcr.io/conformance-arm64:VERSION +# ---> k8s.gcr.io/conformance-arm64:VERSION $ make push VERSION={target_version} ARCH=ppc64le -# ---> staging-k8s.gcr.io/conformance-ppc64le:VERSION +# ---> k8s.gcr.io/conformance-ppc64le:VERSION $ make push VERSION={target_version} ARCH=s390x -# ---> staging-k8s.gcr.io/conformance-s390x:VERSION +# ---> k8s.gcr.io/conformance-s390x:VERSION ``` If you don't want to push the images, run `make` or `make build` instead -#### How to setup RBAC needed +#### How to run tests ``` -kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=default:default +kubectl create -f conformance-e2e.yaml ``` -#### How to run a single test - -``` -apiVersion: v1 -kind: Pod -metadata: - name: e2e-producer-consumer-test -spec: - containers: - - name: conformance-container - image: gcr.io/heptio-images/kube-conformance:latest - image: staging-k8s.gcr.io/conformance-amd64:v1.12.1 - imagePullPolicy: IfNotPresent - env: - - name: E2E_FOCUS - value: "Pods should be submitted and removed" - volumeMounts: - - name: output-volume - mountPath: /tmp/results - volumes: - - name: output-volume - hostPath: - path: /tmp/results - restartPolicy: Never -``` - - [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/images/conformance/README.md?pixel)]() diff --git a/cluster/images/conformance/conformance-e2e.sh b/cluster/images/conformance/conformance-e2e.sh new file mode 100755 index 0000000000..45d86a258e --- /dev/null +++ b/cluster/images/conformance/conformance-e2e.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Copyright 2018 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +kubectl create -f conformance-e2e.yaml +while true; do + STATUS=$(kubectl -n conformance get pods e2e-conformance-test -o jsonpath="{.status.phase}") + timestamp=$(date +"[%H:%M:%S]") + echo "$timestamp Pod status is: ${STATUS}" + if [[ "$STATUS" == "Succeeded" ]]; then + echo "$timestamp Done." + break + else + sleep 5 + fi +done +echo "Please use 'kubectl logs -n conformance e2e-conformance-test' to view the results" diff --git a/cluster/images/conformance/conformance-e2e.yaml b/cluster/images/conformance/conformance-e2e.yaml new file mode 100644 index 0000000000..b12c485848 --- /dev/null +++ b/cluster/images/conformance/conformance-e2e.yaml @@ -0,0 +1,71 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: conformance +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + component: conformance + name: conformance-serviceaccount + namespace: conformance +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + component: conformance + name: conformance-serviceaccount-role +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: conformance-serviceaccount +subjects: +- kind: ServiceAccount + name: conformance-serviceaccount + namespace: conformance +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + component: conformance + name: conformance-serviceaccount +rules: +- apiGroups: + - '*' + resources: + - '*' + verbs: + - '*' +- nonResourceURLs: + - '/metrics' + - '/logs' + - '/logs/*' + verbs: + - 'get' +--- +apiVersion: v1 +kind: Pod +metadata: + name: e2e-conformance-test + namespace: conformance +spec: + containers: + - name: conformance-container + image: k8s.gcr.io/conformance-amd64:v1.14 + imagePullPolicy: IfNotPresent + env: + - name: E2E_FOCUS + value: "Pods should be submitted and removed" + volumeMounts: + - name: output-volume + mountPath: /tmp/results + volumes: + - name: output-volume + hostPath: + path: /tmp/results + restartPolicy: Never + serviceAccountName: conformance-serviceaccount