forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubernetes#135 from marun/enable-build
Merging to enable rehearsal testing via openshift/release#9448
- Loading branch information
Showing
28 changed files
with
2,655 additions
and
4 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
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,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
STARTTIME=$(date +%s) | ||
source "$(dirname "${BASH_SOURCE}")/lib/init.sh" | ||
|
||
pushd "${OS_ROOT}" > /dev/null | ||
make all WHAT='cmd/kube-apiserver cmd/kube-controller-manager cmd/kube-scheduler cmd/kubelet' | ||
popd > /dev/null | ||
|
||
os::build::version::git_vars | ||
|
||
if [[ "${OS_GIT_TREE_STATE:-dirty}" == "clean" ]]; then | ||
# only when we are building from a clean state can we claim to | ||
# have created a valid set of binaries that can resemble a release | ||
mkdir -p "${OS_OUTPUT_RELEASEPATH}" | ||
echo "${OS_GIT_COMMIT}" > "${OS_OUTPUT_RELEASEPATH}/.commit" | ||
fi | ||
|
||
ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret" |
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,129 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script generates release zips and RPMs into _output/releases. | ||
# All build dependencies are required on the host. The build will be | ||
# performed by the upstream makefile called by from the spec file. | ||
source "$(dirname "${BASH_SOURCE}")/lib/init.sh" | ||
|
||
# Only build linux by default. Clearing this value will build all platforms | ||
OS_ONLY_BUILD_PLATFORMS="${OS_ONLY_BUILD_PLATFORMS:-linux/amd64}" | ||
|
||
function cleanup() { | ||
return_code=$? | ||
os::util::describe_return_code "${return_code}" | ||
exit "${return_code}" | ||
} | ||
trap "cleanup" EXIT | ||
|
||
# check whether we are in a clean output state | ||
dirty="$( if [[ -d "${OS_OUTPUT}" ]]; then echo '1'; fi )" | ||
|
||
os::util::ensure::system_binary_exists rpmbuild | ||
os::util::ensure::system_binary_exists createrepo | ||
|
||
if [[ -n "${OS_BUILD_SRPM-}" ]]; then | ||
srpm="a" | ||
else | ||
srpm="b" | ||
fi | ||
|
||
os::build::rpm::get_nvra_vars | ||
|
||
OS_RPM_SPECFILE="$( find "${OS_ROOT}" -name *.spec )" | ||
OS_RPM_NAME="$( rpmspec -q --qf '%{name}\n' "${OS_RPM_SPECFILE}" | head -1 )" | ||
|
||
os::log::info "Building release RPMs for ${OS_RPM_SPECFILE} ..." | ||
|
||
rpm_tmp_dir="${BASETMPDIR}/rpm" | ||
|
||
# RPM requires the spec file be owned by the invoking user | ||
chown "$(id -u):$(id -g)" "${OS_RPM_SPECFILE}" || true | ||
|
||
if [[ -n "${dirty}" && "${OS_GIT_TREE_STATE}" == "dirty" ]]; then | ||
os::log::warning "Repository is not clean, performing fast build and reusing _output" | ||
|
||
# build and output from source to destination | ||
rm -rf "${rpm_tmp_dir}" | ||
mkdir -p "${rpm_tmp_dir}" | ||
ln -fns "${OS_ROOT}" "${rpm_tmp_dir}/SOURCES" | ||
ln -fns "${OS_ROOT}" "${rpm_tmp_dir}/BUILD" | ||
rpmbuild -bb "${OS_RPM_SPECFILE}" \ | ||
--define "_sourcedir ${rpm_tmp_dir}/SOURCES" \ | ||
--define "_builddir ${rpm_tmp_dir}/BUILD" \ | ||
--define "skip_prep 1" \ | ||
--define "skip_dist ${SKIP_DIST:-1}" \ | ||
--define "version ${OS_RPM_VERSION}" \ | ||
--define "release ${OS_RPM_RELEASE}" \ | ||
--define "commit ${OS_GIT_COMMIT}" \ | ||
--define "os_git_vars ${OS_RPM_GIT_VARS}" \ | ||
--define "_topdir ${rpm_tmp_dir}" | ||
|
||
mkdir -p "${OS_OUTPUT_RPMPATH}" | ||
mv -f "${rpm_tmp_dir}"/RPMS/*/*.rpm "${OS_OUTPUT_RPMPATH}" | ||
|
||
else | ||
rm -rf "${rpm_tmp_dir}/SOURCES" | ||
mkdir -p "${rpm_tmp_dir}/SOURCES" | ||
tar czf "${rpm_tmp_dir}/SOURCES/${OS_RPM_NAME}-${OS_RPM_VERSION}.tar.gz" \ | ||
--owner=0 --group=0 \ | ||
--exclude=_output --exclude=.git \ | ||
--transform "s|^|${OS_RPM_NAME}-${OS_RPM_VERSION}/|rSH" \ | ||
. | ||
|
||
rpmbuild -b${srpm} "${OS_RPM_SPECFILE}" \ | ||
--define "skip_dist ${SKIP_DIST:-1}" \ | ||
--define "version ${OS_RPM_VERSION}" \ | ||
--define "release ${OS_RPM_RELEASE}" \ | ||
--define "commit ${OS_GIT_COMMIT}" \ | ||
--define "os_git_vars ${OS_RPM_GIT_VARS}" \ | ||
--define "_topdir ${rpm_tmp_dir}" | ||
|
||
output_directory="$( find "${rpm_tmp_dir}" -type d -path "*/BUILD/${OS_RPM_NAME}-${OS_RPM_VERSION}/_output/local" )" | ||
if [[ -z "${output_directory}" ]]; then | ||
os::log::fatal 'No _output artifact directory found in rpmbuild artifacts!' | ||
fi | ||
|
||
# migrate the rpm artifacts to the output directory, must be clean or move will fail | ||
make clean | ||
mkdir -p "${OS_OUTPUT}" | ||
|
||
# mv exits prematurely with status 1 in the following scenario: running as root, | ||
# attempting to move a [directory tree containing a] symlink to a destination on | ||
# an NFS volume exported with root_squash set. This can occur when running this | ||
# script on a Vagrant box. The error shown is "mv: failed to preserve ownership | ||
# for $FILE: Operation not permitted". As a workaround, if | ||
# ${output_directory} and ${OS_OUTPUT} are on different devices, use cp and | ||
# rm instead. | ||
if [[ $(stat -c %d "${output_directory}") == $(stat -c %d "${OS_OUTPUT}") ]]; then | ||
mv "${output_directory}"/* "${OS_OUTPUT}" | ||
else | ||
cp -R "${output_directory}"/* "${OS_OUTPUT}" | ||
rm -rf "${output_directory}"/* | ||
fi | ||
|
||
mkdir -p "${OS_OUTPUT_RPMPATH}" | ||
if [[ -n "${OS_BUILD_SRPM-}" ]]; then | ||
mv -f "${rpm_tmp_dir}"/SRPMS/*src.rpm "${OS_OUTPUT_RPMPATH}" | ||
fi | ||
mv -f "${rpm_tmp_dir}"/RPMS/*/*.rpm "${OS_OUTPUT_RPMPATH}" | ||
fi | ||
|
||
mkdir -p "${OS_OUTPUT_RELEASEPATH}" | ||
echo "${OS_GIT_COMMIT}" > "${OS_OUTPUT_RELEASEPATH}/.commit" | ||
|
||
repo_path="$( os::util::absolute_path "${OS_OUTPUT_RPMPATH}" )" | ||
createrepo "${repo_path}" | ||
|
||
echo "[${OS_RPM_NAME}-local-release] | ||
baseurl = file://${repo_path} | ||
gpgcheck = 0 | ||
name = Release from Local Source for ${OS_RPM_NAME} | ||
enabled = 1 | ||
" > "${repo_path}/local-release.repo" | ||
|
||
# DEPRECATED: preserve until jobs migrate to using local-release.repo | ||
cp "${repo_path}/local-release.repo" "${repo_path}/origin-local-release.repo" | ||
|
||
os::log::info "Repository file for \`yum\` or \`dnf\` placed at ${repo_path}/local-release.repo | ||
Install it with: | ||
$ mv '${repo_path}/local-release.repo' '/etc/yum.repos.d" |
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,11 @@ | ||
reviewers: | ||
- smarterclayton | ||
- giuseppe | ||
- JacobTanenbaum | ||
- pweil- | ||
- pecameron | ||
- sdodson | ||
approvers: | ||
- smarterclayton | ||
- pweil- | ||
- sdodson |
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,16 @@ | ||
FROM registry.svc.ci.openshift.org/ocp/builder:golang-1.13 AS builder | ||
WORKDIR /go/src/github.com/openshift/kubernetes | ||
COPY . . | ||
RUN make WHAT='cmd/kube-apiserver cmd/kube-controller-manager cmd/kube-scheduler cmd/kubelet' && \ | ||
mkdir -p /tmp/build && \ | ||
cp openshift-build/images/hyperkube/hyperkube /tmp/build && \ | ||
cp /go/src/github.com/openshift/kubernetes/_output/local/bin/linux/$(go env GOARCH)/{kube-apiserver,kube-controller-manager,kube-scheduler,kubelet} \ | ||
/tmp/build | ||
|
||
FROM registry.svc.ci.openshift.org/ocp/4.5:base | ||
RUN yum install -y --setopt=tsflags=nodocs --setopt=skip_missing_names_on_install=False iproute && yum clean all | ||
COPY --from=builder /tmp/build/* /usr/bin/ | ||
LABEL io.k8s.display-name="OpenShift Kubernetes Server Commands" \ | ||
io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \ | ||
io.openshift.tags="openshift,hyperkube" \ | ||
io.openshift.build.versions="kubernetes=1.18.3" |
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,5 @@ | ||
reviewers: | ||
- smarterclayton | ||
- sdodson | ||
approvers: | ||
- smarterclayton |
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,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
BINS=( | ||
kube-apiserver | ||
kube-controller-manager | ||
kube-scheduler | ||
kubelet | ||
) | ||
|
||
function array_contains() { | ||
local search="$1" | ||
local element | ||
shift | ||
for element; do | ||
if [[ "${element}" == "${search}" ]]; then | ||
return 0 | ||
fi | ||
done | ||
return 1 | ||
} | ||
|
||
function print_usage() { | ||
cat <<EOF | ||
Usage: | ||
$(basename "$0") [command] | ||
Available Commands: | ||
help Help about any command | ||
kube-apiserver | ||
kube-controller-manager | ||
kube-scheduler | ||
kubelet | ||
EOF | ||
exit 0 | ||
} | ||
|
||
function main() { | ||
if [[ "$#" -lt 1 || "${1:-}" == "--help" || "${1:-}" == "help" ]]; then | ||
print_usage | ||
fi | ||
if ! array_contains "$1" "${BINS[@]}"; then | ||
echo "$1: command not supported" | ||
print_usage | ||
fi | ||
command=${1} | ||
shift | ||
if ! command -v "${command}" &>/dev/null; then | ||
echo "${command}: command not found" | ||
exit 1 | ||
fi | ||
exec "${command}" "${@}" | ||
} | ||
|
||
main "${@}" |
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,23 @@ | ||
FROM fedora:29 AS build | ||
|
||
COPY --from=registry.svc.ci.openshift.org/openshift/origin-v4.0:machine-os-content /srv/ /srv/ | ||
RUN set -x && yum install -y ostree rpm-ostree yum-utils selinux-policy-targeted && \ | ||
curl http://base-4-3-rhel8.ocp.svc > /etc/yum.repos.d/rhel8.repo && \ | ||
commit=$( find /srv -name *.commit | sed -Ee 's|.*objects/(.+)/(.+)\.commit|\1\2|' | head -1 ) && \ | ||
mkdir /tmp/working && cd /tmp/working && \ | ||
rpm-ostree db list --repo /srv/repo $commit > /tmp/packages && \ | ||
PACKAGES=(openshift-hyperkube) && \ | ||
yumdownloader -y --disablerepo=* --enablerepo=built --destdir=/tmp/rpms "${PACKAGES[@]}" && \ | ||
if ! grep -q cri-o /tmp/packages; then yumdownloader -y --disablerepo=* --enablerepo=rhel-8* --destdir=/tmp/rpms cri-o cri-tools; fi && \ | ||
if ! grep -q machine-config-daemon /tmp/packages; then yumdownloader -y --disablerepo=* --enablerepo=rhel-8* --destdir=/tmp/rpms machine-config-daemon; fi && \ | ||
ls /tmp/rpms/ && (cd /tmp/rpms/ && ls ${PACKAGES[@]/%/*}) && \ | ||
for i in $(find /tmp/rpms/ -name *.rpm); do echo "Extracting $i ..."; rpm2cpio $i | cpio -div; done && \ | ||
if [[ -d etc ]]; then mv etc usr/; fi && \ | ||
mkdir -p /tmp/tmprootfs/etc && \ | ||
ostree --repo=/srv/repo checkout -U $commit --subpath /usr/etc/selinux /tmp/tmprootfs/etc/selinux && \ | ||
ostree --repo=/srv/repo commit --parent=$commit --tree=ref=$commit --tree=dir=. \ | ||
--selinux-policy /tmp/tmprootfs \ | ||
-s "origin-ci-dev overlay RPMs" --branch=origin-ci-dev | ||
|
||
FROM scratch | ||
COPY --from=build /srv/ /srv/ |
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,16 @@ | ||
FROM registry.svc.ci.openshift.org/ocp/builder:golang-1.12 AS builder | ||
WORKDIR /go/src/github.com/openshift/origin | ||
COPY . . | ||
RUN make build WHAT=cmd/openshift-tests; \ | ||
mkdir -p /tmp/build; \ | ||
cp /go/src/github.com/openshift/origin/_output/local/bin/linux/$(go env GOARCH)/openshift-tests /tmp/build/openshift-tests | ||
|
||
FROM registry.svc.ci.openshift.org/ocp/4.2:cli | ||
COPY --from=builder /tmp/build/openshift-tests /usr/bin/ | ||
RUN yum install --setopt=tsflags=nodocs -y git gzip util-linux && yum clean all && rm -rf /var/cache/yum/* && \ | ||
git config --system user.name test && \ | ||
git config --system user.email test@test.com && \ | ||
chmod g+w /etc/passwd | ||
LABEL io.k8s.display-name="OpenShift End-to-End Tests" \ | ||
io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \ | ||
io.openshift.tags="openshift,tests,e2e" |
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,5 @@ | ||
reviewers: | ||
- smarterclayton | ||
- sdodson | ||
approvers: | ||
- smarterclayton |
Oops, something went wrong.