Skip to content

Commit

Permalink
rename deprecated prestart to createRuntime
Browse files Browse the repository at this point in the history
`prestart` hook is marked as deprecated in the OCI runtime spec:
https://github.com/opencontainers/runtime-spec/blob/main/config.md#posix-platform-hooks

Renamed `prestart` to the `createRuntime` as suggested in the spec.

Replaced `CDI hook` with `OCI hook` to be more clear. CDI is just a
way to update OCI config and theoretically there is no such thing as
CDI hook.
  • Loading branch information
bart0sh committed May 22, 2024
1 parent 1fa557e commit e58369e
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 42 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The FPGA plugin comes as three parts.

- the [device plugin](#device-plugin)
- the [admission controller](#admission-controller)
- the [CDI prestart hook](#CDI-prestart-hook)
- the [OCI createRuntime hook](#OCI-createRuntime-hook)

Refer to each individual sub-components documentation for more details.
Brief overviews of the sub-components are below.
Expand All @@ -88,9 +88,9 @@ is responsible for performing mapping from user-friendly function IDs to the
Interface ID and Bitstream ID that are required for FPGA programming. It also
implements access control by namespacing FPGA configuration information.

#### CDI Prestart Hook
#### OCI createRuntime Hook

The [FPGA CDI prestart hook](cmd/fpga_crihook/README.md) performs discovery
The [FPGA OCI createRuntime hook](cmd/fpga_crihook/README.md) performs discovery
of the requested FPGA function bitstream and programs FPGA devices based on the
environment variables in the workload description.

Expand Down
2 changes: 1 addition & 1 deletion build/docker/intel-fpga-initcontainer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ LABEL version='devel'
LABEL release='1'
LABEL name='intel-fpga-initcontainer'
LABEL summary='Intel® FPGA programming CDI hook for Kubernetes'
LABEL description='The FPGA prestart CDI hook performs discovery of the requested FPGA function bitstream and programs FPGA devices based on the environment variables in the workload description'
LABEL description='The FPGA OCI createRuntime hook performs discovery of the requested FPGA function bitstream and programs FPGA devices based on the environment variables in the workload description'
COPY --from=builder /install_root /
ENTRYPOINT [ "/usr/bin/sh", "-c", "cp -a /usr/local/fpga-sw/* /opt/intel/fpga-sw/" ]
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FROM ${FINAL_BASE}

LABEL name='intel-fpga-initcontainer'
LABEL summary='Intel® FPGA programming CDI hook for Kubernetes'
LABEL description='The FPGA prestart CDI hook performs discovery of the requested FPGA function bitstream and programs FPGA devices based on the environment variables in the workload description'
LABEL description='The FPGA OCI createRuntime hook performs discovery of the requested FPGA function bitstream and programs FPGA devices based on the environment variables in the workload description'

COPY --from=builder /install_root /

Expand Down
10 changes: 5 additions & 5 deletions cmd/fpga_admissionwebhook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ devices to Kubernetes.
The FPGA admission controller webhook is responsible for performing mapping from user-friendly
function IDs to the Interface ID and Bitstream ID that are required for FPGA programming by
the [FPGA CDI prestart hook](../fpga_crihook/README.md).
the [FPGA OCI createRuntime hook](../fpga_crihook/README.md).

Mappings are stored in namespaced custom resource definition (CRD) objects, therefore the admission
controller also performs access control, determining which bitstream can be used for which namespace.
More details can be found in the [Mappings](#mappings) section.

The admission controller also keeps the user from bypassing namespaced mapping restrictions,
by denying admission of any pods that are trying to use internal knowledge of InterfaceID or
Bitstream ID environment variables used by the prestart hook.
Bitstream ID environment variables used by the createRuntime hook.

## Dependencies

This component is one of a set of components that work together. You may also want to
install the following:

- [FPGA device plugin](../fpga_plugin/README.md)
- [FPGA CDI prestart hook](../fpga_crihook/README.md)
- [FPGA OCI createRuntime hook](../fpga_crihook/README.md)

All components have the same basic dependencies as the
[generic plugin framework dependencies](../../README.md#about)
Expand Down Expand Up @@ -129,7 +129,7 @@ The same mapping, but with its mode field set to `region`, would translate
and the corresponding AF IDs are set in environment variables for the container.
Though in this case the cluster administrator would probably want to rename
the mapping `arria10.dcp1.2-nlb0-preprogrammed` to something like `arria10.dcp1.2-nlb0-orchestrated`
to reflect its mode. The [FPGA CDI prestart hook](../fpga_crihook/README.md) then loads the requested
to reflect its mode. The [FPGA OCI createRuntime hook](../fpga_crihook/README.md) then loads the requested
bitstream to a region before the container is started.

Mappings of resource names are configured with objects of `AcceleratorFunction` and
Expand Down Expand Up @@ -183,4 +183,4 @@ and they are applicable to pods created in the corresponding namespaces.

## Next steps

Continue with [FPGA CDI prestart hook](../fpga_crihook/README.md).
Continue with [FPGA OCI createRuntime hook](../fpga_crihook/README.md).
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Intel FPGA CDI prestart hook for Kubernetes
# Intel FPGA OCI createRuntime hook for Kubernetes

Table of Contents

Expand All @@ -11,7 +11,7 @@ Table of Contents
The FPGA CDI hook is one of the components used to add support for Intel FPGA
devices to Kubernetes.

The FPGA prestart hook is passed by the [FPGA device plugin](../fpga_plugin/README.md) as
The FPGA OCI createRuntime hook is passed by the [FPGA device plugin](../fpga_plugin/README.md) as
a CDI device attribute to the Kubelet and then to the CRI runtime.
It performs discovery of the requested FPGA function bitstream and then programs FPGA devices
based on the environment variables in the workload description.
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-correct.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-no-FPGA-devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-no-afu.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-no-devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-no-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-no-linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-no-process.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-no-region.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-non-existing-bitstream.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions cmd/fpga_crihook/testdata/config-region-afu-dont-match.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
}
],
"hooks": {
"prestart": [
"createRuntime": [
{
"path": "/usr/local/bin/fpga_crihook",
"args": [
"/usr/local/bin/fpga_crihook"
],
"env": [
"stage=prestart"
"stage=createRuntime"
]
}
]
Expand Down
20 changes: 11 additions & 9 deletions cmd/fpga_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,20 @@ Kubernetes:
which can be used to dynamically convert logical resource names in pod specifications into actual FPGA
resource names, as advertised by the device plugin.

The webhook can also set environment variables to instruct the CDI prestart hook to program the FPGA
The webhook can also set environment variables to instruct the OCI createRuntime hook to program the FPGA
before launching the container.

> **NOTE:** Installation of the [FPGA admission controller webhook](../fpga_admissionwebhook/README.md) can be skipped if the
> FPGA device plugin is operated with the Intel Device Plugins Operator
> since it integrates the controller's functionality.
> However, [the mappings](../fpga_admissionwebhook/README.md#mappings-deployment) still must be deployed."
- [FPGA CDI prestart hook](../fpga_crihook/README.md)
- [FPGA OCI createRuntime hook](../fpga_crihook/README.md)

A [CDI](https://github.com/cncf-tags/container-device-interface) prestart hook that, upon instruction from the FPGA admission
controller, programs the FPGA before the container is launched.
An [OCI](https://github.com/opencontainers/runtime-spec/blob/main/config.md#createRuntime-hooks) createRuntime hook that,
upon instruction from the FPGA admission controller, programs the FPGA before the container is launched.
The FPGA plugin uses [Container Device Interface](https://github.com/cncf-tags/container-device-interface) to pass the hook
to the Kubelet.

The repository also contains an [FPGA helper tool](../fpga_tool/README.md) that may be useful during
development, initial deployment and debugging.
Expand Down Expand Up @@ -102,13 +104,13 @@ major components:

- [FPGA device plugin](README.md) (this component)
- [FPGA admission controller webhook](../fpga_admissionwebhook/README.md)
- [FPGA CDI prestart hook](../fpga_crihook/README.md)
- [FPGA OCI createRuntime hook](../fpga_crihook/README.md)

The CDI hook is only *required* if `region` mode is being used, but is installed by default by the
[FPGA plugin DaemonSet YAML](/deployments/fpga_plugin/base/intel-fpga-plugin-daemonset.yaml), and is benign
in `af` mode.

If using the `af` mode, and therefore *not* using the CDI prestart hook, any runtime can be used
If using the `af` mode, and therefore *not* using the OCI createRuntime hook, any runtime can be used
(that is, the CDI is not supported by all runtimes).

The FPGA device plugin requires a Linux Kernel FPGA driver to be installed and enabled to
Expand Down Expand Up @@ -146,7 +148,7 @@ The following images are available on the Docker hub:

- [The FPGA plugin](https://hub.docker.com/r/intel/intel-fpga-plugin)
- [The FPGA admisson webhook](https://hub.docker.com/r/intel/intel-fpga-admissionwebhook)
- [The FPGA CDI prestart hook (in the `initcontainer` image)](https://hub.docker.com/r/intel/intel-fpga-initcontainer)
- [The FPGA OCI createRuntime hook (in the `initcontainer` image)](https://hub.docker.com/r/intel/intel-fpga-initcontainer)

Depending on the FPGA mode, run either
```bash
Expand Down Expand Up @@ -206,7 +208,7 @@ $ kubectl annotate node <node_name> 'fpga.intel.com/device-plugin-mode=af'
And restart the pods on the nodes.

> **Note:** The FPGA plugin [DaemonSet YAML](/deployments/fpga_plugin/base/intel-fpga-plugin-daemonset.yaml)
> also deploys the [FPGA CDI prestart hook](../fpga_crihook/README.md) `initcontainer` image, but it will be
> also deploys the [FPGA OCI createRuntime hook](../fpga_crihook/README.md) `initcontainer` image, but it will be
> benign (un-used) when running the FPGA plugin in `af` mode.
#### Verify Plugin Registration
Expand All @@ -222,6 +224,6 @@ fpga.intel.com/region-ce48969398f05f33946d560708be108a: 1
```

> **Note:** The FPGA plugin [DaemonSet YAML](/deployments/fpga_plugin/fpga_plugin.yaml)
> also deploys the [FPGA CDI prestart hook](../fpga_crihook/README.md) `initcontainer` image as well. You may
> also deploys the [FPGA OCI createRuntime hook](../fpga_crihook/README.md) `initcontainer` image as well. You may
> also wish to build that image locally before deploying the FPGA plugin to avoid deploying
> the Docker hub default image.
2 changes: 1 addition & 1 deletion cmd/fpga_plugin/fpga_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
scanPeriod = 5 * time.Second

// CDI hook attributes.
HookName = "prestart"
HookName = "createRuntime"
HookPath = "/opt/intel/fpga-sw/intel-fpga-crihook"
)

Expand Down

0 comments on commit e58369e

Please sign in to comment.