-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make general and k8s specific versions of pj-on-kind.sh.
Also switches to building mkpj and mkpod with go instead of bazel.
- Loading branch information
Showing
4 changed files
with
122 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
pj.yaml | ||
pod.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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. | ||
|
||
# Runs prow/pj-on-kind.sh with config arguments specific to the prow.k8s.io instance. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
export CONFIG_PATH="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../prow/config.yaml)" | ||
export JOB_CONFIG_PATH="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/jobs)" | ||
bash <(curl -s https://raw.githubusercontent.com/cjwagner/test-infra/local-pod-go/prow/pj-on-kind.sh) "$@" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 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. | ||
|
||
# Requires go, docker, and kubectl. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# Prep and check args. | ||
job=${1:-""} | ||
config=${CONFIG_PATH:-""} | ||
job_config=${JOB_CONFIG_PATH:-""} | ||
out_dir=${OUT_DIR:-/tmp/prowjob-out} | ||
|
||
echo job=${job} | ||
echo CONFIG_PATH=${config} | ||
echo JOB_CONFIG_PATH=${job_config} | ||
echo OUT_DIR=${out_dir} "(May be different when reusing an existing kind cluster.)" | ||
|
||
if [[ -z ${job} ]] | ||
then | ||
echo "Must specify a job name as the first argument." | ||
exit 2 | ||
fi | ||
if [[ -z ${config} ]] | ||
then | ||
echo "Must specify config.yaml location via CONFIG_PATH env var." | ||
exit 2 | ||
fi | ||
if [[ -n ${job_config} ]] | ||
then | ||
job_config="--job-config-path=${job_config}" | ||
fi | ||
|
||
# Install kind and set up cluster if not already done. | ||
if [[ -z $(which kind) ]] | ||
then | ||
GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0 && kind create cluster | ||
fi | ||
found="false" | ||
for clust in $(kind get clusters) | ||
do | ||
if [[ ${clust} == "mkpod" ]] | ||
then | ||
found="true" | ||
fi | ||
done | ||
if [[ ${found} == "false" ]] | ||
then | ||
# Create config file | ||
cat <<EOF >> ${PWD}/kind-config.yaml | ||
kind: Cluster | ||
apiVersion: kind.sigs.k8s.io/v1alpha3 | ||
nodes: | ||
- extraMounts: | ||
- containerPath: /output | ||
hostPath: ${out_dir} | ||
EOF | ||
|
||
kind create cluster --name=mkpod --config=${PWD}/kind-config.yaml --wait=5m | ||
rm ${PWD}/kind-config.yaml | ||
fi | ||
export KUBECONFIG="$(kind get kubeconfig-path --name="mkpod")" | ||
|
||
# Install mkpj and mkpod if not already done. | ||
if [[ -z $(which mkpj) ]] | ||
then | ||
go get k8s.io/test-infra/prow/cmd/mkpj | ||
fi | ||
if [[ -z $(which mkpod) ]] | ||
then | ||
go get k8s.io/test-infra/prow/cmd/mkpod | ||
fi | ||
|
||
# Generate PJ and Pod. | ||
mkpj --config-path=${config} ${job_config} --job=${job} > ${PWD}/pj.yaml | ||
mkpod --build-id=snowflake --prow-job=${PWD}/pj.yaml --local --out-dir=/output/${job} > ${PWD}/pod.yaml | ||
|
||
# Deploy pod and watch. | ||
pod=$(kubectl apply -f ${PWD}/pod.yaml | cut -d ' ' -f 1) | ||
kubectl get ${pod} -w |