Skip to content

Commit e5afa33

Browse files
dmcgowanestesp
authored andcommitted
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 <[email protected]>
1 parent 9bd8f6e commit e5afa33

5 files changed

Lines changed: 223 additions & 22 deletions

File tree

.github/workflows/release.yml

Lines changed: 100 additions & 13 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,36 +86,35 @@ jobs:
7986
repository: containerd/containerd
8087
ref: ${{ github.ref }}
8188
path: src/github.com/containerd/containerd
89+
8290
- name: Install Linux dependencies
8391
if: startsWith(matrix.os, 'ubuntu')
8492
run: |
85-
sudo apt-get update
86-
sudo apt-get install -y btrfs-tools
8793
sudo script/setup/install-seccomp
8894
working-directory: src/github.com/containerd/containerd
95+
8996
- name: HCS Shim commit
9097
id: hcsshim_commit
9198
if: startsWith(matrix.os, 'windows')
9299
shell: bash
93100
run: echo "::set-output name=sha::$(grep Microsoft/hcsshim vendor.conf | awk '{print $2}')"
94101
working-directory: src/github.com/containerd/containerd
102+
95103
- name: Checkout hcsshim source
96104
if: startsWith(matrix.os, 'windows')
97105
uses: actions/checkout@v2
98106
with:
99107
repository: Microsoft/hcsshim
100108
ref: ${{ steps.hcsshim_commit.outputs.sha }}
101109
path: src/github.com/Microsoft/hcsshim
110+
102111
- name: Make
103112
shell: bash
104-
env:
105-
MOS: ${{ matrix.os }}
106-
OS: linux
107113
run: |
108114
make build
109115
make binaries
110-
[[ "${MOS}" =~ "windows" ]] && {
111-
OS=windows
116+
rm bin/containerd-stress*
117+
[[ "${OS}" == "windows" ]] && {
112118
(
113119
bindir="$(pwd)/bin"
114120
cd ../../Microsoft/hcsshim
@@ -126,6 +132,47 @@ jobs:
126132
name: containerd-binaries-${{ matrix.os }}
127133
path: src/github.com/containerd/containerd/*.tar.gz*
128134

135+
- name: Install cri-containerd dependencies
136+
shell: bash
137+
env:
138+
RUNC_FLAVOR: runc
139+
DESTDIR: ${{ github.workspace }}/cri-release
140+
run: |
141+
mkdir ${DESTDIR}
142+
if [[ "${OS}" == "linux" ]]; then
143+
sudo install -d ${DESTDIR}/usr/local/bin
144+
sudo install -D -m 755 bin/* ${DESTDIR}/usr/local/bin
145+
sudo install -d ${DESTDIR}/opt/containerd/cluster
146+
sudo cp -r contrib/gce ${DESTDIR}/opt/containerd/cluster/
147+
sudo install -d ${DESTDIR}/etc/systemd/system
148+
sudo install -m 644 containerd.service ${DESTDIR}/etc/systemd/system
149+
echo "CONTAINERD_VERSION: '${RELEASE_VER#v}'" | sudo tee ${DESTDIR}/opt/containerd/cluster/version
150+
151+
sudo PATH=$PATH script/setup/install-seccomp
152+
USESUDO=true script/setup/install-runc
153+
script/setup/install-cni
154+
script/setup/install-critools
155+
elif [[ "${OS}" == "windows" ]]; then
156+
script/setup/install-cni-windows
157+
cp bin/* ${DESTDIR}/
158+
fi
159+
working-directory: src/github.com/containerd/containerd
160+
161+
- name: Make cri-containerd tar
162+
shell: bash
163+
run: |
164+
TARFILE="cri-containerd-cni-${RELEASE_VER#v}-${OS}-amd64.tar.gz"
165+
[[ "${OS}" == "linux" ]] && tar czf ${TARFILE} etc usr opt
166+
[[ "${OS}" == "windows" ]] && tar czf ${TARFILE} *
167+
sha256sum ${TARFILE} >${TARFILE}.sha256sum
168+
working-directory: cri-release
169+
170+
- name: Save cri-containerd binaries
171+
uses: actions/upload-artifact@v2
172+
with:
173+
name: cri-containerd-binaries-${{ matrix.os }}
174+
path: cri-release/cri-containerd-cni-*.tar.gz*
175+
129176
release:
130177
name: Create containerd Release
131178
runs-on: ubuntu-18.04
@@ -142,8 +189,12 @@ jobs:
142189
run: |
143190
_filenum=1
144191
for i in "ubuntu-18.04" "windows-2019"; do
145-
for i in `ls builds/containerd-binaries-${i}`; do
146-
echo "::set-output name=file${_filenum}::${i}"
192+
for f in `ls builds/containerd-binaries-${i}`; do
193+
echo "::set-output name=file${_filenum}::${f}"
194+
let "_filenum+=1"
195+
done
196+
for f in `ls builds/cri-containerd-binaries-${i}`; do
197+
echo "::set-output name=file${_filenum}::${f}"
147198
let "_filenum+=1"
148199
done
149200
done
@@ -176,21 +227,57 @@ jobs:
176227
asset_path: ./builds/containerd-binaries-ubuntu-18.04/${{ steps.catalog.outputs.file2 }}
177228
asset_name: ${{ steps.catalog.outputs.file2 }}
178229
asset_content_type: text/plain
179-
- name: Upload Windows containerd tarball
230+
- name: Upload Linux cri containerd tarball
180231
uses: actions/upload-release-asset@v1
181232
env:
182233
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
183234
with:
184235
upload_url: ${{ steps.create_release.outputs.upload_url }}
185-
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file3 }}
236+
asset_path: ./builds/cri-containerd-binaries-ubuntu-18.04/${{ steps.catalog.outputs.file3 }}
186237
asset_name: ${{ steps.catalog.outputs.file3 }}
187238
asset_content_type: application/gzip
188-
- name: Upload Windows sha256 sum
239+
- name: Upload Linux cri sha256 sum
189240
uses: actions/upload-release-asset@v1
190241
env:
191242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192243
with:
193244
upload_url: ${{ steps.create_release.outputs.upload_url }}
194-
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file4 }}
245+
asset_path: ./builds/cri-containerd-binaries-ubuntu-18.04/${{ steps.catalog.outputs.file4 }}
195246
asset_name: ${{ steps.catalog.outputs.file4 }}
196247
asset_content_type: text/plain
248+
- name: Upload Windows containerd tarball
249+
uses: actions/upload-release-asset@v1
250+
env:
251+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
252+
with:
253+
upload_url: ${{ steps.create_release.outputs.upload_url }}
254+
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file5 }}
255+
asset_name: ${{ steps.catalog.outputs.file5 }}
256+
asset_content_type: application/gzip
257+
- name: Upload Windows sha256 sum
258+
uses: actions/upload-release-asset@v1
259+
env:
260+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
261+
with:
262+
upload_url: ${{ steps.create_release.outputs.upload_url }}
263+
asset_path: ./builds/containerd-binaries-windows-2019/${{ steps.catalog.outputs.file6 }}
264+
asset_name: ${{ steps.catalog.outputs.file6 }}
265+
asset_content_type: text/plain
266+
- name: Upload Windows cri containerd tarball
267+
uses: actions/upload-release-asset@v1
268+
env:
269+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
270+
with:
271+
upload_url: ${{ steps.create_release.outputs.upload_url }}
272+
asset_path: ./builds/cri-containerd-binaries-windows-2019/${{ steps.catalog.outputs.file7 }}
273+
asset_name: ${{ steps.catalog.outputs.file7 }}
274+
asset_content_type: application/gzip
275+
- name: Upload Windows cri sha256 sum
276+
uses: actions/upload-release-asset@v1
277+
env:
278+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
279+
with:
280+
upload_url: ${{ steps.create_release.outputs.upload_url }}
281+
asset_path: ./builds/cri-containerd-binaries-windows-2019/${{ steps.catalog.outputs.file8 }}
282+
asset_name: ${{ steps.catalog.outputs.file8 }}
283+
asset_content_type: text/plain

script/setup/install-cni

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#
2222
set -eu -o pipefail
2323

24-
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
24+
CNI_COMMIT=$(grep containernetworking/plugins "$GOPATH"/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}')
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +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
29+
sudo make install -e BINDIR=${DESTDIR:=''}/usr/local/bin
30+
cat << EOF | sudo tee ${DESTDIR}/etc/crictl.yaml
31+
runtime-endpoint: unix:///run/containerd/containerd.sock
32+
EOF

script/setup/install-runc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ set -eu -o pipefail
2424
RUNC_COMMIT=$(grep opencontainers/runc ${GOPATH}/src/github.com/containerd/containerd/vendor.conf | awk '{print $2}')
2525

2626
go get -d github.com/opencontainers/runc
27-
cd $GOPATH/src/github.com/opencontainers/runc
27+
cd "$GOPATH"/src/github.com/opencontainers/runc
2828
git checkout $RUNC_COMMIT
2929
make BUILDTAGS="seccomp apparmor selinux" runc
30-
sudo make install
30+
USESUDO=${USESUDO:-false}
31+
if ${USESUDO}; then
32+
SUDO='sudo -E'
33+
else
34+
SUDO=''
35+
fi
36+
${SUDO} make install

0 commit comments

Comments
 (0)