Skip to content

Commit 7e4a66d

Browse files
authored
Merge pull request #199 from kad/opae1.3.2
FPGA: Migrate to ClearLinux, use native go and kernel APIs
2 parents 5b2aa6d + 6395b16 commit 7e4a66d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4853
-1463
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,12 @@ coverage.txt
88
cmd/fpga_admissionwebhook/fpga_admissionwebhook
99
cmd/fpga_crihook/fpga_crihook
1010
cmd/fpga_plugin/fpga_plugin
11+
cmd/fpga_tool/fpga_tool
1112
cmd/gpu_plugin/gpu_plugin
1213
cmd/qat_plugin/qat_plugin
14+
15+
*.h
16+
*.gbs
17+
*.gbs.*
18+
*.aocx
19+
*.aocx.*

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ before_install:
2323
- if [[ "$src" != "$dest" ]]; then mv "$src" "$dest"; cd ../../intel/$repo; export TRAVIS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/$repo; fi
2424
## install buildah build deps
2525
- cdir=$(pwd)
26+
- sudo apt-get update
2627
- sudo apt-get -y install e2fslibs-dev libfuse-dev libgpgme11-dev libdevmapper-dev libglib2.0-dev libprotobuf-dev
2728
# build buildah
2829
- mkdir -p $GOPATH/src/github.com/containers
@@ -47,7 +48,7 @@ script:
4748
- make vet
4849
- make cyclomatic-check
4950
- make test BUILDTAGS=kerneldrv
50-
- make images
51+
- make -j4 images
5152
- make images BUILDER=buildah
5253
- make demos
5354
- make demos BUILDER=buildah

Jenkinsfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pipeline {
3636
}
3737
stage("buildah") {
3838
steps {
39+
sh "sudo apt-get update"
3940
sh "sudo apt-get -y install e2fslibs-dev libfuse-dev libgpgme11-dev libdevmapper-dev libglib2.0-dev libprotobuf-dev"
4041
sh "mkdir -p ${GOPATH}/src/github.com/containers"
4142
dir(path: "${GOPATH}/src/github.com/containers") {
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
1-
FROM golang:1.11 as builder
1+
# CLEAR_LINUX_BASE and CLEAR_LINUX_VERSION can be used to make the build
2+
# reproducible by choosing an image by its hash and installing an OS version
3+
# with --version=:
4+
# CLEAR_LINUX_BASE=clearlinux@sha256:b8e5d3b2576eb6d868f8d52e401f678c873264d349e469637f98ee2adf7b33d4
5+
# CLEAR_LINUX_VERSION="--version=29970"
6+
#
7+
# This is used on release branches before tagging a stable version.
8+
# The master branch defaults to using the latest Clear Linux.
9+
ARG CLEAR_LINUX_BASE=clearlinux/golang:latest
10+
11+
FROM ${CLEAR_LINUX_BASE} as builder
12+
13+
ARG CLEAR_LINUX_VERSION=
14+
15+
RUN swupd update --no-boot-update ${CLEAR_LINUX_VERSION}
16+
RUN mkdir /install_root \
17+
&& swupd os-install \
18+
${CLEAR_LINUX_VERSION} \
19+
--path /install_root \
20+
--statedir /swupd-state \
21+
--bundles=os-core \
22+
--no-boot-update \
23+
&& rm -rf /install_root/var/lib/swupd/*
24+
225
ARG DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes
326
WORKDIR $DIR
427
COPY . .
528
RUN cd cmd/fpga_admissionwebhook; go install
6-
RUN chmod a+x /go/bin/fpga_admissionwebhook
29+
RUN chmod a+x /go/bin/fpga_admissionwebhook \
30+
&& install -D /go/bin/fpga_admissionwebhook /install_root/usr/local/bin/intel_fpga_admissionwebhook \
31+
&& install -D ${DIR}/LICENSE /install_root/usr/local/share/package-licenses/intel-device-plugins-for-kubernetes/LICENSE
732

8-
FROM gcr.io/distroless/base
9-
COPY --from=builder /go/bin/fpga_admissionwebhook /usr/bin/intel_fpga_admissionwebhook
10-
CMD ["/usr/bin/intel_fpga_admissionwebhook"]
33+
FROM scratch as final
34+
COPY --from=builder /install_root /
35+
CMD ["/usr/local/bin/intel_fpga_admissionwebhook"]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# CLEAR_LINUX_BASE and CLEAR_LINUX_VERSION can be used to make the build
2+
# reproducible by choosing an image by its hash and installing an OS version
3+
# with --version=:
4+
# CLEAR_LINUX_BASE=clearlinux@sha256:b8e5d3b2576eb6d868f8d52e401f678c873264d349e469637f98ee2adf7b33d4
5+
# CLEAR_LINUX_VERSION="--version=29970"
6+
#
7+
# This is used on release branches before tagging a stable version.
8+
# The master branch defaults to using the latest Clear Linux.
9+
ARG CLEAR_LINUX_BASE=clearlinux/golang:latest
10+
11+
FROM ${CLEAR_LINUX_BASE} as builder
12+
13+
ARG CLEAR_LINUX_VERSION=
14+
15+
RUN swupd update --no-boot-update ${CLEAR_LINUX_VERSION}
16+
RUN mkdir /install_root \
17+
&& swupd os-install \
18+
${CLEAR_LINUX_VERSION} \
19+
--path /install_root \
20+
--statedir /swupd-state \
21+
--bundles=os-core,rsync \
22+
--no-boot-update \
23+
&& rm -rf /install_root/var/lib/swupd/*
24+
25+
# Build CRI Hook
26+
ARG DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes
27+
WORKDIR $DIR
28+
COPY . .
29+
RUN cd $DIR/cmd/fpga_crihook && \
30+
go install && \
31+
chmod a+x /go/bin/fpga_crihook && \
32+
cd $DIR/cmd/fpga_tool && \
33+
go install && \
34+
chmod a+x /go/bin/fpga_tool && \
35+
install -D ${DIR}/LICENSE /install_root/usr/local/share/package-licenses/intel-device-plugins-for-kubernetes/LICENSE
36+
37+
# Minimal result image
38+
FROM scratch as final
39+
COPY --from=builder /install_root /
40+
41+
ARG SRC_DIR=/usr/local/fpga-sw.src
42+
ARG DST_DIR=/opt/intel/fpga-sw
43+
44+
# CRI hook
45+
ARG CRI_HOOK=intel-fpga-crihook
46+
ARG FPGA_TOOL=fpgatool
47+
ARG HOOK_CONF=$CRI_HOOK.json
48+
ARG HOOK_CONF_SRC=$SRC_DIR/$HOOK_CONF
49+
ARG HOOK_CONF_DST=$DST_DIR/$HOOK_CONF
50+
51+
COPY --from=builder /go/bin/fpga_crihook $SRC_DIR/$CRI_HOOK
52+
COPY --from=builder /go/bin/fpga_tool $SRC_DIR/$FPGA_TOOL
53+
54+
RUN echo -e "{\n\
55+
\"hook\" : \"$DST_DIR/$CRI_HOOK\",\n\
56+
\"stage\" : [ \"prestart\" ],\n\
57+
\"annotation\": [ \"fpga.intel.com/region\" ]\n\
58+
}\n">>$HOOK_CONF_SRC
59+
60+
RUN echo -e "#!/bin/sh\n\
61+
rsync -a --delete $SRC_DIR/ $DST_DIR\n\
62+
mkdir -p /etc/containers/oci/hooks.d\n\
63+
ln -sf $HOOK_CONF_DST /etc/containers/oci/hooks.d/$HOOK_CONF\n\
64+
rm $DST_DIR/deploy.sh\n\
65+
">> $SRC_DIR/deploy.sh && chmod +x $SRC_DIR/deploy.sh
66+
67+
CMD [ "/opt/intel/fpga-sw.src/deploy.sh" ]
Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
1-
FROM golang:1.11 as builder
1+
# CLEAR_LINUX_BASE and CLEAR_LINUX_VERSION can be used to make the build
2+
# reproducible by choosing an image by its hash and installing an OS version
3+
# with --version=:
4+
# CLEAR_LINUX_BASE=clearlinux@sha256:b8e5d3b2576eb6d868f8d52e401f678c873264d349e469637f98ee2adf7b33d4
5+
# CLEAR_LINUX_VERSION="--version=29970"
6+
#
7+
# This is used on release branches before tagging a stable version.
8+
# The master branch defaults to using the latest Clear Linux.
9+
ARG CLEAR_LINUX_BASE=clearlinux/golang:latest
10+
11+
FROM ${CLEAR_LINUX_BASE} as builder
12+
13+
ARG CLEAR_LINUX_VERSION=
14+
15+
RUN swupd update --no-boot-update ${CLEAR_LINUX_VERSION}
16+
RUN mkdir /install_root \
17+
&& swupd os-install \
18+
${CLEAR_LINUX_VERSION} \
19+
--path /install_root \
20+
--statedir /swupd-state \
21+
--bundles=os-core \
22+
--no-boot-update \
23+
&& rm -rf /install_root/var/lib/swupd/*
24+
225
ARG DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes
326
WORKDIR $DIR
427
COPY . .
528
RUN cd cmd/fpga_plugin; go install
6-
RUN chmod a+x /go/bin/fpga_plugin
29+
RUN chmod a+x /go/bin/fpga_plugin \
30+
&& install -D /go/bin/fpga_plugin /install_root/usr/local/bin/intel_fpga_device_plugin \
31+
&& install -D ${DIR}/LICENSE /install_root/usr/local/share/package-licenses/intel-device-plugins-for-kubernetes/LICENSE
732

8-
FROM gcr.io/distroless/base
9-
COPY --from=builder /go/bin/fpga_plugin /usr/bin/intel_fpga_device_plugin
10-
CMD ["/usr/bin/intel_fpga_device_plugin"]
33+
FROM scratch as final
34+
COPY --from=builder /install_root /
35+
CMD ["/usr/local/bin/intel_fpga_device_plugin"]

cmd/fpga_crihook/README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@ $ cd $GOPATH/src/github.com/intel/intel-device-plugins-for-kubernetes
2121
$ make fpga_crihook
2222
```
2323

24-
### Download 'Acceleration Stack for Runtime' tarball
25-
```
26-
Download a10_gx_pac_ias_1_1_pv_rte_installer.tar.gz from https://www.intel.com/content/www/us/en/programmable/solutions/acceleration-hub/downloads.html into $GOPATH/src/github.com/intel/intel-device-plugins-for-kubernetes/deployments/fpga_plugin directory
27-
```
28-
29-
### Build init container that contains CRI hook and all its dependencies:
30-
```
31-
$ cd $GOPATH/src/github.com/intel/intel-device-plugins-for-kubernetes/deployments/fpga_plugin
32-
$ ./build-initcontainer-image.sh
33-
```
24+
### Ensure that CRI-O is configured to allow OCI hooks
3425

26+
Recent versions of CRI-O are shipped with default configuration file that prevents
27+
CRI-O to discover and configure hooks automatically.
28+
For FPGA orchestration programmed mode, the OCI hooks are the key component.
29+
Thus, please make sure that in your `/etc/crio/crio.conf` parameter `hooks_dir` is either unset (to enable default search paths for OCI hooks configuration) or contains directory `/etc/containers/oci/hooks.d`

0 commit comments

Comments
 (0)