-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[secure-boot] ease of use update and bug fixes (#90)
* [secure-boot] ease of use update and bug fixes * using variable values instead of hard-coding paths * incorrect path to db.der/mok.pub corrected * If the named secret exists in secret manager and tls/ directory does not exist, fetch contents of tls/ from gcp APIs * Otherwise create a new MOK key pair and publish in secret manager * make expected md5sum immutable * removed definition of unused project number variable ; added docs link regarding instructions for creating service account * image name may not include dots * suggested another role to grant to the dataproc service account * tested with this documentation * test of install_gpu_driver.sh as a customization script * more selective about portion of the script which has access to private key material * first pass at using custom script instance to install GPU driver using init action ; to do: install the trust db before running the installer ; turn on secure boot * removed redundant gpu argument ; launching 2.2 customization instances with secure boot enabled * returning version to 42 * enable dkms certificate use anywhere in main function * moved example code from README.md to cuda.sh update python version in Dockerfile reduce noise from serial console read config values from env.json * included license text with example * added example script to run generate-custom_image.py with secure boot and cuda
- Loading branch information
Showing
9 changed files
with
1,443 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,15 @@ | ||
To generate a key pair for use with the custom image, run the | ||
create-key-pair.sh script. You can then specify the full path to | ||
**tls/db.der** with the argument **--trusted-cert=.../tls/db.der** | ||
|
||
Kernel drivers signed with the private side of this key pair can then | ||
be loaded into kernels on systems with secure boot enabled. | ||
|
||
To create a custom image with a self-signed, trusted certificate | ||
inserted into the boot sector, and then run a script to install nvidia | ||
kernel drivers on a Dataproc image, the following commands can be | ||
run from the root of the custom-images git repository: | ||
|
||
```bash | ||
PROJECT_ID=your-project-here | ||
PROJECT_NUMBER=your-project-nnnn-here | ||
CLUSTER_NAME=your-cluster-name-here | ||
my_bucket=your-bucket-here | ||
custom_image_zone=your-zone-here | ||
|
||
export SA_NAME=sa-${CLUSTER_NAME} | ||
export GSA=${SA_NAME}@${PROJECT_ID}.iam.gserviceaccount.com | ||
|
||
gcloud projects add-iam-policy-binding ${PROJECT_ID} \ | ||
--member=serviceAccount:${GSA} \ | ||
--role=roles/secretmanager.secretAccessor | ||
gcloud config set project ${PROJECT_ID} | ||
|
||
gcloud auth login | ||
inserted into the boot sector, and then run a script to install cuda | ||
on a Dataproc image, the commands from cuda.sh can be run from the | ||
root of the custom-images git repository or from a docker container. | ||
|
||
# variables *_secret_name_, secret_project, secret_version defined here: | ||
eval $(bash examples/secure-boot/create-key-pair.sh) | ||
metadata="public_secret_name=${public_secret_name}" | ||
metadata="${metadata},private_secret_name=${private_secret_name}" | ||
metadata="${metadata},secret_project=${secret_project}" | ||
metadata="${metadata},secret_version=${secret_version}" | ||
First, write an env.json to the directory from which you will run the | ||
customization script. There is a sample which you can copy and edit | ||
in the file examples/secure-boot/env.json.sample. | ||
|
||
#dataproc_version=2.2-rocky9 | ||
#dataproc_version=2.2-ubuntu22 | ||
dataproc_version=2.2-debian12 | ||
#customization_script=examples/secure-boot/install-nvidia-driver-debian11.sh | ||
customization_script=examples/secure-boot/install-nvidia-driver-debian12.sh | ||
#image_name="nvidia-open-kernel-2.2-ubuntu22-$(date +%F)" | ||
#image_name="nvidia-open-kernel-2.2-rocky9-$(date +%F)" | ||
#image_name="nvidia-open-kernel-2.2-debian12-$(date +%F)" | ||
image_name="nvidia-open-kernel-${dataproc_version}-$(date +%F)" | ||
disk_size_gb="50" | ||
|
||
python generate_custom_image.py \ | ||
--image-name ${image_name} \ | ||
--dataproc-version ${dataproc_version} \ | ||
--trusted-cert "tls/db.der" \ | ||
--customization-script ${customization_script} \ | ||
--metadata "${metadata}" \ | ||
--zone "${custom_image_zone}" \ | ||
--disk-size "${disk_size_gb}" \ | ||
--no-smoke-test \ | ||
--gcs-bucket "${my_bucket}" | ||
```bash | ||
cp examples/secure-boot/env.json.sample env.json | ||
vi env.json | ||
docker build -t dataproc-custom-images:latest . | ||
docker run -it dataproc-custom-images:latest /bin/bash examples/secure-boot/cuda.sh | ||
``` | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.