Skip to content

Commit

Permalink
Merge pull request #87 from sriramandev/topic/sriramandev/support-1.31.1
Browse files Browse the repository at this point in the history
Add support for v1.31.1 vSphere Kubernetes Release
  • Loading branch information
galop authored Oct 8, 2024
2 parents 0012a10 + 98c2dcb commit 90cf123
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 166 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.vscode
!.gitignore
scripts/__pycache__
output*
output*
.idea
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ make build-node-image OS_TARGET=photon-3 KUBERNETES_VERSION=v1.23.15+vmware.1 TK

Sample customization examples can be found [here](docs/examples/README.md)

For Windows support you may refer to [Windows tutorial](docs/windows.md)

## Debugging

- To enable debugging for the [make file scripts](hack/make-helpers/) export `DEBUGGING=true`.
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Examples

This document gives information about different customization examples to customize a Node image for Tanzu on vSphere.
This document gives information about how to build Kubernetes Release on vSphere Node image and different customization examples to customize the Node image.

- [Changing VM Hardware Version(VMX version)](changing_hardware_version.md)
- [Adding new OS packages and configuring the repositories or sources](adding_os_pkg_repos.md).
- [Running Prometheus node exporter service on the nodes](prometheus_node_exporter.md)
- [Tutorial for Using the vSphere Tanzu Kubernetes Grid Image Builder](tutorial_building_an_image.md)
- [Changing VM Hardware Version(VMX version)](./customizations/changing_hardware_version.md)
- [Adding new OS packages and configuring the repositories or sources](./customizations/adding_os_pkg_repos.md).
- [Running Prometheus node exporter service on the nodes](./customizations/prometheus_node_exporter.md)
109 changes: 0 additions & 109 deletions docs/examples/adding_os_pkg_repos.md

This file was deleted.

12 changes: 12 additions & 0 deletions docs/examples/customizations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Examples

This document gives information about different customization examples to customize a Kubernetes Release on vSphere Node image.

- [Changing VM Hardware Version(VMX version)][hardware-version]
- [Adding new OS packages and configuring the repositories or sources][custom-package-repos].
- [Running Prometheus node exporter service on the nodes][prometheus-node-exporter]

[//]: Links
[hardware-version]: changing_hardware_version.md
[custom-package-repos]: adding_os_pkg_repos.md
[prometheus-node-exporter]: prometheus_node_exporter.md
114 changes: 114 additions & 0 deletions docs/examples/customizations/adding_os_pkg_repos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Adding new OS packages and configuring the repositories or sources

## Use case

As a user I want to

1. Add new OS packages such as `pkg1` and `pkg2`.
2. Configure sources/repositories to an internal mirror to build the node images in an air-gapped scenario. Configuring new sources/repositories is also useful when we want to install internally built software.

## Customization

Configuration of OS packages and sources/repositories is exposed as packer variables. To view a list of packer variables exposed by [kubernetes image builder][kubernetes-image-builder] please refer to this [page][customizations-doc].

### Adding new packages

To add new packages [kubernetes image builder][kubernetes-image-builder] provides `extra_rpms` and `extra_debs` packer variables for Photon and Ubuntu respectively.

To add new packages to Ubuntu 22.04, add the packages to the packer variables in the [default-args-ubuntu-2204-efi.j2][default-args-ubuntu-2204-efi] file as shown below.

```jinja
"extra_debs": "existing_packages pkg1 pkg2"
```

To add new packages to Photon 5, add the packages to the packer variables in the [default-args-photon-5.j2][default-args-photon-5] file as shown below.

```jinja
"extra_rpms": "existing_packages pkg1 pkg2"
```

_**Note**: The location of default configuration specific to OS follows the path nomenclature, `packer-variables/<OS>-<Version>/default-args-<OS>-<version>.j2`. Include `-efi` suffix as well along with the version for Ubuntu._

### Configuring new sources/repositories

[kubernetes image builder][kubernetes-image-builder] provides `extra_repos` packer variables through which sources/repositories can be configured for both Photon and Ubuntu. As there is a difference in how Ubuntu/Photon sources are configured we need to have separate source files for Photon/Ubuntu.

- Create new folder `repos` in [ansible files][ansible-files] folder
- Depending upon the Linux OS flavour, use either of the below steps
- For **Photon** sources, create a new file called `photon.repo` in the `repos` folder. Refer below for sample content and refer to the official Photon [document][photon-repo-doc] for more information.

```text
[photon]
name=VMware Photon Linux $releasever ($basearch)
baseurl=<internal_mirror_url>/$releasever/photon_release_$releasever_$basearch
gpgkey=<gpg_key>
gpgcheck=1
enabled=1
[photon-updates]
name=VMware Photon Linux $releasever ($basearch) Updates
baseurl=<internal_mirror_url>/$releasever/photon_updates_$releasever_$basearch
gpgkey=<gpg_key>
gpgcheck=1
enabled=1
[photon-extras]
name=VMware Photon Extras $releasever ($basearch)
baseurl=<internal_mirror_url>/$releasever/photon_extras_$releasever_$basearch
gpgkey=<gpg_key>
gpgcheck=1
enabled=1
```

- For **Ubuntu** sources, create a new file called `ubuntu.list` in the `repos` folder. Refer to the official ubuntu [documentation][ubuntu-sources-doc] for more information.
- _**Note**: `jammy` is for ubuntu 22.04 so this needs to be changed if the ubuntu version is also changed, example for ubuntu 20.04 it is `focal`_

```text
deb <internal_source_url> jammy main restricted universe
deb <internal_source_url> jammy-security main restricted
deb <internal_source_url> jammy-updates main restricted
```

- Create a new file `repos.j2` in [packer-variables][packer-variables] folder for configuring the `extra_repos` packer variable folder. (Uses [jinja][jinja] templating)

```jinja
{
{% if os_type == "photon-5" %}
"extra_repos": "/image-builder/images/capi/image/ansible/files/repos/photon.repo"
{% elif os_type == "ubuntu-2204-efi" %}
"extra_repos": "/image-builder/images/capi/image/ansible/files/repos/ubuntu.list"
{% endif %}
}
```

### Disabling public repositories/sources

For disabling public repos set the `disable_public_repos` packer variable to `true` in the `repos.j2` file.

### Removing the extra repositories/sources

To remove the extra repositories/sources that were configured during the image build process set the `remove_extra_repos` packer variable to `true`.

```jinja
{
"disable_public_repos": true,
"remove_extra_repos": true
{% if os_type == "photon-5" %}
"extra_repos": "/image-builder/images/capi/image/ansible/files/repos/photon.repo"
{% elif os_type == "ubuntu-2204-efi" %}
"extra_repos": "/image-builder/images/capi/image/ansible/files/repos/ubuntu.list"
{% endif %}
}
```

[//]: Links

[ansible-files]: ./../../ansible/files/
[customizations-doc]: https://image-builder.sigs.k8s.io/capi/capi.html#customization
[jinja]: https://jinja.palletsprojects.com/en/3.1.x/
[kubernetes-image-builder]: https://github.com/kubernetes-sigs/image-builder/
[photon-repo-doc]: https://vmware.github.io/photon/assets/files/html/3.0/photon_admin/adding-a-new-repository.html
[ubuntu-sources-doc]: https://manpages.ubuntu.com/manpages/focal/man5/sources.list.5.html
[default-args-ubuntu-2204-efi]: ../../packer-variables/ubuntu-2204-efi/default-args-ubuntu-2204-efi.j2
[default-args-photon-5]: ../../packer-variables/photon-5/default-args-photon-5.j2
[packer-variables]: ./../../packer-variables/
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ As a customer, I want to change the Hardware version of the node image to use th

## Background

By default, node images use the hardware version(`VMX`) 17. Please refer to the below documents to learn more about the hardware version and its compatibility with the vSphere environment.
By default, node images use the hardware version(`VMX`) 17 defined in [default-args.j2][default-args](Windows uses hardware version 18 by default defined in [default-args-windows.j2][default-args-windows]). Please refer to the below documents to learn more about the hardware version and its compatibility with the vSphere environment.

- [Hardware Features Available with Virtual Machine Compatibility Settings](https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-vm-administration/GUID-789C3913-1053-4850-A0F0-E29C3D32B6DA.html)
- [ESXi/ESX hosts and compatible virtual machine hardware versions list](https://kb.vmware.com/s/article/2007240)
Expand All @@ -19,7 +19,10 @@ By default, node images use the hardware version(`VMX`) 17. Please refer to the
"vmx_version": "17",
```

- _**Note**: For Windows, update the `vmx_version` in the [default-args-windows.j2][default-args-windows] file._

[//]: Links

[default-args]: [./../../../packer-variables/default-args.j2]
[kubernetes-image-builder]: https://github.com/kubernetes-sigs/image-builder/
[default-args-windows]: ../../packer-variables/windows/default-args-windows.j2
File renamed without changes.
Loading

0 comments on commit 90cf123

Please sign in to comment.