Skip to content

Commit c970b88

Browse files
committed
feat: IBM Cloud Support
Signed-off-by: Adrian Riobo <ariobolo@redhat.com>
1 parent c802f4d commit c970b88

File tree

2,288 files changed

+991196
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,288 files changed

+991196
-8
lines changed

.claude/settings.local.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(go list:*)",
5+
"Bash(curl:*)",
6+
"Bash(find:*)",
7+
"Bash(go mod:*)",
8+
"Bash(go env:*)",
9+
"Bash(make:*)",
10+
"Bash(go build:*)"
11+
],
12+
"deny": [],
13+
"ask": []
14+
}
15+
}

.golangci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
3+
run:
4+
timeout: 20m
5+
skip-dirs:
6+
- vendor
7+
- tools/vendor
8+
skip-files:
9+
- pkg/provider/ibmcloud/action/powervs/powervs.go
10+
concurrency: 1
11+
12+
linters-settings:
13+
govet:
14+
enable-all: true
15+
16+
issues:
17+
exclude-dirs:
18+
- vendor
19+
- tools/vendor

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ build: $(BUILD_DIR)/mapt
7575

7676
.PHONY: test
7777
test:
78+
GOMAXPROCS=1 CGO_ENABLED=1 go test -p 1 --tags build -v -ldflags="$(VERSION_VARIABLES)" ./pkg/... ./cmd/... -skip github.com/mapt-oss/pulumi-ibmcloud/sdk/go/...
79+
80+
.PHONY: test-race
81+
test-race:
7882
CGO_ENABLED=1 go test -race --tags build -v -ldflags="$(VERSION_VARIABLES)" ./pkg/... ./cmd/...
7983

8084
.PHONY: clean ## Remove all build artifacts
@@ -89,7 +93,7 @@ fmt:
8993
# Run golangci-lint against code
9094
.PHONY: lint
9195
lint: $(TOOLS_BINDIR)/golangci-lint
92-
"$(TOOLS_BINDIR)"/golangci-lint run -v --timeout 10m
96+
"$(TOOLS_BINDIR)"/golangci-lint run -v --timeout 20m --skip-dirs vendor
9397

9498
# Build the container image
9599
.PHONY: oci-build

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,26 @@ Instances can be wrapped on specific topologies like airgap, in this case mapt w
1616

1717
Instances can also define a timeout to avoid leftovers in case destoy operation is missing. Using this approach mapt will be execute as an unateneded execution using servless technologies.
1818

19-
[MacOS](docs/aws/mac.md)-[Windows Server](docs/aws/windows.md)-[Windows Desktop](docs/azure/windows.md)-[RHEL](docs/aws/rhel.md)-[Fedora](docs/azure/fedora.md)-[Ubuntu](docs/azure/ubuntu.md)
19+
[MacOS](docs/aws/mac.md) - [Windows Server](docs/aws/windows.md) - [Windows Desktop](docs/azure/windows.md) - [RHEL](docs/aws/rhel.md) - [Fedora](docs/azure/fedora.md) - [Ubuntu](docs/azure/ubuntu.md)
2020

2121
### Services
2222

2323
Mapt offers some managed services boosted with some of the features from the instances offerings (i.e spot) and also create some ad hoc services on top the instances offerings to improve reutilization of instances when there is no easy way to do it (i.e. Mac-Pool).
2424

25-
[AKS](docs/azure/aks.md)-[EKS](docs/aws/eks.md)-[Mac-Pool](docs/aws/mac-pool.md) - [OpenShift-SNC](docs/aws/openshift-snc.md) - [Kind](docs/aws/openshift-snc.md)
25+
[AKS](docs/azure/aks.md) - [EKS](docs/aws/eks.md) - [Mac-Pool](docs/aws/mac-pool.md) - [OpenShift-SNC](docs/aws/openshift-snc.md) - [Kind](docs/aws/openshift-snc.md)
26+
27+
### Architectures
28+
29+
x86 and arm64 archs can be provisioned through any of the previous targets based on parameters.
30+
31+
In addition we can provision
32+
33+
[s390x](docs/ibmcloud/ibm-z.md) - [ppc64](docs/ibmcloud/ibm-power.mdS)
2634

2735

2836
### Integrations
2937

30-
Currently each target offered by Mapt can be added as:
38+
The integrations allow to provision the machine and link to different CI/CD systems based on their native integrations.
3139

3240
* [Github Self Hosted Runner](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners)
3341
* [Cirrus Persistent Worker](https://cirrus-ci.org/guide/persistent-workers/)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
ibmpower "github.com/redhat-developer/mapt/pkg/provider/ibmcloud/action/ibm-power"
7+
"github.com/spf13/cobra"
8+
"github.com/spf13/pflag"
9+
"github.com/spf13/viper"
10+
)
11+
12+
const (
13+
cmdIBMPower = "ibm-power"
14+
cmdIBMPowerDesc = "manage ibm-power machines (ppc64)"
15+
)
16+
17+
func IBMPowerCmd() *cobra.Command {
18+
c := &cobra.Command{
19+
Use: cmdIBMPower,
20+
Short: cmdIBMPowerDesc,
21+
RunE: func(cmd *cobra.Command, args []string) error {
22+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
23+
return err
24+
}
25+
return nil
26+
},
27+
}
28+
29+
flagSet := pflag.NewFlagSet(cmdIBMPower, pflag.ExitOnError)
30+
params.AddCommonFlags(flagSet)
31+
c.PersistentFlags().AddFlagSet(flagSet)
32+
33+
c.AddCommand(ibmPowerCreate(), ibmPowerDestroy())
34+
return c
35+
}
36+
37+
func ibmPowerCreate() *cobra.Command {
38+
c := &cobra.Command{
39+
Use: params.CreateCmdName,
40+
Short: params.CreateCmdName,
41+
RunE: func(cmd *cobra.Command, args []string) error {
42+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
43+
return err
44+
}
45+
return ibmpower.New(
46+
&maptContext.ContextArgs{
47+
Context: cmd.Context(),
48+
ProjectName: viper.GetString(params.ProjectName),
49+
BackedURL: viper.GetString(params.BackedURL),
50+
ResultsOutput: viper.GetString(params.ConnectionDetailsOutput),
51+
Debug: viper.IsSet(params.Debug),
52+
DebugLevel: viper.GetUint(params.DebugLevel),
53+
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
54+
GHRunnerArgs: params.GithubRunnerArgs(),
55+
Tags: viper.GetStringMapString(params.Tags),
56+
},
57+
&ibmpower.PWArgs{})
58+
},
59+
}
60+
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError)
61+
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
62+
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
63+
params.AddGHActionsFlags(flagSet)
64+
params.AddCirrusFlags(flagSet)
65+
c.PersistentFlags().AddFlagSet(flagSet)
66+
return c
67+
}
68+
69+
func ibmPowerDestroy() *cobra.Command {
70+
c := &cobra.Command{
71+
Use: params.DestroyCmdName,
72+
Short: params.DestroyCmdName,
73+
RunE: func(cmd *cobra.Command, args []string) error {
74+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
75+
return err
76+
}
77+
return ibmpower.Destroy(&maptContext.ContextArgs{
78+
Context: cmd.Context(),
79+
ProjectName: viper.GetString(params.ProjectName),
80+
BackedURL: viper.GetString(params.BackedURL),
81+
Debug: viper.IsSet(params.Debug),
82+
DebugLevel: viper.GetUint(params.DebugLevel),
83+
Serverless: viper.IsSet(params.Serverless),
84+
ForceDestroy: viper.IsSet(params.ForceDestroy),
85+
})
86+
},
87+
}
88+
flagSet := pflag.NewFlagSet(params.DestroyCmdName, pflag.ExitOnError)
89+
flagSet.Bool(params.Serverless, false, params.ServerlessDesc)
90+
flagSet.Bool(params.ForceDestroy, false, params.ForceDestroyDesc)
91+
c.PersistentFlags().AddFlagSet(flagSet)
92+
return c
93+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
ibmz "github.com/redhat-developer/mapt/pkg/provider/ibmcloud/action/ibm-z"
7+
"github.com/spf13/cobra"
8+
"github.com/spf13/pflag"
9+
"github.com/spf13/viper"
10+
)
11+
12+
const (
13+
cmdIBMZ = "ibm-z"
14+
cmdIBMZDesc = "manage ibm-power machines (s390x)"
15+
)
16+
17+
func IBMZCmd() *cobra.Command {
18+
c := &cobra.Command{
19+
Use: cmdIBMZ,
20+
Short: cmdIBMZDesc,
21+
RunE: func(cmd *cobra.Command, args []string) error {
22+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
23+
return err
24+
}
25+
return nil
26+
},
27+
}
28+
29+
flagSet := pflag.NewFlagSet(cmdIBMZ, pflag.ExitOnError)
30+
params.AddCommonFlags(flagSet)
31+
c.PersistentFlags().AddFlagSet(flagSet)
32+
33+
c.AddCommand(ibmZCreate(), ibmZDestroy())
34+
return c
35+
}
36+
37+
func ibmZCreate() *cobra.Command {
38+
c := &cobra.Command{
39+
Use: params.CreateCmdName,
40+
Short: params.CreateCmdName,
41+
RunE: func(cmd *cobra.Command, args []string) error {
42+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
43+
return err
44+
}
45+
return ibmz.New(
46+
&maptContext.ContextArgs{
47+
Context: cmd.Context(),
48+
ProjectName: viper.GetString(params.ProjectName),
49+
BackedURL: viper.GetString(params.BackedURL),
50+
ResultsOutput: viper.GetString(params.ConnectionDetailsOutput),
51+
Debug: viper.IsSet(params.Debug),
52+
DebugLevel: viper.GetUint(params.DebugLevel),
53+
CirrusPWArgs: params.CirrusPersistentWorkerArgs(),
54+
GHRunnerArgs: params.GithubRunnerArgs(),
55+
Tags: viper.GetStringMapString(params.Tags),
56+
},
57+
&ibmz.ZArgs{})
58+
},
59+
}
60+
flagSet := pflag.NewFlagSet(params.CreateCmdName, pflag.ExitOnError)
61+
flagSet.StringP(params.ConnectionDetailsOutput, "", "", params.ConnectionDetailsOutputDesc)
62+
flagSet.StringToStringP(params.Tags, "", nil, params.TagsDesc)
63+
params.AddGHActionsFlags(flagSet)
64+
params.AddCirrusFlags(flagSet)
65+
c.PersistentFlags().AddFlagSet(flagSet)
66+
return c
67+
}
68+
69+
func ibmZDestroy() *cobra.Command {
70+
c := &cobra.Command{
71+
Use: params.DestroyCmdName,
72+
Short: params.DestroyCmdName,
73+
RunE: func(cmd *cobra.Command, args []string) error {
74+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
75+
return err
76+
}
77+
return ibmz.Destroy(&maptContext.ContextArgs{
78+
Context: cmd.Context(),
79+
ProjectName: viper.GetString(params.ProjectName),
80+
BackedURL: viper.GetString(params.BackedURL),
81+
Debug: viper.IsSet(params.Debug),
82+
DebugLevel: viper.GetUint(params.DebugLevel),
83+
Serverless: viper.IsSet(params.Serverless),
84+
ForceDestroy: viper.IsSet(params.ForceDestroy),
85+
})
86+
},
87+
}
88+
flagSet := pflag.NewFlagSet(params.DestroyCmdName, pflag.ExitOnError)
89+
flagSet.Bool(params.Serverless, false, params.ServerlessDesc)
90+
flagSet.Bool(params.ForceDestroy, false, params.ForceDestroyDesc)
91+
c.PersistentFlags().AddFlagSet(flagSet)
92+
return c
93+
}

cmd/mapt/cmd/ibmcloud/ibmcloud.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package ibmcloud
2+
3+
import (
4+
"github.com/redhat-developer/mapt/cmd/mapt/cmd/ibmcloud/hosts"
5+
params "github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
6+
"github.com/spf13/cobra"
7+
"github.com/spf13/pflag"
8+
"github.com/spf13/viper"
9+
)
10+
11+
const (
12+
cmd = "ibmcloud"
13+
cmdDesc = "ibmcloud operations"
14+
)
15+
16+
func GetCmd() *cobra.Command {
17+
c := &cobra.Command{
18+
Use: cmd,
19+
Short: cmdDesc,
20+
RunE: func(cmd *cobra.Command, args []string) error {
21+
if err := viper.BindPFlags(cmd.Flags()); err != nil {
22+
return err
23+
}
24+
return nil
25+
},
26+
}
27+
28+
flagSet := pflag.NewFlagSet(cmd, pflag.ExitOnError)
29+
params.AddCommonFlags(flagSet)
30+
c.PersistentFlags().AddFlagSet(flagSet)
31+
c.AddCommand(
32+
hosts.IBMPowerCmd(),
33+
hosts.IBMZCmd())
34+
return c
35+
}

cmd/mapt/cmd/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"syscall"
1111
"github.com/redhat-developer/mapt/cmd/mapt/cmd/aws"
1212
"github.com/redhat-developer/mapt/cmd/mapt/cmd/azure"
13+
"github.com/redhat-developer/mapt/cmd/mapt/cmd/ibmcloud"
1314
"github.com/redhat-developer/mapt/cmd/mapt/cmd/params"
1415
"github.com/redhat-developer/mapt/pkg/util/logging"
1516
"github.com/spf13/cobra"
@@ -61,7 +62,8 @@ func init() {
6162
// Subcommands
6263
rootCmd.AddCommand(
6364
aws.GetCmd(),
64-
azure.GetCmd())
65+
azure.GetCmd(),
66+
ibmcloud.GetCmd())
6567
}
6668

6769
func Execute() {

docs/ibmcloud/ibm-power.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Overview
2+
3+
This actions will handle provision Ubuntu ppc64 machines on ibm cloud power vs.
4+
5+
6+
## Create
7+
8+
```bash
9+
mapt ibmcloud ibm-power z create -h
10+
create
11+
12+
Usage:
13+
mapt ibmcloud ibm-power create [flags]
14+
15+
Flags:
16+
--conn-details-output string path to export host connection information (host, username and privateKey)
17+
--ghactions-runner-labels strings List of labels separated by comma to be added to the self-hosted runner
18+
--ghactions-runner-repo string Full URL of the repository where the Github Actions Runner should be registered
19+
--ghactions-runner-token string Token needed for registering the Github Actions Runner token
20+
-h, --help help for create
21+
--it-cirrus-pw-labels stringToString additional labels to use on the persistent worker (--it-cirrus-pw-labels key1=value1,key2=value2) (default [])
22+
--it-cirrus-pw-token string Add mapt target as a cirrus persistent worker. The value will hold a valid token to be used by cirrus cli to join the project.
23+
--tags stringToString tags to add on each resource (--tags name1=value1,name2=value2) (default [])
24+
25+
Global Flags:
26+
--backed-url string backed for stack state. (local) file:///path/subpath (s3) s3://existing-bucket, (azure) azblob://existing-blobcontainer. See more https://www.pulumi.com/docs/iac/concepts/state-and-backends/#using-a-self-managed-backend
27+
--debug Enable debug traces and set verbosity to max. Typically to get information to troubleshooting an issue.
28+
--debug-level uint Set the level of verbosity on debug. You can set from minimum 1 to max 9. (default 3)
29+
--project-name string project name to identify the instance of the stack
30+
```
31+
32+
### Outputs
33+
34+
* It will crete an instance and will give as result several files located at path defined by `--conn-details-output`:
35+
36+
* **host**: host for the Windows machine (lb if spot)
37+
* **username**: username to connect to the machine
38+
* **id_rsa**: private key to connect to machine
39+
40+
* Also, it will create a state folder holding the state for the created resources at azure, the path for this folder is defined within `--backed-url`, the content from that folder it is required with the same project name (`--project-name`) in order to destroy the resources.
41+
42+
### Container
43+
44+
```bash
45+
podman run -d --name ibm-power \
46+
-v ${PWD}:/workspace:z \
47+
-e IBMCLOUD_ACCOUNT=XXX \
48+
-e IBMCLOUD_API_KEY=XXX \
49+
-e IC_REGION=us-south \
50+
-e IC_ZONE=dal12 \ # power vs use this notation
51+
quay.io/redhat-developer/mapt:1.0.0 ibm-power create \
52+
--project-name ibm-power \
53+
--backed-url file:///workspace \
54+
--conn-details-output /workspace
55+
```

0 commit comments

Comments
 (0)