Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
40 changes: 32 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
make completions-generation
hack/tree_status.sh

build-static:
build-static-amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -138,23 +138,47 @@ jobs:
- run: result/bin/crio version
- uses: actions/upload-artifact@v2
with:
name: build-static
name: build-static-amd64
path: |
result/bin/crio
result/bin/crio-status
result/bin/pinns

bundle:
build-static-arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v12
- uses: cachix/cachix-action@v8
with:
name: cri-o-static
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix-build nix/default-arm64.nix
- run: file result/bin/crio
- uses: actions/upload-artifact@v2
with:
name: build-static-arm64
path: |
result/bin/crio
result/bin/crio-status
result/bin/pinns

bundles:
runs-on: ubuntu-latest
needs:
- build
- build-static
- build-static-amd64
- build-static-arm64
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: build-static
path: bin/static
name: build-static-amd64
path: bin/static-amd64
- uses: actions/download-artifact@v2
with:
name: build-static-arm64
path: bin/static-arm64
- uses: actions/download-artifact@v2
with:
name: docs
Expand All @@ -163,15 +187,15 @@ jobs:
with:
name: config
- run: chmod -R +x bin
- run: make bundle
- run: make bundles
- uses: actions/upload-artifact@v2
with:
name: bundle
path: build/bundle/*.tar.gz

bundle-test:
runs-on: ubuntu-latest
needs: bundle
needs: bundles
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ bundle:
bundle-test:
sudo contrib/bundle/test

bundles:
contrib/bundle/build amd64
contrib/bundle/build arm64

install: .gopathok install.bin install.man install.completions install.systemd install.config

install.bin-nobuild:
Expand Down Expand Up @@ -486,6 +490,7 @@ metrics-exporter: bin/metrics-exporter
git-validation \
binaries \
bundle \
bundles \
bundle-test \
build-static \
clean \
Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,44 @@ up a PR and add it to the list.
## Getting started

### Installing CRI-O

To install `CRI-O`, you can follow our [installation guide](install.md).
Alternatively, if you'd rather build `CRI-O` from source, checkout our [setup
guide](install.md#build-and-install-cri-o-from-source).
We also provide a way in building [static binaries of `CRI-O`](install.md#static-builds) via nix.
Those binaries are available for every successfully built commit on our [Google Cloud Storage Bucket][bucket].
This means that the latest commit can be downloaded via:
This means that the latest commit can be installed via our convinience script:

[bucket]: https://console.cloud.google.com/storage/browser/k8s-conform-cri-o/artifacts

```shell
> curl -f https://storage.googleapis.com/k8s-conform-cri-o/artifacts/crio-$(git ls-remote https://github.com/cri-o/cri-o master | cut -c1-9).tar.gz -o crio.tar.gz
> curl https://raw.githubusercontent.com/cri-o/cri-o/master/scripts/get | bash
```

Beside `amd64` we also support the `arm64` bit architecture. This can be
selected via the script, too:

```shell
> curl https://raw.githubusercontent.com/cri-o/cri-o/master/scripts/get | bash -s -- -a arm64
```

It is also possible to select a specific git SHA or tag by:

```shell
> curl https://raw.githubusercontent.com/cri-o/cri-o/master/scripts/get | bash -s -- -t v1.21.0
```

The above script resolves to the download URL of the static binary bundle
tarball matching the format:

```
https://storage.googleapis.com/k8s-conform-cri-o/artifacts/cri-o.$ARCH.$REV.tar.gz
```

where `$ARCH` can be `amd64` or `arm64` and `$REV` can be any git SHA or tag.
Please be aware that using the latest `master` SHA might cause a race, because
the CI has not finished publishing the artifacts yet or failed.

### Running kubernetes with CRI-O

Before you begin, you'll need to [start CRI-O](install.md#starting-cri-o)
Expand Down
4 changes: 4 additions & 0 deletions contrib/bundle/10-crun.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[crio.runtime]
default_runtime = "crun"

[crio.runtime.runtimes.crun]
8 changes: 8 additions & 0 deletions contrib/bundle/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ZSHINSTALLDIR ?= $(PREFIX)/share/zsh/site-functions
SYSTEMDDIR ?= $(PREFIX)/lib/systemd/system
OPT_CNI_BIN_DIR ?= /opt/cni/bin

ARCH ?= amd64

all: install

.PHONY: install
Expand Down Expand Up @@ -49,6 +51,7 @@ install-crio:
install $(SELINUX) -D -m 644 -t $(ETCDIR) etc/crictl.yaml
install $(SELINUX) -D -m 644 -t $(OCIDIR) etc/crio-umount.conf
install $(SELINUX) -D -m 644 -t $(ETCDIR)/crio etc/crio.conf
install $(SELINUX) -D -m 644 -t $(ETCDIR)/crio/crio.conf.d etc/10-crun.conf
install $(SELINUX) -D -m 644 -t $(MANDIR)/man5 man/crio.conf.5
install $(SELINUX) -D -m 644 -t $(MANDIR)/man5 man/crio.conf.d.5
install $(SELINUX) -D -m 644 -t $(MANDIR)/man8 man/crio-status.8
Expand All @@ -65,7 +68,9 @@ install-pinns:

.PHONY: install-runc
install-runc:
ifeq ($(ARCH),amd64)
install $(SELINUX) -D -m 755 -t $(BINDIR) bin/runc
endif

.PHONY: install-crun
install-crun:
Expand Down Expand Up @@ -101,6 +106,7 @@ uninstall-crio:
rm $(ETCDIR)/crictl.yaml
rm $(OCIDIR)/crio-umount.conf
rm $(ETCDIR)/crio/crio.conf
rm $(ETCDIR)/crio/crio.conf.d/10-crun.conf
rm $(MANDIR)/man5/crio.conf.5
rm $(MANDIR)/man5/crio.conf.d.5
rm $(MANDIR)/man8/crio-status.8
Expand All @@ -117,7 +123,9 @@ uninstall-pinns:

.PHONY: uninstall-runc
uninstall-runc:
ifeq ($(ARCH),amd64)
rm $(BINDIR)/runc
endif

.PHONY: uninstall-crun
uninstall-crun:
Expand Down
71 changes: 54 additions & 17 deletions contrib/bundle/build
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail

ARCH_AMD64=amd64
ARCH_ARM64=arm64

ARCH=${1:-$ARCH_AMD64}

# Global vars to be used
# shellcheck source=vars
source "$(dirname "${BASH_SOURCE[0]}")"/vars
source "$(dirname "${BASH_SOURCE[0]}")"/vars "$ARCH"

cd "$(dirname "$0")"

Expand All @@ -12,9 +17,9 @@ cd "$(dirname "$0")"
source "$GIT_ROOT/scripts/versions"

FILES_BIN=(
"$GIT_ROOT/bin/static/crio-status"
"$GIT_ROOT/bin/static/crio"
"$GIT_ROOT/bin/static/pinns"
"$GIT_ROOT/bin/static-$ARCH/crio-status"
"$GIT_ROOT/bin/static-$ARCH/crio"
"$GIT_ROOT/bin/static-$ARCH/pinns"
)
FILES_MAN=(
"$GIT_ROOT/docs/crio-status.8"
Expand All @@ -26,6 +31,7 @@ FILES_ETC=(
"$GIT_ROOT/crictl.yaml"
"$GIT_ROOT/crio-umount.conf"
"$GIT_ROOT/crio.conf"
"$GIT_ROOT/contrib/bundle/10-crun.conf"
)
FILES_CONTRIB=(
"$GIT_ROOT/contrib/cni/10-crio-bridge.conf"
Expand Down Expand Up @@ -88,6 +94,8 @@ fi

# Local assets
cp "$GIT_ROOT/contrib/bundle/Makefile" "$TMPDIR"
sed -i "s/ARCH ?= amd64/ARCH ?= $ARCH/" "$TMPDIR/Makefile"

cp "$GIT_ROOT/contrib/bundle/README.md" "$TMPDIR"

curl_to() {
Expand All @@ -97,42 +105,71 @@ TMP_BIN=$TMPDIR/bin

# conmon
curl_to "$TMP_BIN/conmon" \
https://github.com/containers/conmon/releases/download/"${VERSIONS["conmon"]}"/conmon
"https://github.com/containers/conmon/releases/download/${VERSIONS["conmon"]}/conmon.$ARCH"
chmod +x "$TMP_BIN/conmon"

# runc
curl_to "$TMP_BIN/runc" \
https://github.com/opencontainers/runc/releases/download/"${VERSIONS["runc"]}"/runc.amd64
chmod +x "$TMP_BIN/runc"
if [[ $ARCH == "$ARCH_AMD64" ]]; then
# runc
curl_to "$TMP_BIN/runc" \
"https://github.com/opencontainers/runc/releases/download/${VERSIONS["runc"]}/runc.amd64"
chmod +x "$TMP_BIN/runc"
fi

# crun
curl_to "$TMP_BIN/crun" \
https://github.com/containers/crun/releases/download/"${VERSIONS["crun"]}"/crun-"${VERSIONS["crun"]}"-linux-amd64
"https://github.com/containers/crun/releases/download/${VERSIONS["crun"]}/crun-${VERSIONS["crun"]}-linux-$ARCH"
chmod +x "$TMP_BIN/crun"

# CNI plugins
mkdir -p "$TMPDIR/cni-plugins"
set -x
curl_to - \
https://github.com/containernetworking/plugins/releases/download/"${VERSIONS["cni-plugins"]}"/cni-plugins-linux-amd64-"${VERSIONS["cni-plugins"]}".tgz |
"https://github.com/containernetworking/plugins/releases/download/${VERSIONS["cni-plugins"]}/cni-plugins-linux-$ARCH-${VERSIONS["cni-plugins"]}.tgz" |
tar xfz - -C "$TMPDIR/cni-plugins"

# crictl
curl_to - \
https://github.com/kubernetes-sigs/cri-tools/releases/download/"${VERSIONS["cri-tools"]}"/crictl-"${VERSIONS["cri-tools"]}"-linux-amd64.tar.gz |
"https://github.com/kubernetes-sigs/cri-tools/releases/download/${VERSIONS["cri-tools"]}/crictl-${VERSIONS["cri-tools"]}-linux-$ARCH.tar.gz" |
tar xfz - -C "$TMP_BIN"

# Check the architectures of the binaries
ELF_ARCH=x86-64
if [[ $ARCH == "$ARCH_ARM64" ]]; then
ELF_ARCH=aarch64
fi
for FILE in "$TMP_BIN"/*; do
if ! file "$FILE" | grep -q "$ELF_ARCH"; then
echo "$FILE is not of required arch $ELF_ARCH"
exit 1
fi
done

# Create the archive
pushd "$ARCHIVE_PATH"
rm -f "$ARCHIVE"
tar cfz "$ARCHIVE" tmp --transform s/tmp/"$BUNDLE"/
TAR_DIR=cri-o
tar cfz "$ARCHIVE" tmp --transform s/tmp/$TAR_DIR/
rm -rf "$TMPDIR"
echo "Created $ARCHIVE_PATH/$ARCHIVE"

# Test the archive
echo "Testing archive"
tar xf "$ARCHIVE"
pushd "$BUNDLE"
make DESTDIR=test
pushd $TAR_DIR
export DESTDIR=test OPT_CNI_BIN_DIR=test/opt/cni/bin
make
EXP_CNT=64
if [[ $ARCH == "$ARCH_AMD64" ]]; then
EXP_CNT=65
fi
ACT_CNT=$(find test | wc -l)
if [[ "$EXP_CNT" != "$ACT_CNT" ]]; then
echo "make install file count does not match, expected: $EXP_CNT, actual: $ACT_CNT"
exit 1
fi
make uninstall
if [[ $(find test -type f | wc -l) != 0 ]]; then
echo "make uninstall left over some files"
exit 1
fi
popd
rm -rf "$BUNDLE"
rm -rf $TAR_DIR
5 changes: 4 additions & 1 deletion contrib/bundle/test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi

# Assume we're running on this arch
ARCH=amd64

# Global vars to be used
# shellcheck source=vars
source "$(dirname "${BASH_SOURCE[0]}")"/vars
Expand All @@ -15,7 +18,7 @@ pushd "$ARCHIVE_PATH"

# Untar the bundle
tar xfvz "$ARCHIVE"
pushd "$BUNDLE"
pushd cri-o

# Install and prepare config
make install
Expand Down
5 changes: 2 additions & 3 deletions contrib/bundle/vars
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ GIT_ROOT=$(git rev-parse --show-toplevel)
ARCHIVE_PATH="$GIT_ROOT/build/bundle"
mkdir -p "$ARCHIVE_PATH"

BUNDLE=crio-$(git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)
ARCHIVE="$BUNDLE.tar.gz"
ARCH=${1:-amd64}
ARCHIVE="cri-o.$ARCH.$(git describe --tags --exact-match 2>/dev/null || git rev-parse HEAD).tar.gz"
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool.

/cc @odinuge


export BUNDLE
export ARCHIVE
Loading