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

Adds support for VPC #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

prabhav-thali
Copy link

@prabhav-thali prabhav-thali commented Jan 9, 2025

Adds support for VPC resources. By default, make install-deployer-tf will build for powervs. To use vpc provider pass --provider vpc in kubetest2 tf command. This provider value is mapped to TargetProvider variable in deployer.go which allows to select vpc provider. By default, it is powervs.

@ppc64le-cloud-bot
Copy link
Contributor

Welcome @prabhav-thali! It looks like this is your first PR to ppc64le-cloud/kubetest2-plugins 🎉

@ppc64le-cloud-bot ppc64le-cloud-bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 9, 2025
@ppc64le-cloud-bot
Copy link
Contributor

Hi @prabhav-thali. Thanks for your PR.

I'm waiting for a ppc64le-cloud member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ppc64le-cloud-bot ppc64le-cloud-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 9, 2025
@mkumatag
Copy link
Member

mkumatag commented Jan 9, 2025

can you please post the ansible code outside of this PR?

@prabhav-thali
Copy link
Author

Yes, sure. I'll raise another PR to update ansible submodule

Makefile Outdated
@@ -14,7 +15,7 @@ INSTALL_DIR?=$(shell $(REPO_ROOT)/hack/goinstalldir.sh)
# the output binary name, overridden when cross compiling
BINARY_NAME=kubetest2-tf
BINARY_PATH=./kubetest2-tf
BUILD_FLAGS=-trimpath -ldflags="-buildid= -X=github.com/ppc64le-cloud/kubetest2-plugins/kubetest2-tf/deployer.GitTag=$(COMMIT)"
BUILD_FLAGS=-trimpath -ldflags="-buildid= -X=github.com/ppc64le-cloud/kubetest2-plugins/kubetest2-tf/deployer.GitTag=$(COMMIT) -X=github.com/ppc64le-cloud/kubetest2-plugins/kubetest2-tf/deployer.TargetProvider=$(PROVIDER)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already build mechanism is not that great for this project, lets not add one more to it, lets decide the provider based some flag runtime instead of buildtime.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will the code post this change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check how we can handle this during runtime instead of buildtime.

Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm except few minor comments

@@ -81,6 +82,7 @@ type deployer struct {
Playbook string `desc:"name of ansible playbook to be run"`
ExtraVars map[string]string `desc:"Passes extra-vars to ansible playbook, enter a string of key=value pairs"`
SetKubeconfig bool `desc:"Flag to set kubeconfig"`
TargetProvider string `json:"provider value to be used"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TargetProvider string `json:"provider value to be used"`
TargetProvider string `desc:"provider value to be used(powervs, vpc)"`

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented this

Comment on lines 110 to 115
if targetProvider == "" {
targetProvider = os.Getenv("TARGET_PROVIDER")
}
if targetProvider == "" {
return fmt.Errorf("provider not specified. Use --provider or set the TARGET_PROVIDER environment variable")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets set the default value as powervs and remove this check and also lets avoid reading from env for now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, kept powervs as default

@@ -142,6 +159,7 @@ func New(opts types.Options) (types.Deployer, *pflag.FlagSet) {
}
klog.InitFlags(nil)
flagSet.AddGoFlagSet(goflag.CommandLine)
flagSet.StringVar(&d.TargetProvider, "target-provider", "powervs", "The provider to use (vpc or powervs)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not required if you use desc as above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead add an entry here https://github.com/mkumatag/kubetest2-plugins/blob/df90d8a23d4dadc5fa18cc18ba3e191f181472e4/kubetest2-tf/deployer/deployer.go#L137 to set the default as follows

	       SetKubeconfig:    true,
               TargetProvider: "powervs"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented the change.

@prabhav-thali
Copy link
Author

Thanks for the suggestions. I will post an update here once review comments are implemented and testing is complete.

@mkumatag
Copy link
Member

Adds support for VPC resources. By default, make install-deployer-tf will build for powervs. To build the tool for VPC usage, pass PROVIDER=vpc in the make command make install-deployer-tf PROVIDER=vpc. This PROVIDER value is mapped to TargetProvider variable in deployer.go which helps to decide on vpc or powervs.

change this description as well in the end

@mkumatag
Copy link
Member

/ok-to-test

@ppc64le-cloud-bot ppc64le-cloud-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 10, 2025
@@ -81,6 +82,7 @@ type deployer struct {
Playbook string `desc:"name of ansible playbook to be run"`
ExtraVars map[string]string `desc:"Passes extra-vars to ansible playbook, enter a string of key=value pairs"`
SetKubeconfig bool `desc:"Flag to set kubeconfig"`
TargetProvider string `flag:"~target-provider" desc:"provider value to be used(powervs, vpc)"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think flag tag is not required, can you check ones?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also for all the go files you have added

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the flag tag.

@@ -135,6 +143,7 @@ func New(opts types.Options) (types.Deployer, *pflag.FlagSet) {
RetryOnTfFailure: 1,
Playbook: "install-k8s.yml",
SetKubeconfig: true,
TargetProvider: "powervs",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please run the go fmt on this file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes formatted the files.

Copy link
Member

@mkumatag mkumatag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/hold
for @Rajalakshmi-Girish @Prajyot-Parab 's review

@ppc64le-cloud-bot ppc64le-cloud-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 10, 2025
@mkumatag
Copy link
Member

/cc @Prajyot-Parab

@Prajyot-Parab
Copy link

/cc @Prajyot-Parab

will review by today.

@Prajyot-Parab
Copy link

@prabhav-thali

  1. Please run terraform fmt to format the tf files.
  2. Also the folder structure has vpc dir inside vpc (vpc -> vpc), maybe try to rename the parent folder or (if possible see if you can optimize the overall vpc code at same level)

Copy link
Contributor

@Rajalakshmi-Girish Rajalakshmi-Girish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @Prajyot-Parab mentioned, it might be better to avoid a folder structure like having a 'vpc' directory inside another 'vpc'. Otherwise, it looks good to me based on my basic understanding of Terraform, considering the structure and resource creation in the Terraform files at a high level.
/lgtm

@ppc64le-cloud-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mkumatag, prabhav-thali, Rajalakshmi-Girish

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mkumatag
Copy link
Member

@prabhav-thali

  1. Please run terraform fmt to format the tf files.

  2. Also the folder structure has vpc dir inside vpc (vpc -> vpc), maybe try to rename the parent folder or (if possible see if you can optimize the overall vpc code at same level)

Please fix these comments, will merge the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants