Skip to content
Merged
74 changes: 74 additions & 0 deletions _partials/capi-image-builder/_build-custom-image-intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
partial_category: capi-image-builder
partial_name: build-custom-image-intro
---

1. Open a terminal session on your Linux machine and set your CAPI Image Builder version tag as a variable. This guide
uses version 4.6.24 as an example. Refer to the CAPI Image Builder
[Downloads](/downloads/capi-image-builder) page for the latest version.

```shell
CAPI_IMAGE_BUILDER_VERSION=<capi-image-builder-version-tag>
echo CAPI Image Builder version: $CAPI_IMAGE_BUILDER_VERSION
```

```shell title="Example output"
CAPI Image Builder version: v4.6.24
```

2. Download the CAPI Image Builder image.

<Tabs groupId="container-tech">

<TabItem value="Docker" label="Docker">

```shell
docker pull us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder:$CAPI_IMAGE_BUILDER_VERSION
```

Confirm that the image was downloaded correctly.

```shell
docker images
```

```text hideClipboard title="Example output"
REPOSITORY TAG IMAGE ID CREATED SIZE
us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder v4.6.24 2adff15eee2d 7 days ago 2.09GB
```

</TabItem>

<TabItem value="Podman" label="Podman">

```shell
podman pull us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder:$CAPI_IMAGE_BUILDER_VERSION
```

Confirm that the image was downloaded correctly.

```shell
podman images
```

```text hideClipboard title="Example output"
REPOSITORY TAG IMAGE ID CREATED SIZE
us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder v4.6.24 2adff15eee2d 7 days ago 2.09GB
```

</TabItem>

</Tabs>

3. Create an `output` directory to store the image files and set the required permissions.

```shell
mkdir /home/$USER/output
chmod a+rwx /home/$USER/output
```

4. Navigate to the `output` directory.

```shell
cd /home/$USER/output
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ partial_name: download-capi-image-builder-repository
<TabItem value="Docker" label="Docker">

```shell
docker pull us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder:v4.6.23
docker pull us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder:v4.6.24
```

Confirm that the image was downloaded correctly.
Expand All @@ -19,15 +19,15 @@ partial_name: download-capi-image-builder-repository

```text hideClipboard title="Example output"
REPOSITORY TAG IMAGE ID CREATED SIZE
us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder v4.6.23 2adff15eee2d 7 days ago 2.47 GB
us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder v4.6.24 2adff15eee2d 7 days ago 2.09GB
```

</TabItem>

<TabItem value="Podman" label="Podman">

```shell
podman pull us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder:v4.6.23
podman pull us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder:v4.6.24
```

Confirm that the image was downloaded correctly.
Expand All @@ -38,7 +38,7 @@ partial_name: download-capi-image-builder-repository

```text hideClipboard title="Example output"
REPOSITORY TAG IMAGE ID CREATED SIZE
us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder v4.6.23 2adff15eee2d 7 days ago 2.47 GB
us-docker.pkg.dev/palette-images/palette/imagebuilder/capi-builder v4.6.24 2adff15eee2d 7 days ago 2.09GB
```

</TabItem>
Expand Down
56 changes: 56 additions & 0 deletions _partials/capi-image-builder/_ssh-vm.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
partial_category: capi-image-builder
partial_name: ssh-vm
---

Locate the new Rocky image VM in your VMware vSphere environment. Right-click the VM and select **Clone > Clone to
Template**.

:::tip

Once the image is built, you can connect to the image via SSH. The following steps are based on guidance from the
[Image Builder Book](https://image-builder.sigs.k8s.io/capi/providers/vsphere#accessing-remote-vms).

<details>

<summary> Connect to image VM with SSH </summary>

1. On a machine with [govc](https://github.com/vmware/govmomi/tree/main/govc) installed and configured with your
VMware vSphere credentials, clone the
[Kubernetes Image Builder repository](https://github.com/kubernetes-sigs/image-builder).

2. Navigate to the `capi` directory of the Kubernetes Image Builder repository.

```shell
cd ./image-builder/images/capi/
```

3. Run the Kubernetes Image Builder `image-govc-cloudinit.sh` script and pass in the `image_name` of your Rocky
image VM as specified in the `imageconfig` file. This creates a snapshot of the image and updates it with the
data located in the `cloudinit` directory. Ensure the VM is off before running the command.

```shell
./hack/image-govc-cloudinit.sh <image_name>
```

```shell title="Example output"
image-govc-cloudinit: creating snapshot 'new'
image-govc-cloudinit: initializing cloud-init data
image-govc-cloudinit: creating snapshot 'cloudinit'
```

4. Set read-write permissions for the owner of the `id_rsa.capi` file.

```shell
chmod 600 cloudinit/id_rsa.capi
```

5. Power on the Rocky image VM.

6. Connect to the VM via SSH using your `id_rsa.capi` key. Replace `<vm-ip>` with the IP of your Rocky image VM.

```shell
ssh -i cloudinit/id_rsa.capi capv@<vm-ip>
```

</details>
Loading
Loading