Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RHEL support for Nutanix to image-builder #2558

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion projects/aws/image-builder/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ func (b *BuildOptions) BuildImage() {

outputArtifactPath = filepath.Join(cwd, fmt.Sprintf("%s.gz", b.Os))
} else if b.Hypervisor == Nutanix {
// Set proxy on RHSM if available
if b.Os == RedHat && b.NutanixConfig.HttpProxy != "" {
if err := setRhsmProxy(&b.NutanixConfig.ProxyConfig, &b.NutanixConfig.RhsmConfig); err != nil {
log.Fatalf("Error parsing proxy host and port for RHSM: %v", err)
}
}

// Patch firmware config for tool
upstreamPatchCommand := fmt.Sprintf("make -C %s patch-repo", imageBuilderProjectPath)
if err := executeMakeBuildCommand(upstreamPatchCommand, commandEnvVars...); err != nil {
Expand All @@ -201,7 +208,23 @@ func (b *BuildOptions) BuildImage() {
log.Fatalf("Error writing nutanix config file to packer: %v", err)
}

buildCommand := fmt.Sprintf("make -C %s local-build-nutanix-ubuntu-%s", imageBuilderProjectPath, b.OsVersion)
var buildCommand string
switch b.Os {
case Ubuntu:
buildCommand = fmt.Sprintf("make -C %s local-build-nutanix-ubuntu-%s", imageBuilderProjectPath, b.OsVersion)
case RedHat:
buildCommand = fmt.Sprintf("make -C %s local-build-nutanix-redhat-%s", imageBuilderProjectPath, b.OsVersion)
commandEnvVars = append(commandEnvVars,
fmt.Sprintf("%s=%s", rhelUsernameEnvVar, b.NutanixConfig.RhelUsername),
fmt.Sprintf("%s=%s", rhelPasswordEnvVar, b.NutanixConfig.RhelPassword),
fmt.Sprintf("%s=%s", rhelImageUrlNutanixEnvVar, b.NutanixConfig.ImageUrl),
)
}

if b.NutanixConfig != nil {
commandEnvVars = append(commandEnvVars, fmt.Sprintf("%s=%s", packerNutanixVarFilesEnvVar, packerNutanixConfigFile))
}

err = executeMakeBuildCommand(buildCommand, commandEnvVars...)
if err != nil {
log.Fatalf("Error executing image-builder for nutanix hypervisor: %v", err)
Expand Down
2 changes: 2 additions & 0 deletions projects/aws/image-builder/builder/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ const (
packerAdditionalFilesConfigFileEnvVar string = "PACKER_ADDITIONAL_FILES_VAR_FILES"
rhelUsernameEnvVar string = "RHSM_USERNAME"
rhelPasswordEnvVar string = "RHSM_PASSWORD"
rhelImageUrlNutanixEnvVar string = "RHEL_IMAGE_URL"
rhsmActivationKeyEnvVar string = "RHSM_ACTIVATION_KEY"
rhsmOrgIDEnvVar string = "RHSM_ORG_ID"
packerTypeVarFilesEnvVar string = "PACKER_TYPE_VAR_FILES"
packerNutanixVarFilesEnvVar string = "PACKER_NUTANIX_VAR_FILES"
eksaUseDevReleaseEnvVar string = "EKSA_USE_DEV_RELEASE"

// Miscellaneous
Expand Down
5 changes: 4 additions & 1 deletion projects/aws/image-builder/builder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var SupportedUbuntuVersions = []string{

var SupportedRedHatVersions = []string{
"8",
"9",
}

var SupportedFirmwares = []string{
Expand Down Expand Up @@ -108,13 +109,15 @@ type RhelConfig struct {
type NutanixConfig struct {
ClusterName string `json:"nutanix_cluster_name"`
ImageName string `json:"image_name"`
SourceImageName string `json:"source_image_name"`
ImageUrl string `json:"image_url,omitempty"`
SourceImageName string `json:"source_image_name,omitempty"`
NutanixEndpoint string `json:"nutanix_endpoint"`
NutanixInsecure string `json:"nutanix_insecure"`
NutanixPort string `json:"nutanix_port"`
NutanixUserName string `json:"nutanix_username"`
NutanixPassword string `json:"nutanix_password"`
NutanixSubnetName string `json:"nutanix_subnet_name"`
RhelConfig
ProxyConfig
ExtraPackagesConfig
ExtraOverridesConfig
Expand Down
14 changes: 10 additions & 4 deletions projects/aws/image-builder/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func ValidateInputs(bo *builder.BuildOptions) error {
bo.OsVersion = "8"
}

if bo.Hypervisor != builder.Nutanix && bo.Os == builder.RedHat && bo.OsVersion != "8" {
log.Fatalf("Invalid OS version for RedHat. Please choose 8")
}

if err = validateOSVersion(bo.Os, bo.OsVersion); err != nil {
log.Fatal(err.Error())
}
Expand Down Expand Up @@ -181,6 +185,12 @@ func ValidateInputs(bo *builder.BuildOptions) error {
return err
}

if bo.Os == builder.RedHat {
if err = validateRedhat(&bo.NutanixConfig.RhelConfig, "Don't check IsoUrl Param"); err != nil {
return err
}
}

if bo.NutanixConfig.NutanixUserName == "" || bo.NutanixConfig.NutanixPassword == "" {
log.Fatalf("\"nutanix_username\" and \"nutanix_password\" are required fields in nutanix-config")
}
Expand Down Expand Up @@ -258,10 +268,6 @@ func validateOSHypervisorCombinations(os, hypervisor string) error {
return fmt.Errorf("Invalid OS type. Only redhat OS is supported for CloudStack")
}

if hypervisor == builder.Nutanix && os != builder.Ubuntu {
return fmt.Errorf("Invalid OS type. Only ubuntu OS is supported for Nutanix")
}

if hypervisor == builder.AMI && os != builder.Ubuntu {
return fmt.Errorf("Invalid OS type. Only ubuntu OS is supported for AMI")
}
Expand Down
4 changes: 2 additions & 2 deletions projects/aws/image-builder/cmd/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestValidateOSHypervisorCombinations(t *testing.T) {
Hypervisor: "nutanix",
Os: "redhat",
},
wantErr: "Invalid OS type. Only ubuntu OS is supported for Nutanix",
wantErr: "",
},
}

Expand Down Expand Up @@ -138,7 +138,7 @@ func TestValidateOSVersionCombinations(t *testing.T) {
Os: "redhat",
OsVersion: "9",
},
wantErr: "9 is not a supported version of Redhat. Please select one of 8",
wantErr: "",
},
{
testName: "Rockylinux 1",
Expand Down
11 changes: 7 additions & 4 deletions projects/kubernetes-sigs/image-builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ PACKER_OVA_VAR_FILES+=$(PACKER_OVA_CONF_FILE)
PACKER_RAW_VAR_FILES?=
PACKER_CLOUDSTACK_VAR_FILES?=

PACKER_NUTANIX_CONF_FILES=$(MAKE_ROOT)/packer/nutanix/nutanix.json
PACKER_NUTANIX_VAR_FILES+=$(PACKER_NUTANIX_CONF_FILES)
PACKER_NUTANIX_VAR_FILES?=$(MAKE_ROOT)/packer/nutanix/nutanix.json

PACKER_TYPE_VAR_FILES?=$(PACKER_$(call TO_UPPER,$(IMAGE_FORMAT))_VAR_FILES)
PACKER_ADDITIONAL_FILES_VAR_FILES?=
Expand Down Expand Up @@ -166,12 +165,12 @@ ALLOWED_OVA_OS=ubuntu bottlerocket redhat
ALLOWED_RAW_OS=ubuntu bottlerocket redhat
ALLOWED_CLOUDSTACK_OS=redhat
ALLOWED_AMI_OS=ubuntu bottlerocket
ALLOWED_NUTANIX_OS=ubuntu
ALLOWED_NUTANIX_OS=ubuntu redhat

ALLOWED_UBUNTU_VERSIONS=2004 2204
DEFAULT_UBUNTU_VERSION=2004

ALLOWED_REDHAT_VERSIONS=8
ALLOWED_REDHAT_VERSIONS=8 9
DEFAULT_REDHAT_VERSION=8

ALLOWED_BOTTLEROCKET_VERSIONS=1
Expand Down Expand Up @@ -433,8 +432,12 @@ release-ami-ubuntu-2204:

build-nutanix-ubuntu-2004:
build-nutanix-ubuntu-2204:
build-nutanix-redhat-8:
build-nutanix-redhat-9:
release-nutanix-ubuntu-2004:
release-nutanix-ubuntu-2204:
release-nutanix-redhat-8:
release-nutanix-redhat-9:

build-ova-ubuntu-2004:
build-ova-ubuntu-2204:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From d63488c1d3e6b4d8754066eda15dadb4c4ab2351 Mon Sep 17 00:00:00 2001
From 77387af616bd52c47525a2c5c86e430d3e4577e4 Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Tue, 11 Jan 2022 18:36:56 -0800
Subject: [PATCH 01/22] Add goss validations for EKS-D artifacts
Subject: [PATCH 01/25] Add goss validations for EKS-D artifacts

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
---
Expand Down Expand Up @@ -31,5 +31,5 @@ index 0fec04c4e..7bb9293fb 100644
stderr: []
timeout: 0
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 36050872c2a7b24d46919788f2c8c50a4bd67c56 Mon Sep 17 00:00:00 2001
From c1cf6093ad760214200f68f5f826c7d1c8b4f73f Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Tue, 11 Jan 2022 21:00:12 -0800
Subject: [PATCH 02/22] Output vsphere builds to content library instead of
Subject: [PATCH 02/25] Output vsphere builds to content library instead of
exports

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
Expand Down Expand Up @@ -98,5 +98,5 @@ index 64eb272cb..dc308e490 100644
}
}
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From beb55b7c85e2dc93b5f5c0a9c8d68290d48cc9e2 Mon Sep 17 00:00:00 2001
From f4ba98d94350e21f0b589a61ab1a1b35e74333b3 Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Tue, 11 Jan 2022 21:05:13 -0800
Subject: [PATCH 03/22] Create /etc/pki/tls/certs dir as part of image-builds
Subject: [PATCH 03/25] Create /etc/pki/tls/certs dir as part of image-builds

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
---
Expand Down Expand Up @@ -29,5 +29,5 @@ index 975506921..0aab7f565 100644
file:
path: /etc/systemd/system/containerd.service.d/http-proxy.conf
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 9f02ccac113f4682bae8d8090c0607014f463b91 Mon Sep 17 00:00:00 2001
From 6067b53b55e9d381ebd1be1ccc235ce40579ca9c Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Tue, 11 Jan 2022 21:12:53 -0800
Subject: [PATCH 04/22] Add etcdadm and etcd.tar.gz to image for unstacked etcd
Subject: [PATCH 04/25] Add etcdadm and etcd.tar.gz to image for unstacked etcd
support

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
Expand Down Expand Up @@ -83,5 +83,5 @@ index 9cce0a96a..ab5300ccc 100644
"kubernetes_apiserver_port": "6443",
"kubernetes_container_registry": "registry.k8s.io",
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From ae159da404950818d798d0f4c19c4ea155fe5c1a Mon Sep 17 00:00:00 2001
From 73436f46bf8fd6f0251a55c4dd0a2b3b9b691188 Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Tue, 11 Jan 2022 21:26:09 -0800
Subject: [PATCH 05/22] Additional EKS-A specific goss validations
Subject: [PATCH 05/25] Additional EKS-A specific goss validations

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
---
Expand Down Expand Up @@ -128,5 +128,5 @@ index dc308e490..0567fcd56 100644
"version": "{{user `goss_version`}}"
}
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 70613c7b58f1f8760077cd6b61e7a3749c928db2 Mon Sep 17 00:00:00 2001
From dc5a1d7f5501600e662e509cc21369968698c0dc Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Tue, 11 Jan 2022 21:29:16 -0800
Subject: [PATCH 06/22] Tweak Product info in OVF
Subject: [PATCH 06/25] Tweak Product info in OVF

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
---
Expand Down Expand Up @@ -35,5 +35,5 @@ index 316427ec3..ca23db5f9 100644
<Property ovf:userConfigurable="false" ovf:value="${BUILD_TIMESTAMP}" ovf:type="string" ovf:key="BUILD_TIMESTAMP"/>
<Property ovf:userConfigurable="false" ovf:value="${BUILD_DATE}" ovf:type="string" ovf:key="BUILD_DATE"/>
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 839cf56ca4919b662a19bcd1f1ceb251e99a515a Mon Sep 17 00:00:00 2001
From 649791272ebeeb070f58d4eb096c188507c5c4c7 Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Fri, 2 Sep 2022 14:32:21 -0700
Subject: [PATCH 07/22] Support crictl validation from input checksum
Subject: [PATCH 07/25] Support crictl validation from input checksum

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
---
Expand Down Expand Up @@ -38,5 +38,5 @@ index 9ae4f81b1..1ef16318a 100644
mode: 0600

--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From fdee87538968240c3384e23f50b495912564928e Mon Sep 17 00:00:00 2001
From 57394707343d15a11f5eaa95e7eecfac27532c1e Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Tue, 6 Dec 2022 15:42:02 -0600
Subject: [PATCH 08/22] Exclude kernel and cloud-init from yum updates
Subject: [PATCH 08/25] Exclude kernel and cloud-init from yum updates

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
---
Expand All @@ -21,5 +21,5 @@ index 66d9c8cac..0961f37d4 100644

- name: install baseline dependencies
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 2c48ebfc86fa43c4adb8784b0306ef986cecff93 Mon Sep 17 00:00:00 2001
From c5d465abe5c4990407b0bb1ae8a5f509dd0e55a1 Mon Sep 17 00:00:00 2001
From: Vignesh Goutham Ganesh <[email protected]>
Date: Mon, 9 Jan 2023 14:11:18 -0600
Subject: [PATCH 09/22] Patch cloud-init systemd unit to wait for network
Subject: [PATCH 09/25] Patch cloud-init systemd unit to wait for network
manager online

Signed-off-by: Vignesh Goutham Ganesh <[email protected]>
Expand Down Expand Up @@ -47,5 +47,5 @@ index 7b1cb93ce..fd93ef4b2 100644
# Enable all cloud-init services on boot.
- name: Make sure all cloud init services are enabled
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 7d1bd7af0d8df722156ecabc3829e74985f2baf5 Mon Sep 17 00:00:00 2001
From 3b894353bd052b36d4fc6afe61888ddd4eba67e2 Mon Sep 17 00:00:00 2001
From: Abhay Krishna Arunachalam <[email protected]>
Date: Thu, 2 Feb 2023 01:39:15 -0800
Subject: [PATCH 10/22] Add instance metadata options to Packer config
Subject: [PATCH 10/25] Add instance metadata options to Packer config

Signed-off-by: Abhay Krishna Arunachalam <[email protected]>
---
Expand Down Expand Up @@ -35,5 +35,5 @@ index 3117354cd..175ca11d6 100644
"ib_version": "{{env `IB_VERSION`}}",
"iops": "3000",
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 03a34c9a1742e681a117a23c271bfeee40a1ce59 Mon Sep 17 00:00:00 2001
From 174958df5393fe070de05dc38480195a835f14eb Mon Sep 17 00:00:00 2001
From: Abhay Krishna Arunachalam <[email protected]>
Date: Fri, 10 Feb 2023 16:08:18 -0800
Subject: [PATCH 11/22] Rename Snow node image to reflect appropriate CAPI
Subject: [PATCH 11/25] Rename Snow node image to reflect appropriate CAPI
provider

Signed-off-by: Abhay Krishna Arunachalam <[email protected]>
Expand All @@ -23,5 +23,5 @@ index 175ca11d6..cb6fbb470 100644
"ami_regions": "{{user `ami_regions`}}",
"ami_users": "{{user `ami_users`}}",
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 1c18f29813aea77c65d5891941d2b23055048a9c Mon Sep 17 00:00:00 2001
From 2d18d5c4c61cf2415e378a80675eca795de73db5 Mon Sep 17 00:00:00 2001
From: Abhay Krishna Arunachalam <[email protected]>
Date: Thu, 2 Mar 2023 19:27:50 -0800
Subject: [PATCH 12/22] Add EKS-A specific inline Goss vars to all supported
Subject: [PATCH 12/25] Add EKS-A specific inline Goss vars to all supported
providers

Signed-off-by: Abhay Krishna Arunachalam <[email protected]>
Expand Down Expand Up @@ -85,5 +85,5 @@ index 152041455..a04be4e8f 100644
"version": "{{user `goss_version`}}"
}
--
2.40.1
2.39.2

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From efa4c0fb7f8e676f38f35bd6b497274fb0d17eae Mon Sep 17 00:00:00 2001
From d1e8e6db38ae280f966ccfca2cae39111ed34868 Mon Sep 17 00:00:00 2001
From: Abhay Krishna Arunachalam <[email protected]>
Date: Thu, 9 Mar 2023 16:05:22 -0800
Subject: [PATCH 13/22] Use tar.gz extension for CNI plugins tarball
Subject: [PATCH 13/25] Use tar.gz extension for CNI plugins tarball

Signed-off-by: Abhay Krishna Arunachalam <[email protected]>
---
Expand All @@ -22,5 +22,5 @@ index 48a4a2177..99bf2f843 100644
dest: /tmp/cni.tar.gz
mode: 0755
--
2.40.1
2.39.2

Loading