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

Support for AWS RHEL instances on arm64 arch #240

Merged
merged 3 commits into from
Jul 1, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Also mapt offers a set of features wich are transversal to each type of target m
| Mac | x86, M1, M2 | AWS | Baremetal | [info](docs/aws/mac.md) | [task](tkn/infra-aws-mac.yaml) | a |
| Windows Server | x86 | AWS | Baremetal | [info](docs/aws/windows.md)| [task](tkn/infra-aws-windows-server.yaml) | a,s |
| Windows Desktop| x86 | Azure | Virtualized | [info](docs/azure.md) | [task](tkn/infra-azure-windows-desktop.yaml) | s |
| RHEL | x86 | AWS | Baremetal | [info](docs/aws/rhel.md) | [task](tkn/infra-aws-rhel.yaml) | a,s |
| RHEL | x86, arm64 | AWS | Baremetal | [info](docs/aws/rhel.md) | [task](tkn/infra-aws-rhel.yaml) | a,s |
| Fedora | x86 | AWS | Baremetal | [info](docs/aws/fedora.md) | [task](tkn/infra-aws-fedora.yaml) | a,s |

Features:
Expand Down
7 changes: 6 additions & 1 deletion cmd/cmd/aws/hosts/rhel.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const (

rhelVersion string = "version"
rhelVersionDesc string = "version for the RHEL OS"
rhelVersionDefault string = "9.3"
rhelVersionDefault string = "9.4"
rhelArch string = "arch"
rhelArchDesc string = "architecture for the machine. Allowed x86_64 or arm64"
rhelArchDefault string = "x86_64"
subsUsername string = "rh-subscription-username"
subsUsernameDesc string = "username to register the subscription"
subsUserpass string = "rh-subscription-password"
Expand Down Expand Up @@ -61,6 +64,7 @@ func getRHELCreate() *cobra.Command {
&rhel.Request{
Prefix: "main",
Version: viper.GetString(rhelVersion),
Arch: viper.GetString(rhelArch),
SubsUsername: viper.GetString(subsUsername),
SubsUserpass: viper.GetString(subsUserpass),
ProfileSNC: viper.IsSet(profileSNC),
Expand All @@ -75,6 +79,7 @@ func getRHELCreate() *cobra.Command {
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
flagSet.StringP(rhelVersion, "", rhelVersionDefault, rhelVersionDesc)
flagSet.StringP(rhelArch, "", rhelArchDefault, rhelArchDesc)
flagSet.StringP(subsUsername, "", "", subsUsernameDesc)
flagSet.StringP(subsUserpass, "", "", subsUserpassDesc)
flagSet.Bool(airgap, false, airgapDesc)
Expand Down
18 changes: 17 additions & 1 deletion docs/aws/rhel.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ Usage:

Flags:
--airgap if this flag is set the host will be created as airgap machine. Access will done through a bastion
--arch string architecture for the machine. Allowed x86_64 or arm64 (default "x86_64")
--conn-details-output string path to export host connection information (host, username and privateKey)
-h, --help help for create
--rh-subscription-password string password to register the subscription
--rh-subscription-username string username to register the subscription
--snc if this flag is set the RHEL will be setup with SNC profile. Setting up all requirements to run https://github.com/crc-org/snc
--spot if this flag is set the host will be created only on the region set by the AWS Env (AWS_DEFAULT_REGION)
--tags stringToString tags to add on each resource (--tags name1=value1,name2=value2) (default [])
--version string version for the RHEL OS (default "9.3")
--version string version for the RHEL OS (default "9.4")

Global Flags:
--backed-url string backed for stack state. Can be a local path with format file:///path/subpath or s3 s3://existing-bucket
Expand All @@ -48,6 +49,7 @@ Global Flags:
When running the container image it is required to pass the authetication information as variables(to setup AWS credentials there is a [helper script](./../../hacks/aws_setup.sh)), following a sample snipped on how to create an instance with default values:

```bash
# x86_64
podman run -d --name mapt-rhel \
-v ${PWD}:/workspace:z \
-e AWS_ACCESS_KEY_ID=XXX \
Expand All @@ -59,4 +61,18 @@ podman run -d --name mapt-rhel \
--rh-subscription-password XXXX \
--rh-subscription-username XXXXX \
--conn-details-output /workspace

# arm64
podman run -d --name mapt-rhel \
-v ${PWD}:/workspace:z \
-e AWS_ACCESS_KEY_ID=XXX \
-e AWS_SECRET_ACCESS_KEY=XXX \
-e AWS_DEFAULT_REGION=us-east-1 \
quay.io/redhat-developer/mapt:0.7.0-dev aws rhel create \
--project-name mapt-rhel \
--arch arm64 \
--backed-url file:///workspace \
--rh-subscription-password XXXX \
--rh-subscription-username XXXXX \
--conn-details-output /workspace
```
12 changes: 9 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ require (
github.com/pulumi/pulumi-tls/sdk/v5 v5.0.3
)

require (
github.com/hashicorp/hcl v1.0.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/tools v0.22.0 // indirect
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.9.0 // indirect
Expand Down Expand Up @@ -57,8 +63,8 @@ require (
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
// github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.20.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
Expand Down Expand Up @@ -139,7 +145,7 @@ require (
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
lukechampine.com/frand v1.4.2 // indirect
Expand Down
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI=
github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE=
github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc=
github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
Expand Down Expand Up @@ -328,6 +328,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down Expand Up @@ -395,6 +397,8 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand All @@ -403,8 +407,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c h1:
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
4 changes: 2 additions & 2 deletions pkg/provider/aws/action/rhel/cloud-config-base
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ rh_subscription:
username: {{.SubscriptionUsername}}
password: {{.SubscriptionPassword}}
auto-attach: true
packages:
runcmd:
- while fuser /var/lib/rpm/.rpm.lock > /dev/null 2>&1 ; do sleep 1 ; done
- podman
- dnf install -y podman
9 changes: 6 additions & 3 deletions pkg/provider/aws/action/rhel/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ var (

diskSize int = 200

amiRegex = "RHEL-%s*-x86_64-*"
amiUserDefault = "ec2-user"
amiProductDescription = "Red Hat Enterprise Linux"
amiRegex = "RHEL-%s*-%s-*"
amiUserDefault = "ec2-user"

requiredInstanceTypes = []string{"c5.metal", "c5d.metal", "c5n.metal"}
supportedInstanceTypes = map[string][]string{
"x86_64": {"c5.metal", "c5d.metal", "c5n.metal"},
"arm64": {"c7gd.metal", "c7gn.metal", "m6gd.metal"}}

outputHost = "ardHost"
outputUsername = "ardUsername"
Expand Down
15 changes: 8 additions & 7 deletions pkg/provider/aws/action/rhel/rhel.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Request struct {
Prefix string
// Basic info to setup on cloud-init
Version string
Arch string
SubsUsername string
SubsUserpass string
// if profile SNC is enabled machine is setup to
Expand Down Expand Up @@ -68,10 +69,10 @@ func Create(r *Request) error {
if r.Spot {
sr := spot.SpotOptionRequest{
Prefix: r.Prefix,
ProductDescription: "Red Hat Enterprise Linux",
InstaceTypes: requiredInstanceTypes,
AMIName: fmt.Sprintf(amiRegex, r.Version),
AMIArch: "x86_64",
ProductDescription: amiProductDescription,
InstaceTypes: supportedInstanceTypes[r.Arch],
AMIName: fmt.Sprintf(amiRegex, r.Version, r.Arch),
AMIArch: r.Arch,
}
so, err := sr.Create()
if err != nil {
Expand Down Expand Up @@ -148,10 +149,10 @@ func (r *Request) createAirgapMachine() error {
func (r *Request) deploy(ctx *pulumi.Context) error {
// Get AMI
ami, err := amiSVC.GetAMIByName(ctx,
fmt.Sprintf(amiRegex, r.Version),
fmt.Sprintf(amiRegex, r.Version, r.Arch),
"",
map[string]string{
"architecture": "x86_64"})
"architecture": r.Arch})
if err != nil {
return err
}
Expand Down Expand Up @@ -199,7 +200,7 @@ func (r *Request) deploy(ctx *pulumi.Context) error {
UserDataAsBase64: userDataB64,
KeyResources: keyResources,
SecurityGroups: securityGroups,
InstaceTypes: requiredInstanceTypes,
InstaceTypes: supportedInstanceTypes[r.Arch],
DiskSize: &diskSize,
Airgap: r.Airgap,
LB: lb,
Expand Down
24 changes: 22 additions & 2 deletions vendor/github.com/hashicorp/hcl/v2/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions vendor/github.com/hashicorp/hcl/v2/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions vendor/github.com/hashicorp/hcl/v2/tools.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions vendor/golang.org/x/mod/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/golang.org/x/mod/PATENTS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading