|
| 1 | +# OKE Custom Node Image Builder |
| 2 | + |
| 3 | +This project uses Packer to create custom images for Oracle Kubernetes Engine (OKE) nodes based on Oracle-provided base images. The customizations include: |
| 4 | +1. Updating all packages to their latest versions. |
| 5 | +2. Installing `oci-fss-utils` for in-transit encryption support. |
| 6 | +3. Upgrading to cgroups v2. |
| 7 | + |
| 8 | +## Prerequisites |
| 9 | +- Packer installed (version compatible with the oracle plugin ~>1). |
| 10 | +- Oracle Cloud Infrastructure (OCI) CLI configured with necessary credentials. |
| 11 | +- Access to an OCI compartment, subnet, and a base OKE node image OCID. |
| 12 | +- Only Oracle Linux 8 base images are supported for this Packer build. |
| 13 | +- If you're not an administrator, ensure your user group (e.g., PackerGroup) has the following OCI IAM policies: |
| 14 | + ``` |
| 15 | + Allow group PackerGroup to manage instance-family in compartment ${COMPARTMENT_NAME} |
| 16 | + Allow group PackerGroup to manage instance-images in compartment ${COMPARTMENT_NAME} |
| 17 | + Allow group PackerGroup to use virtual-network-family in compartment ${COMPARTMENT_NAME} |
| 18 | + Allow group PackerGroup to manage compute-image-capability-schema in tenancy |
| 19 | + ``` |
| 20 | + Replace `PackerGroup` with your actual group name and `${COMPARTMENT_NAME}` with your compartment name. |
| 21 | + |
| 22 | +## Setup |
| 23 | +1. Clone this repository or copy the files to your local machine. |
| 24 | +2. Edit `vars.pkrvars.hcl` to provide your specific OCI details (see below for placeholders). |
| 25 | + |
| 26 | +### Configuring vars.pkrvars.hcl |
| 27 | +Update the file with your values: |
| 28 | +- `availability_domain`: Your OCI availability domain (e.g., "XXXX:REGION-AD-1"). |
| 29 | +- `base_image_ocid`: OCID of the Oracle-provided OKE base image. To find the latest base image OCID, refer to the [Oracle Linux 8 OKE Worker Node Images documentation](https://docs.oracle.com/en-us/iaas/images/oke-worker-node-oracle-linux-8x/index.htm). |
| 30 | +- `compartment_ocid`: OCID of your OCI compartment. |
| 31 | +- `image_prefix`: Prefix for the generated image name (default: "oke-custom-image"). |
| 32 | +- `shape`: VM shape (e.g., "VM.Standard.E4.Flex"). |
| 33 | +- `ocpus`: Number of OCPUs (default: 1). |
| 34 | +- `memory_in_gbs`: Memory in GB (default: 8). |
| 35 | +- `subnet_ocid`: OCID of the subnet for the build instance. |
| 36 | +- `region`: OCI region (e.g., "eu-frankfurt-1"). |
| 37 | +- `skip_create_image`: Set to true to skip image creation (default: false). |
| 38 | + |
| 39 | +## Usage |
| 40 | +1. Ensure you're in the project directory. |
| 41 | +2. Run the build script: |
| 42 | + ``` |
| 43 | + ./run-packer.sh |
| 44 | + ``` |
| 45 | +3. Packer will provision a temporary instance, apply customizations, and create the custom image in your compartment. |
| 46 | + |
| 47 | +## Files Overview |
| 48 | +- `oke-custom-image.pkr.hcl`: Main Packer configuration. |
| 49 | +- `variables.pkr.hcl`: Variable definitions. |
| 50 | +- `vars.pkrvars.hcl`: User-configurable variables. |
| 51 | +- `run-packer.sh`: Script to execute the Packer build. |
| 52 | + |
| 53 | +## Troubleshooting |
| 54 | +- If the build fails, check OCI permissions and network access. |
| 55 | +- Use the `-debug` flag in run-packer.sh for detailed logs. |
| 56 | +- Base images are constantly updated by Oracle, ensure you use the latest OCID. |
| 57 | + |
| 58 | +For more details on Packer and OCI integration, refer to the [Packer OCI Plugin documentation](https://developer.hashicorp.com/packer/integrations/hashicorp/oracle/latest/components/builder/oci). |
0 commit comments