Skip to content

Commit d2472ec

Browse files
committed
Add CRI release build
Add installation scripts needed to generate CRI + CNI tar package on release. Update Github action release script to generate CRI release tarballs for Linux and Windows. Signed-off-by: Derek McGowan <derek@mcg.dev>
1 parent 1c7312e commit d2472ec

File tree

5 files changed

+219
-19
lines changed

5 files changed

+219
-19
lines changed

.github/workflows/release.yml

Lines changed: 99 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,18 @@ jobs:
6666

6767
- name: Set env
6868
shell: bash
69+
env:
70+
MOS: ${{ matrix.os }}
6971
run: |
7072
releasever=${{ github.ref }}
7173
releasever="${releasever#refs/tags/}"
74+
os=linux
75+
[[ "${MOS}" =~ "windows" ]] && {
76+
os=windows
77+
}
7278
echo "::set-env name=RELEASE_VER::${releasever}"
7379
echo "::set-env name=GOPATH::${{ github.workspace }}"
80+
echo "::set-env name=OS::${os}"
7481
echo "::add-path::${{ github.workspace }}/bin"
7582
7683
- name: Checkout containerd
@@ -79,29 +86,29 @@ jobs:
7986
repository: containerd/containerd
8087
ref: ${{ github.ref }}
8188
path: src/github.com/containerd/containerd
89+
8290
- name: HCS Shim commit
8391
id: hcsshim_commit
8492
if: startsWith(matrix.os, 'windows')
8593
shell: bash
8694
run: echo "::set-output name=sha::$(grep Microsoft/hcsshim vendor.conf | awk '{print $2}')"
8795
working-directory: src/github.com/containerd/containerd
96+
8897
- name: Checkout hcsshim source
8998
if: startsWith(matrix.os, 'windows')
9099
uses: actions/checkout@v2
91100
with:
92101
repository: Microsoft/hcsshim
93102
ref: ${{ steps.hcsshim_commit.outputs.sha }}
94103
path: src/github.com/Microsoft/hcsshim
104+
95105
- name: Make
96106
shell: bash
97-
env:
98-
MOS: ${{ matrix.os }}
99-
OS: linux
100107
run: |
101108
make build
102109
make binaries
103-
[[ "${MOS}" =~ "windows" ]] && {
104-
OS=windows
110+
rm bin/containerd-stress*
111+
[[ "${OS}" == "windows" ]] && {
105112
(
106113
bindir="$(pwd)/bin"
107114
cd ../../Microsoft/hcsshim
@@ -119,6 +126,47 @@ jobs:
119126
name: containerd-binaries-${{ matrix.os }}
120127
path: src/github.com/containerd/containerd/*.tar.gz*
121128

129+
- name: Install cri-containerd dependencies
130+
shell: bash
131+
env:
132+
RUNC_FLAVOR: runc
133+
DESTDIR: ${{ github.workspace }}/cri-release
134+
run: |
135+
mkdir ${DESTDIR}
136+
if [[ "${OS}" == "linux" ]]; then
137+
sudo install -d ${DESTDIR}/usr/local/bin
138+
sudo install -D -m 755 bin/* ${DESTDIR}/usr/local/bin
139+
sudo install -d ${DESTDIR}/opt/containerd/cluster
140+
sudo cp -r contrib/gce ${DESTDIR}/opt/containerd/cluster/
141+
sudo install -d ${DESTDIR}/etc/systemd/system
142+
sudo install -m 644 containerd.service ${DESTDIR}/etc/systemd/system
143+
echo "CONTAINERD_VERSION: '${RELEASE_VER#v}'" | sudo tee ${DESTDIR}/opt/containerd/cluster/version
144+
145+
sudo PATH=$PATH script/setup/install-seccomp
146+
USESUDO=true script/setup/install-runc
147+
script/setup/install-cni
148+
script/setup/install-critools
149+
elif [[ "${OS}" == "windows" ]]; then
150+
script/setup/install-cni-windows
151+
cp bin/* ${DESTDIR}/
152+
fi
153+
working-directory: src/github.com/containerd/containerd
154+
155+
- name: Make cri-containerd tar
156+
shell: bash
157+
run: |
158+
TARFILE="cri-containerd-cni-${RELEASE_VER#v}-${OS}-amd64.tar.gz"
159+
[[ "${OS}" == "linux" ]] && tar czf ${TARFILE} etc usr opt
160+
[[ "${OS}" == "windows" ]] && tar czf ${TARFILE} *
161+
sha256sum ${TARFILE} >${TARFILE}.sha256sum
162+
working-directory: cri-release
163+
164+
- name: Save cri-containerd binaries
165+
uses: actions/upload-artifact@v2
166+
with:
167+
name: cri-containerd-binaries-${{ matrix.os }}
168+
path: cri-release/cri-containerd-cni-*.tar.gz*
169+
122170
release:
123171
name: Create containerd Release
124172
runs-on: ubuntu-18.04
@@ -135,8 +183,12 @@ jobs:
135183
run: |
136184
_filenum=1
137185
for i in "ubuntu-18.04" "windows-2019"; do
138-
for i in `ls builds/containerd-binaries-${i}`; do
139-
echo "::set-output name=file${_filenum}::${i}"
186+
for f in `ls builds/containerd-binaries-${i}`; do
187+
echo "::set-output name=file${_filenum}::${f}"
188+
let "_filenum+=1"
189+
done
190+
for f in `ls builds/cri-containerd-binaries-${i}`; do
191+
echo "::set-output name=file${_filenum}::${f}"
140192
let "_filenum+=1"
141193
done
142194
done
@@ -169,21 +221,57 @@ jobs:
169221
asset_path: ./builds/containerd-binaries-ubuntu-18.04/${{ steps.catalog.outputs.file2 }}
170222
asset_name: ${{ steps.catalog.outputs.file2 }}
171223
asset_content_type: text/plain
172-
- name: Upload Windows containerd tarball
224+
- name: Upload Linux cri containerd tarball
173225
uses: actions/upload-release-asset@v1
174226
env:
175227
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176228
with:
177229
upload_url: ${{ steps.create_release.outputs.upload_url }}
178-
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file3 }}
230+
asset_path: ./builds/cri-containerd-binaries-ubuntu-18.04/${{ steps.catalog.outputs.file3 }}
179231
asset_name: ${{ steps.catalog.outputs.file3 }}
180232
asset_content_type: application/gzip
181-
- name: Upload Windows sha256 sum
233+
- name: Upload Linux cri sha256 sum
182234
uses: actions/upload-release-asset@v1
183235
env:
184236
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
185237
with:
186238
upload_url: ${{ steps.create_release.outputs.upload_url }}
187-
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file4 }}
239+
asset_path: ./builds/cri-containerd-binaries-ubuntu-18.04/${{ steps.catalog.outputs.file4 }}
188240
asset_name: ${{ steps.catalog.outputs.file4 }}
189241
asset_content_type: text/plain
242+
- name: Upload Windows containerd tarball
243+
uses: actions/upload-release-asset@v1
244+
env:
245+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
246+
with:
247+
upload_url: ${{ steps.create_release.outputs.upload_url }}
248+
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file5 }}
249+
asset_name: ${{ steps.catalog.outputs.file5 }}
250+
asset_content_type: application/gzip
251+
- name: Upload Windows sha256 sum
252+
uses: actions/upload-release-asset@v1
253+
env:
254+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
255+
with:
256+
upload_url: ${{ steps.create_release.outputs.upload_url }}
257+
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file6 }}
258+
asset_name: ${{ steps.catalog.outputs.file6 }}
259+
asset_content_type: text/plain
260+
- name: Upload Windows cri containerd tarball
261+
uses: actions/upload-release-asset@v1
262+
env:
263+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
264+
with:
265+
upload_url: ${{ steps.create_release.outputs.upload_url }}
266+
asset_path: ./builds/cri-containerd-binaries-windows-2019/${{ steps.catalog.outputs.file7 }}
267+
asset_name: ${{ steps.catalog.outputs.file7 }}
268+
asset_content_type: application/gzip
269+
- name: Upload Windows cri sha256 sum
270+
uses: actions/upload-release-asset@v1
271+
env:
272+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
273+
with:
274+
upload_url: ${{ steps.create_release.outputs.upload_url }}
275+
asset_path: ./builds/cri-containerd-binaries-windows-2019/${{ steps.catalog.outputs.file8 }}
276+
asset_name: ${{ steps.catalog.outputs.file8 }}
277+
asset_content_type: text/plain

script/setup/install-cni

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
set -eu -o pipefail
2323

2424
CNI_COMMIT=$(grep containernetworking/plugins "$GOPATH"/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}')
25-
CNI_DIR=/opt/cni
26-
CNI_CONFIG_DIR=/etc/cni/net.d
25+
CNI_DIR=${DESTDIR:=''}/opt/cni
26+
CNI_CONFIG_DIR=${DESTDIR}/etc/cni/net.d
2727

2828
go get -d github.com/containernetworking/plugins/...
2929
cd "$GOPATH"/src/github.com/containernetworking/plugins
@@ -32,7 +32,7 @@ FASTBUILD=true ./build.sh
3232
sudo mkdir -p $CNI_DIR
3333
sudo cp -r ./bin $CNI_DIR
3434
sudo mkdir -p $CNI_CONFIG_DIR
35-
cat <<EOF | sudo tee $CNI_CONFIG_DIR/10-containerd-net.conflist
35+
cat << EOF | sudo tee $CNI_CONFIG_DIR/10-containerd-net.conflist
3636
{
3737
"cniVersion": "0.3.1",
3838
"name": "containerd-net",
@@ -45,9 +45,17 @@ cat <<EOF | sudo tee $CNI_CONFIG_DIR/10-containerd-net.conflist
4545
"promiscMode": true,
4646
"ipam": {
4747
"type": "host-local",
48-
"subnet": "10.88.0.0/16",
48+
"ranges": [
49+
[{
50+
"subnet": "10.88.0.0/16"
51+
}],
52+
[{
53+
"subnet": "2001:4860:4860::8888/32"
54+
}]
55+
],
4956
"routes": [
50-
{ "dst": "0.0.0.0/0" }
57+
{ "dst": "0.0.0.0/0" },
58+
{ "dst": "::/0" }
5159
]
5260
}
5361
},

script/setup/install-cni-windows

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
3+
# Copyright The containerd Authors.
4+
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -eu -o pipefail
18+
19+
destdir="${destdir:-"C:\\Program Files\\containerd"}"
20+
WINCNI_BIN_DIR="${destdir}/cni"
21+
WINCNI_PKG=github.com/Microsoft/windows-container-networking
22+
WINCNI_VERSION=aa10a0b31e9f72937063436454def1760b858ee2
23+
24+
go get -d "${WINCNI_PKG}/..."
25+
cd "${GOPATH}/src/${WINCNI_PKG}"
26+
git checkout "${WINCNI_VERSION}"
27+
make all
28+
install -D -m 755 "out/nat.exe" "${WINCNI_BIN_DIR}/nat.exe"
29+
install -D -m 755 "out/sdnbridge.exe" "${WINCNI_BIN_DIR}/sdnbridge.exe"
30+
install -D -m 755 "out/sdnoverlay.exe" "${WINCNI_BIN_DIR}/sdnoverlay.exe"
31+
32+
CNI_CONFIG_DIR="${destdir}/cni/conf"
33+
mkdir -p "${CNI_CONFIG_DIR}"
34+
35+
# split_ip splits ip into a 4-element array.
36+
split_ip() {
37+
local -r varname="$1"
38+
local -r ip="$2"
39+
for i in {0..3}; do
40+
eval "$varname"[$i]=$( echo "$ip" | cut -d '.' -f $((i + 1)) )
41+
done
42+
}
43+
44+
# subnet gets subnet for a gateway, e.g. 192.168.100.0/24.
45+
calculate_subnet() {
46+
local -r gateway="$1"
47+
local -r prefix_len="$2"
48+
split_ip gateway_array "$gateway"
49+
local len=$prefix_len
50+
for i in {0..3}; do
51+
if (( len >= 8 )); then
52+
mask=255
53+
elif (( len > 0 )); then
54+
mask=$(( 256 - 2 ** ( 8 - len ) ))
55+
else
56+
mask=0
57+
fi
58+
(( len -= 8 ))
59+
result_array[i]=$(( gateway_array[i] & mask ))
60+
done
61+
result="$(printf ".%s" "${result_array[@]}")"
62+
result="${result:1}"
63+
echo "$result/$((32 - prefix_len))"
64+
}
65+
66+
# nat already exists on the Windows VM, the subnet and gateway
67+
# we specify should match that.
68+
gateway="$(powershell -c "(Get-NetIPAddress -InterfaceAlias 'vEthernet (nat)' -AddressFamily IPv4).IPAddress")"
69+
prefix_len="$(powershell -c "(Get-NetIPAddress -InterfaceAlias 'vEthernet (nat)' -AddressFamily IPv4).PrefixLength")"
70+
71+
subnet="$(calculate_subnet "$gateway" "$prefix_len")"
72+
73+
# The "name" field in the config is used as the underlying
74+
# network type right now (see
75+
# https://github.com/microsoft/windows-container-networking/pull/45),
76+
# so it must match a network type in:
77+
# https://docs.microsoft.com/en-us/windows-server/networking/technologies/hcn/hcn-json-document-schemas
78+
bash -c 'cat >"'"${CNI_CONFIG_DIR}"'"/0-containerd-nat.conf <<EOF
79+
{
80+
"cniVersion": "0.2.0",
81+
"name": "nat",
82+
"type": "nat",
83+
"master": "Ethernet",
84+
"ipam": {
85+
"subnet": "'$subnet'",
86+
"routes": [
87+
{
88+
"GW": "'$gateway'"
89+
}
90+
]
91+
},
92+
"capabilities": {
93+
"portMappings": true,
94+
"dns": true
95+
}
96+
}
97+
EOF'

script/setup/install-critools

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ go get -d github.com/kubernetes-sigs/cri-tools/...
2626
cd "$GOPATH"/src/github.com/kubernetes-sigs/cri-tools
2727
git checkout $CRITEST_COMMIT
2828
make
29-
sudo make install
30-
cat << EOF | sudo tee /etc/crictl.yaml
29+
sudo make install -e BINDIR=${DESTDIR:=''}/usr/local/bin
30+
cat << EOF | sudo tee ${DESTDIR}/etc/crictl.yaml
3131
runtime-endpoint: unix:///run/containerd/containerd.sock
3232
EOF

script/setup/install-runc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ function install_runc() {
2727
cd "$GOPATH"/src/github.com/opencontainers/runc
2828
git checkout $RUNC_COMMIT
2929
make BUILDTAGS='apparmor seccomp selinux' runc
30-
make install
30+
31+
USESUDO=${USESUDO:-false}
32+
if ${USESUDO}; then
33+
SUDO='sudo -E'
34+
else
35+
SUDO=''
36+
fi
37+
${SUDO} make install
3138
}
3239

3340
function install_crun() {

0 commit comments

Comments
 (0)