Skip to content

Commit

Permalink
OCM-11855 | test: Support bastion proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
jameszwang committed Nov 21, 2024
1 parent 9f19993 commit feb55f2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,18 @@ git push origin v0.0.1

`$ rosa-support delete vpc --vpc-id <vpc id> --region <region>`

* Prepare bastion
* *--region* is required where created the vpc-id
* *--availability-zone* is required on which zone to launch the bastion instance
* *--vpc-id* is required which should be VPC id used to launch cluster
* *--keypair-name* is required to generate temporary used to launch the proxy instance
* *--private-key-path* is required to record the generated private ssh key
* *--cidr-block* is NOT required, only IP address within CIDR block can access other resources through bastion proxy(default is 0.0.0.0/0)

`$ rosa-support create bastion --region us-east-2 --availability-zone us-east-2a --vpc-id <vpc id> --keypair-name <name> --private-key-path <path>`

* Destroy bastion,the bastion and related resources with VPC will be destroyed when clean VPC

`$ rosa-support delete vpc --vpc-id <vpc id> --region <region>`

Note that a repository administrator may need to push the tag to the repository due to access restrictions.
31 changes: 29 additions & 2 deletions cmd/rosa-support/create/bastion/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var args struct {
region string
vpcID string
availabilityZone string
privateKeyPath string
keyPairName string
cidr string
}

Expand All @@ -20,7 +22,8 @@ var Cmd = &cobra.Command{
Short: "Create bastion proxy",
Long: "Create bastion proxy.",
Example: ` # Create a bastion proxy in region 'us-east-2'
rosa-support create bastion --region us-east-2 --availability-zone us-east-2a --vpc-id <vpc id>`,
rosa-support create bastion --region us-east-2 --availability-zone us-east-2a --vpc-id <vpc id> --keypair-name <name>
--private-key-path <path>`,

Run: run,
}
Expand Down Expand Up @@ -64,6 +67,30 @@ func init() {
logger.LogError(err.Error())
os.Exit(1)
}
flags.StringVarP(
&args.keyPairName,
"keypair-name",
"",
"",
"key pair will be created with the name (required)",
)
err = Cmd.MarkFlagRequired("keypair-name")
if err != nil {
logger.LogError(err.Error())
os.Exit(1)
}
flags.StringVarP(
&args.privateKeyPath,
"private-key-path",
"",
"",
"record generated private ssh key in the given path (required)",
)
err = Cmd.MarkFlagRequired("private-key-path")
if err != nil {
logger.LogError(err.Error())
os.Exit(1)
}
flags.StringVarP(
&args.cidr,
"cidr-block",
Expand All @@ -79,7 +106,7 @@ func run(cmd *cobra.Command, _ []string) {
if err != nil {
panic(err)
}
instance, err := vpc.PrepareBastionProxy(args.availabilityZone, args.cidr)
instance, err := vpc.PrepareBastionProxy(args.availabilityZone, args.cidr, args.keyPairName, args.privateKeyPath)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/openshift-online/rosa-support
go 1.21

require (
github.com/openshift-online/ocm-common v0.0.13
github.com/openshift-online/ocm-common v0.0.14-0.20241121072829-c1150dfc4289
github.com/spf13/cobra v1.8.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/openshift-online/ocm-common v0.0.13 h1:FUn4PwuxOLsGbyJIC+izQQxYP3hA6dW5z/ep4HbTE4Q=
github.com/openshift-online/ocm-common v0.0.13/go.mod h1:6MWje2NFNJ3IWpGs7BYj6DWagWXHyp8EnmYY7XFTtI4=
github.com/openshift-online/ocm-common v0.0.14-0.20241121072829-c1150dfc4289 h1:CYX7p1cLo4+BwjHlJXHDP/zPiNit32b6YO6R0lGW+ZQ=
github.com/openshift-online/ocm-common v0.0.14-0.20241121072829-c1150dfc4289/go.mod h1:6MWje2NFNJ3IWpGs7BYj6DWagWXHyp8EnmYY7XFTtI4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down

0 comments on commit feb55f2

Please sign in to comment.