|
1 | 1 | # Images |
2 | 2 |
|
3 | | -This directory contains Cloud Build configuration files, Packer templates and scripts used for building DAOS images with [Cloud Build](https://cloud.google.com/build). |
| 3 | +This directory contains files necessary for building DAOS images using [Cloud Build](https://cloud.google.com/build) and [Packer](https://developer.hashicorp.com/packer/downloads). |
4 | 4 |
|
5 | 5 | ## Pre-Deployment steps required |
6 | 6 |
|
7 | 7 | If you have not done so yet, please complete the steps in [Pre-Deployment Guide](../docs/pre-deployment_guide.md). |
8 | 8 |
|
| 9 | +The pre-deployment steps will have you run the `images/build.sh` script once in order to build a DAOS server image and a DAOS client image with the configured default settings. |
| 10 | + |
| 11 | +That should be all you need to run the Terraform examples in the `terraform/examples` directory or to run the [DAOS examples in the Google HPC Toolkit](https://github.com/GoogleCloudPlatform/hpc-toolkit/tree/main/community/examples/intel). |
| 12 | + |
| 13 | +The information in this document is provided in case you need to build custom images with non-default settings. |
| 14 | + |
9 | 15 | ## Building DAOS images |
10 | 16 |
|
11 | | -The [Pre-Deployment Guide](../docs/pre-deployment_guide.md) includes instructions for building DAOS images. |
| 17 | +To rebuild the images with the default settings run: |
| 18 | + |
| 19 | +```bash |
| 20 | +cd images |
| 21 | +./build.sh |
| 22 | +``` |
| 23 | + |
| 24 | +## The Packer HCL template file |
| 25 | + |
| 26 | +A single Packer HCL template file `daos.pkr.hcl` is used to build either a DAOS server or DAOS client image. |
| 27 | + |
| 28 | +The `daos.pkr.hcl` file does not build both server and client images in a single `packer build` run. This is by design since there are use cases in which only one type of image is needed. If both types of images are needed, then `packer build` must be run twice with different variable values. |
| 29 | + |
| 30 | +### Source Block |
| 31 | + |
| 32 | +Within the `daos.pkr.hcl` template there is a single `source` block. Most of the settings for the block are set by variable values. |
| 33 | + |
| 34 | +### Build Block |
| 35 | + |
| 36 | +The `build` block consists of provisioners that do the following: |
| 37 | + |
| 38 | +1. Install Ansible |
| 39 | +2. Run the `ansible_playbooks/tune.yml` playbook |
| 40 | +3. Run the `ansible_playbooks/daos.yml` playbook |
| 41 | + |
| 42 | +These provisioners are the same for building both DAOS server and DAOS client images. |
| 43 | + |
| 44 | +The `daos_install_type` variable in the `daos.pkr.hcl` template is passed in the `--extra-vars` parameter when running the `daos.yml` ansible playbook. |
| 45 | + |
| 46 | +If `daos_install_type=server`, then the `daos.yml` playbook will install the DAOS server packages. |
| 47 | + |
| 48 | +If `daos_install_type=client`, then the `daos.yml` playbook will install the DAOS client packages. |
| 49 | + |
| 50 | +## `build.sh` environment variables |
| 51 | + |
| 52 | +The `images/build.sh` script uses the following environment variables. |
| 53 | + |
| 54 | +| Environment Variable | Description | |
| 55 | +| ---------------------------- | ---------------------------------------------------------- | |
| 56 | +| GCP_PROJECT | Google Cloud Project ID | |
| 57 | +| GCP_ZONE | Zone where images will be deployed | |
| 58 | +| GCP_BUILD_WORKER_POOL | Google Cloud Build Worker Pool | |
| 59 | +| GCP_USE_IAP | Use Identity Aware Proxy | |
| 60 | +| GCP_ENABLE_OSLOGIN | Enable os-login | |
| 61 | +| GCP_USE_CLOUDBUILD | Run packer in a Cloud Build job | |
| 62 | +| GCP_CONFIGURE_PROJECT | Configure default service acct for Cloud Build | |
| 63 | +| DAOS_VERSION | Version of DAOS to install | |
| 64 | +| DAOS_REPO_BASE_URL | Base URL of DAOS Repository | |
| 65 | +| DAOS_PACKAGES_REPO_FILE | See "Controlling the version of DAOS to be installed" | |
| 66 | +| DAOS_MACHINE_TYPE | The machine type to use for the image | |
| 67 | +| DAOS_SOURCE_IMAGE_FAMILY | Source image family that Packer will use as the base image | |
| 68 | +| DAOS_SOURCE_IMAGE_PROJECT_ID | Source project id that contains the source image | |
| 69 | +| DAOS_SERVER_IMAGE_FAMILY | Name of the image family for the DAOS Server image | |
| 70 | +| DAOS_CLIENT_IMAGE_FAMILY | Name of the image family for the DAOS Client image | |
| 71 | +| DAOS_BUILD_SERVER_IMAGE | Whether or not build the DAOS Server image | |
| 72 | +| DAOS_BUILD_CLIENT_IMAGE | Whether or not build the DAOS Client image | |
| 73 | +| DAOS_PACKER_TEMPLATE | Name of the Packer template | |
| 74 | + |
| 75 | +To view the default values for these variables see the defaults set in the `build.sh` script. |
| 76 | + |
| 77 | +Running `build.sh --help` will display the values of these variables so that you can inspect them before running `build.sh` |
| 78 | + |
| 79 | +### Controlling the version of DAOS to be installed |
| 80 | + |
| 81 | +Official DAOS packages are hosted at https://packages.daos.io/ |
| 82 | + |
| 83 | +Unfortunately, the paths to the `.repo` files for each repository do not follow a standard convention that can be dynamically created based on something like the `/etc/os-release` file. |
| 84 | + |
| 85 | +To specify the path to a repo file the following 3 environment variables are used: |
| 86 | + |
| 87 | +- `DAOS_REPO_BASE_URL` |
| 88 | +- `DAOS_VERSION` |
| 89 | +- `DAOS_PACKAGES_REPO_FILE` |
| 90 | + |
| 91 | +These files are used to build the url to the `daos_packages.repo` file. |
| 92 | + |
| 93 | +``` |
| 94 | +"${DAOS_REPO_BASE_URL}/v${DAOS_VERSION}/${DAOS_PACKAGES_REPO_FILE} |
| 95 | +``` |
| 96 | + |
| 97 | +The values of these variables should not start or end with a `/` |
| 98 | + |
| 99 | +**Examples:** |
12 | 100 |
|
13 | | -You can re-build your images with the following commands. |
| 101 | + To install DAOS v2.2.0 on CentOS 7 |
14 | 102 |
|
15 | | -Build both DAOS server and client images |
| 103 | + ```bash |
| 104 | + DAOS_REPO_BASE_URL=https://packages.daos.io |
| 105 | + DAOS_VERSION="2.2.0" |
| 106 | + DAOS_PACKAGES_REPO_FILE="CentOS7/packages/x86_64/daos_packages.repo" |
| 107 | + ``` |
| 108 | + |
| 109 | + To install DAOS v2.2.0 on Rocky 8 |
| 110 | + |
| 111 | + ```bash |
| 112 | + DAOS_REPO_BASE_URL=https://packages.daos.io |
| 113 | + DAOS_VERSION="2.2.0" |
| 114 | + DAOS_PACKAGES_REPO_FILE="EL8/packages/x86_64/daos_packages.repo" |
| 115 | + ``` |
| 116 | + |
| 117 | +## Building only the DAOS Server or the DAOS Client image |
| 118 | + |
| 119 | +If you do not want to build one of the images, you must set the appropriate environment variable. |
| 120 | + |
| 121 | +For example, |
| 122 | + |
| 123 | +To build only the DAOS Server image |
16 | 124 |
|
17 | 125 | ```bash |
18 | | -cd images/ |
19 | | -./build_images.sh --type all |
| 126 | +cd images |
| 127 | +export DAOS_BUILD_CLIENT_IMAGE="false" # Do not run the job to build the DAOS client image |
| 128 | +./build.sh |
20 | 129 | ``` |
21 | 130 |
|
22 | | -Build a DAOS server image |
| 131 | +To build only the DAOS Client image |
23 | 132 |
|
24 | 133 | ```bash |
25 | | -cd images/ |
26 | | -./build_images.sh --type server |
| 134 | +cd images |
| 135 | +export DAOS_BUILD_SERVER_IMAGE="false" # Do not run the job to build the DAOS server image |
| 136 | +./build.sh |
27 | 137 | ``` |
28 | 138 |
|
29 | | -Build a DAOS client image |
| 139 | +## Custom image builds |
| 140 | + |
| 141 | +To create images that do not use the default settings, export one or more of the environment variables listed above before running `build.sh` |
| 142 | + |
| 143 | +### Change the name of the image family |
30 | 144 |
|
31 | 145 | ```bash |
32 | | -cd images/ |
33 | | -./build_images.sh --type client |
| 146 | +cd images |
| 147 | +export DAOS_SERVER_IMAGE_FAMILY="my-daos-server" |
| 148 | +export DAOS_CLIENT_IMAGE_FAMILY="my-daos-client" |
| 149 | +./build.sh |
34 | 150 | ``` |
| 151 | + |
| 152 | +### Use a different source image |
| 153 | + |
| 154 | +For the source image, use the `rocky-linux-8-optimized-gcp` community image instead of the `hpc-rocky-linux-8` image. |
| 155 | + |
| 156 | +```bash |
| 157 | +cd images |
| 158 | +export DAOS_SOURCE_IMAGE_FAMILY="rocky-linux-8-optimized-gcp" |
| 159 | +export DAOS_SOURCE_IMAGE_PROJECT_ID="rocky-linux-cloud" |
| 160 | +./build.sh |
| 161 | +``` |
| 162 | + |
| 163 | +### Other Scenarios |
| 164 | + |
| 165 | +Say you want to make the following customizations to the images: |
| 166 | + |
| 167 | +1. Change the image family names of the DAOS Server and DAOS Client images |
| 168 | +2. Use `hpc-rocky-linux-8` as the source image for the DAOS client image (the default). |
| 169 | +3. Use `rocky-linux-8-optimized-gcp` as the source image for the DAOS server image. |
| 170 | + |
| 171 | +In this scenario it will be necessary to run the `build.sh` script two times with |
| 172 | +different environment variables. |
| 173 | + |
| 174 | +**Build Client Image** |
| 175 | + |
| 176 | +```bash |
| 177 | +cd images |
| 178 | +export DAOS_BUILD_CLIENT_IMAGE="true" # Build client image |
| 179 | +export DAOS_CLIENT_IMAGE_FAMILY="daos-client" # Change image family name for client image |
| 180 | + |
| 181 | +export DAOS_BUILD_SERVER_IMAGE="false" # Do not build server image |
| 182 | +./build.sh |
| 183 | +``` |
| 184 | + |
| 185 | +**Build Server Image** |
| 186 | + |
| 187 | +```bash |
| 188 | +cd images |
| 189 | +export DAOS_BUILD_CLIENT_IMAGE="false" # Do not build client image |
| 190 | +export DAOS_BUILD_SERVER_IMAGE="true" # Build server image |
| 191 | +export DAOS_SERVER_IMAGE_FAMILY="daos-server" # Change image family name for server image |
| 192 | +export DAOS_SOURCE_IMAGE_FAMILY="rocky-linux-8-optimized-gcp" # Change source image family |
| 193 | +export DAOS_SOURCE_IMAGE_PROJECT_ID="rocky-linux-cloud" # Change source image project |
| 194 | +./build.sh |
| 195 | +``` |
| 196 | + |
| 197 | +## Running packer locally (Do not use Cloud Build) |
| 198 | + |
| 199 | +Set `GCP_USE_CLOUDBUILD="false"` to run `packer` locally instead of running it in a Cloud Build job. |
| 200 | + |
| 201 | +```bash |
| 202 | +cd images |
| 203 | +export GCP_USE_CLOUDBUILD="false" # Do not run packer in Cloud Build |
| 204 | +./build.sh |
| 205 | +``` |
| 206 | + |
| 207 | +When running `build.sh` this way, all project configuration steps are skipped. |
| 208 | + |
| 209 | +When `GCP_USE_CLOUDBUILD="true"` the `build.sh` will check your GCP project to ensure the default service account has the proper permissions needed for the Cloud Build job to run packer and create the images in your project. Setting `GCP_USE_CLOUDBUILD="true"` will skip the project configuration steps. In this case, it's up to you to make sure the proper permissions are configured for you to run packer locally to build the images. |
0 commit comments