Skip to content

Commit da36ae1

Browse files
committed
feat: Added rhelai support on Azure
Signed-off-by: Adrian Riobo <ariobolo@redhat.com>
1 parent 449dd0b commit da36ae1

20 files changed

Lines changed: 995 additions & 171 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ define tkn_update
4747
sed -e 's%<IMAGE>%$(1)%g' -e 's%<VERSION>%$(2)%g' tkn/template/infra-aws-windows-server.yaml > tkn/infra-aws-windows-server.yaml
4848
sed -e 's%<IMAGE>%$(1)%g' -e 's%<VERSION>%$(2)%g' tkn/template/infra-azure-aks.yaml > tkn/infra-azure-aks.yaml
4949
sed -e 's%<IMAGE>%$(1)%g' -e 's%<VERSION>%$(2)%g' tkn/template/infra-azure-rhel.yaml > tkn/infra-azure-rhel.yaml
50+
sed -e 's%<IMAGE>%$(1)%g' -e 's%<VERSION>%$(2)%g' tkn/template/infra-azure-rhel-ai.yaml > tkn/infra-azure-rhel-ai.yaml
5051
sed -e 's%<IMAGE>%$(1)%g' -e 's%<VERSION>%$(2)%g' tkn/template/infra-azure-fedora.yaml > tkn/infra-azure-fedora.yaml
5152
sed -e 's%<IMAGE>%$(1)%g' -e 's%<VERSION>%$(2)%g' tkn/template/infra-azure-windows-desktop.yaml > tkn/infra-azure-windows-desktop.yaml
5253
endef

cmd/mapt/cmd/aws/hosts/rhelai.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
55
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
66
rhelai "github.com/redhat-developer/mapt/pkg/provider/aws/action/rhel-ai"
7+
apiRHELAI "github.com/redhat-developer/mapt/pkg/targets/host/rhelai"
78
"github.com/spf13/cobra"
89
"github.com/spf13/pflag"
910
"github.com/spf13/viper"
@@ -52,12 +53,11 @@ func getRHELAICreate() *cobra.Command {
5253
DebugLevel: viper.GetUint(params.DebugLevel),
5354
Tags: viper.GetStringMapString(params.Tags),
5455
},
55-
&rhelai.RHELAIArgs{
56+
&apiRHELAI.RHELAIArgs{
5657
Prefix: "main",
5758
Version: viper.GetString(params.RhelAIVersion),
59+
Accelerator: viper.GetString(params.RhelAIAccelerator),
5860
CustomAMI: viper.GetString(params.RhelAIAMICustom),
59-
SubsUsername: viper.GetString(params.SubsUsername),
60-
SubsUserpass: viper.GetString(params.SubsUserpass),
6161
ComputeRequest: params.ComputeRequestArgs(),
6262
Spot: params.SpotArgs(),
6363
Timeout: viper.GetString(params.Timeout),
@@ -68,9 +68,8 @@ func getRHELAICreate() *cobra.Command {
6868
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
6969
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
7070
flagSet.StringP(params.RhelAIVersion, "", params.RhelAIVersionDefault, params.RhelAIVersionDesc)
71+
flagSet.StringP(params.RhelAIAccelerator, "", params.RhelAIAccelearatorDefault, params.RhelAIAccelearatorDesc)
7172
flagSet.StringP(params.RhelAIAMICustom, "", "", params.RhelAIAMICustomDesc)
72-
flagSet.StringP(params.SubsUsername, "", "", params.SubsUsernameDesc)
73-
flagSet.StringP(params.SubsUserpass, "", "", params.SubsUserpassDesc)
7473
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
7574
params.AddComputeRequestFlags(flagSet)
7675
params.AddSpotFlags(flagSet)

cmd/mapt/cmd/azure/azure.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func GetCmd() *cobra.Command {
3434
hosts.GetWindowsDesktopCmd(),
3535
hosts.GetUbuntuCmd(),
3636
hosts.GetRHELCmd(),
37+
hosts.GetRHELAICmd(),
3738
hosts.GetFedoraCmd(),
3839
services.GetAKSCmd(),
3940
services.GetKindCmd())

cmd/mapt/cmd/azure/hosts/rhelai.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package hosts
2+
3+
import (
4+
"github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
5+
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
6+
rhelai "github.com/redhat-developer/mapt/pkg/provider/azure/action/rhel-ai"
7+
apiRHELAI "github.com/redhat-developer/mapt/pkg/targets/host/rhelai"
8+
"github.com/spf13/cobra"
9+
"github.com/spf13/pflag"
10+
"github.com/spf13/viper"
11+
)
12+
13+
const (
14+
cmdRHELAI = "rhel-ai"
15+
cmdRHELAIDesc = "manage rhel ai host"
16+
)
17+
18+
func GetRHELAICmd() *cobra.Command {
19+
c := &cobra.Command{
20+
Use: cmdRHELAI,
21+
Short: cmdRHELAIDesc,
22+
RunE: func(cmd *cobra.Command, args []string) error {
23+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
24+
return err
25+
}
26+
return nil
27+
},
28+
}
29+
30+
flagSet := pflag.NewFlagSet(cmdRHELAI, pflag.ExitOnError)
31+
params.AddCommonFlags(flagSet)
32+
c.PersistentFlags().AddFlagSet(flagSet)
33+
34+
c.AddCommand(getRHELAICreate(), getRHELAIDestroy())
35+
return c
36+
}
37+
38+
func getRHELAICreate() *cobra.Command {
39+
c := &cobra.Command{
40+
Use: params.CreateCmdName,
41+
Short: params.CreateCmdName,
42+
RunE: func(cmd *cobra.Command, args []string) error {
43+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
44+
return err
45+
}
46+
return rhelai.Create(
47+
&maptContext.ContextArgs{
48+
Context: cmd.Context(),
49+
ProjectName: viper.GetString(params.ProjectName),
50+
BackedURL: viper.GetString(params.BackedURL),
51+
ResultsOutput: viper.GetString(params.ConnectionDetailsOutput),
52+
Debug: viper.IsSet(params.Debug),
53+
DebugLevel: viper.GetUint(params.DebugLevel),
54+
Tags: viper.GetStringMapString(params.Tags),
55+
},
56+
&apiRHELAI.RHELAIArgs{
57+
Prefix: "main",
58+
Version: viper.GetString(params.RhelAIVersion),
59+
Accelerator: viper.GetString(params.RhelAIAccelerator),
60+
CustomAMI: viper.GetString(params.RhelAIAMICustom),
61+
ComputeRequest: params.ComputeRequestArgs(),
62+
Spot: params.SpotArgs(),
63+
Timeout: viper.GetString(params.Timeout),
64+
})
65+
},
66+
}
67+
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError)
68+
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
69+
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
70+
flagSet.StringP(params.RhelAIVersion, "", params.RhelAIVersionDefault, params.RhelAIVersionDesc)
71+
flagSet.StringP(params.RhelAIAccelerator, "", params.RhelAIAccelearatorDefault, params.RhelAIAccelearatorDesc)
72+
flagSet.StringP(params.RhelAIAMICustom, "", "", params.RhelAIAMICustomDesc)
73+
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
74+
params.AddComputeRequestFlags(flagSet)
75+
params.AddSpotFlags(flagSet)
76+
c.PersistentFlags().AddFlagSet(flagSet)
77+
return c
78+
}
79+
80+
func getRHELAIDestroy() *cobra.Command {
81+
c := &cobra.Command{
82+
Use: params.DestroyCmdName,
83+
Short: params.DestroyCmdName,
84+
RunE: func(cmd *cobra.Command, args []string) error {
85+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
86+
return err
87+
}
88+
return rhelai.Destroy(&maptContext.ContextArgs{
89+
Context: cmd.Context(),
90+
ProjectName: viper.GetString(params.ProjectName),
91+
BackedURL: viper.GetString(params.BackedURL),
92+
Debug: viper.IsSet(params.Debug),
93+
DebugLevel: viper.GetUint(params.DebugLevel),
94+
Serverless: viper.IsSet(params.Serverless),
95+
ForceDestroy: viper.IsSet(params.ForceDestroy),
96+
KeepState: viper.IsSet(params.KeepState),
97+
})
98+
},
99+
}
100+
flagSet := pflag.NewFlagSet(params.DestroyCmdName, pflag.ExitOnError)
101+
flagSet.Bool(params.Serverless, false, params.ServerlessDesc)
102+
flagSet.Bool(params.ForceDestroy, false, params.ForceDestroyDesc)
103+
flagSet.Bool(params.KeepState, false, params.KeepStateDesc)
104+
c.PersistentFlags().AddFlagSet(flagSet)
105+
return c
106+
}

cmd/mapt/cmd/params/params.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,23 @@ const (
9191
glRunnerTagsDesc string = "List of tags separated by comma to be added to the self-hosted runner"
9292

9393
//RHEL
94-
SubsUsername string = "rh-subscription-username"
95-
SubsUsernameDesc string = "username to register the subscription"
96-
SubsUserpass string = "rh-subscription-password"
97-
SubsUserpassDesc string = "password to register the subscription"
98-
ProfileSNC string = "snc"
99-
ProfileSNCDesc string = "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"
100-
RhelVersion string = "version"
101-
RhelVersionDesc string = "version for the RHEL OS"
102-
RhelVersionDefault string = "9.4"
103-
RhelAIVersion string = "version"
104-
RhelAIVersionDesc string = "version for the RHELAI OS"
105-
RhelAIVersionDefault string = "3.0.0"
106-
RhelAIAMICustom string = "custom-ami"
107-
RhelAIAMICustomDesc string = "custom AMI to spin RHEL AI OS"
94+
SubsUsername string = "rh-subscription-username"
95+
SubsUsernameDesc string = "username to register the subscription"
96+
SubsUserpass string = "rh-subscription-password"
97+
SubsUserpassDesc string = "password to register the subscription"
98+
ProfileSNC string = "snc"
99+
ProfileSNCDesc string = "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"
100+
RhelVersion string = "version"
101+
RhelVersionDesc string = "version for the RHEL OS"
102+
RhelVersionDefault string = "9.4"
103+
RhelAIVersion string = "version"
104+
RhelAIVersionDesc string = "version for the RHELAI OS"
105+
RhelAIVersionDefault string = "3.0.0"
106+
RhelAIAccelerator string = "accelerator"
107+
RhelAIAccelearatorDesc string = "accelerator type. Valid types: cuda and rocm"
108+
RhelAIAccelearatorDefault string = "cuda"
109+
RhelAIAMICustom string = "custom-ami"
110+
RhelAIAMICustomDesc string = "custom AMI to spin RHEL AI OS"
108111

109112
// Serverless
110113
Timeout string = "timeout"

pkg/provider/aws/action/rhel-ai/constants.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var (
1616
// amiProduct = "Red Hat Enterprise Linux"
1717
amiProduct = "Linux/UNIX"
1818
amiV1Regex = "rhel-ai-nvidia-aws-%s-*"
19-
amiRegex = "rhel-ai-cuda-aws-%s-*"
19+
amiRegex = "rhel-ai-%s-aws-%s-*"
2020
amiOwner = "610952687893"
2121
// amiOwnerSelf = "self"
2222
amiArch = "x86_64"
@@ -48,10 +48,10 @@ var (
4848
outputUserPrivateKey = "ardPrivatekey"
4949
)
5050

51-
func amiName(version *string) string {
51+
func amiName(accelerator, version *string) string {
5252
return util.If(strings.HasPrefix(*version, "1"),
5353
fmt.Sprintf(amiV1Regex, *version),
54-
fmt.Sprintf(amiRegex, *version))
54+
fmt.Sprintf(amiRegex, *accelerator, *version))
5555
}
5656

5757
// NVIDIA A100 X2

pkg/provider/aws/action/rhel-ai/rhelai.go

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"github.com/redhat-developer/mapt/pkg/manager"
1212
mc "github.com/redhat-developer/mapt/pkg/manager/context"
1313
infra "github.com/redhat-developer/mapt/pkg/provider"
14-
cr "github.com/redhat-developer/mapt/pkg/provider/api/compute-request"
15-
spotTypes "github.com/redhat-developer/mapt/pkg/provider/api/spot"
1614
"github.com/redhat-developer/mapt/pkg/provider/aws"
1715
awsConstants "github.com/redhat-developer/mapt/pkg/provider/aws/constants"
1816
"github.com/redhat-developer/mapt/pkg/provider/aws/data"
@@ -26,32 +24,18 @@ import (
2624
securityGroup "github.com/redhat-developer/mapt/pkg/provider/aws/services/ec2/security-group"
2725
"github.com/redhat-developer/mapt/pkg/provider/util/command"
2826
"github.com/redhat-developer/mapt/pkg/provider/util/output"
27+
apiRHELAI "github.com/redhat-developer/mapt/pkg/targets/host/rhelai"
2928
"github.com/redhat-developer/mapt/pkg/util"
3029
"github.com/redhat-developer/mapt/pkg/util/logging"
3130
resourcesUtil "github.com/redhat-developer/mapt/pkg/util/resources"
3231
)
3332

34-
type RHELAIArgs struct {
35-
Prefix string
36-
Version string
37-
CustomAMI string
38-
Arch string
39-
ComputeRequest *cr.ComputeRequestArgs
40-
SubsUsername string
41-
SubsUserpass string
42-
Spot *spotTypes.SpotArgs
43-
// If timeout is set a severless scheduled task will be created to self destroy the resources
44-
Timeout string
45-
}
46-
4733
type rhelAIRequest struct {
4834
mCtx *mc.Context
4935
prefix *string
5036
amiName *string
5137
arch *string
5238
spot bool
53-
subsUsername *string
54-
subsUserpass *string
5539
timeout *string
5640
allocationData *allocation.AllocationResult
5741
}
@@ -68,26 +52,24 @@ func (r *rhelAIRequest) validate() error {
6852
// Create orchestrate 2 stacks:
6953
// If spot is enable it will run best spot option to get the best option to spin the machine
7054
// Then it will run the stack for windows dedicated host
71-
func Create(mCtxArgs *mc.ContextArgs, args *RHELAIArgs) (err error) {
55+
func Create(mCtxArgs *mc.ContextArgs, args *apiRHELAI.RHELAIArgs) (err error) {
7256
// Create mapt Context
7357
mCtx, err := mc.Init(mCtxArgs, aws.Provider())
7458
if err != nil {
7559
return err
7660
}
7761
// Compose request
78-
amiName := amiName(&args.Version)
62+
amiName := amiName(&args.Accelerator, &args.Version)
7963
if len(args.CustomAMI) != 0 {
8064
amiName = fmt.Sprintf("%s*", args.CustomAMI)
8165
}
8266
prefix := util.If(len(args.Prefix) > 0, args.Prefix, "main")
8367
r := rhelAIRequest{
84-
mCtx: mCtx,
85-
prefix: &prefix,
86-
amiName: &amiName,
87-
arch: &args.Arch,
88-
timeout: &args.Timeout,
89-
subsUsername: &args.SubsUsername,
90-
subsUserpass: &args.SubsUserpass}
68+
mCtx: mCtx,
69+
prefix: &prefix,
70+
amiName: &amiName,
71+
arch: &args.Arch,
72+
timeout: &args.Timeout}
9173
if args.Spot != nil {
9274
r.spot = args.Spot.Spot
9375
}

pkg/provider/azure/action/kind/kind.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ func (r *kindRequest) deployer(ctx *pulumi.Context) error {
171171
NetworkInteface: n.NetworkInterface,
172172
// Check this
173173
VMSize: r.allocationData.ComputeSizes[0],
174-
Publisher: r.allocationData.ImageRef.Publisher,
175-
Offer: r.allocationData.ImageRef.Offer,
176-
Sku: r.allocationData.ImageRef.Sku,
177-
ImageID: r.allocationData.ImageRef.ID,
174+
Image: r.allocationData.ImageRef,
178175
PrivateKey: privateKey,
179176
SpotPrice: r.allocationData.Price,
180177
UserDataAsBase64: udB64,

0 commit comments

Comments
 (0)