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

Add support for kwok cluster simulator #239

Merged

Conversation

reetasingh
Copy link
Contributor

@reetasingh reetasingh commented Apr 16, 2023

Fixes #214

  • Adding support for creation and deletion of kwok cluster which includes installing kwokctl
  • Adding env function for creation and deletion of kwok cluster
  • Adding example

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Apr 16, 2023
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 16, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @reetasingh. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 16, 2023
type kwokContextKey string

// GetKwokClusterFromContext helps extract the kwok.Cluster object from the context.
func GetKwokClusterFromContext(ctx context.Context, clusterName string) (*kwok.Cluster, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this and kind_funcs.go share more of less the same set of features/workflows, I am wondering if we can really simplify this better ? It might lead to an interface change but, that might not be a bad idea considering we are still in early phases.

  1. Create a interface type that indicates the cluster providers that can be used to implement kwok/kind or any other one in the future
  2. This env funcs use the interface type with certain args so that these things don't need to be changed frequently

cc @vladimirvivien @reetasingh Does this make sense ?

type clusterOpts func(c ClusterProvider)

type ClusterProvider interface {
	WithVersion(version string) ClusterProvider
	WithOpts(opts ...clusterOpts) ClusterProvider
	Create(args ...string) (string, error)
	GetKubeConfig() string
	GetKubectlContext() string
	ExportLogs(dest string) error
	Destroy() error
	LoadDockerImages(image string) error
	LoadImageArchive(archivePath string) error
}

Define an interface like above and make the ClusterProvider as an argument to functions in the envfuncs helper so that we can build a reusable set of envfunc ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@harshanarayana I like this refactor a lot. First impression is that it is doable and makes sense. Let's spend some times discussing to make sure we're not trapping future development work into a corner by being too specific.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 I agree. And I think we should do that as a pre-work before we can get this one in and not really use this PR to do that change. What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

xref: #245

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@harshanarayana do you plan to address the comments in your PR #239 soon? I am thinking when do we plan to proceed and close this one out?

@harshanarayana
Copy link
Contributor

Thanks a lot for the wonderful work @reetasingh

support/kwok/kwok.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 21, 2023
@reetasingh reetasingh force-pushed the reetas_kwok_feature_support branch from dca8922 to 8c89030 Compare April 21, 2023 05:06
support/kwok/kwok.go Outdated Show resolved Hide resolved
support/kwok/kwok.go Outdated Show resolved Hide resolved
support/kwok/kwok.go Outdated Show resolved Hide resolved
support/kwok/kwok.go Outdated Show resolved Hide resolved
support/kwok/kwok.go Outdated Show resolved Hide resolved
return k.getKubeconfig()
}

command := fmt.Sprintf(`kwokctl create cluster --name %s`, k.name)

Choose a reason for hiding this comment

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

by default, this would spin up a k8s cluster using docker-compose, if we want to default it to kind, need to pass-in --runtime kind explicitly.

Copy link
Contributor Author

@reetasingh reetasingh Apr 27, 2023

Choose a reason for hiding this comment

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

@Huang-Wei would --runtime kind require kind to be installed too? thinking if we need to add kind dependency as well when installing kwok

Choose a reason for hiding this comment

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

@wzshiming kwokctl wouldn't install the missing runtime binary, right?

Copy link
Contributor Author

@reetasingh reetasingh Apr 27, 2023

Choose a reason for hiding this comment

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

@Huang-Wei @wzshiming do we want to default it to kind? or we can let users pass config file to CreateWithConfig(kwokConfigFile string) where file has entry for runtime: kind

Choose a reason for hiding this comment

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

I'm fine with defaulting the same default runtime (docker) in kwokctl here; unless e2e-framework is keen on defaulting to kind.

Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion: since e2e-framework already has support for kind clusters, let's default to kind. If someone wants to use docker-compose, they can do so using the kwok config file.

Copy link
Contributor Author

@reetasingh reetasingh Jun 6, 2023

Choose a reason for hiding this comment

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

Hi @vladimirvivien since kwokctl defaults to using docker-compose I think it makes more sense to default to docker-compose. if we default to kind with --runtime kind argument we will not be able to override to docker-compose since --runtime kind takes precendence over kwok config file

examples/kwok/main_test.go Outdated Show resolved Hide resolved
@Huang-Wei
Copy link

/ok-to-test

@k8s-ci-robot k8s-ci-robot 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 Apr 26, 2023
@reetasingh
Copy link
Contributor Author

/retest-required

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 27, 2023
@jbpratt jbpratt mentioned this pull request May 30, 2023
@vladimirvivien
Copy link
Contributor

Will this PR use #246?

@harshanarayana
Copy link
Contributor

Will this PR use #246?

@vladimirvivien unless this is really really urgent to get into the framework right now, can we wait a few more days until we finalize #246 and get this in using that same interface ? But if getting this in is critical, I can understand 😄

@vladimirvivien
Copy link
Contributor

@harshanarayana I was asking because I do want it to wait to use #246.

Thanks

@harshanarayana
Copy link
Contributor

harshanarayana commented Jun 18, 2023

I'm all right with that.. Let us get this in if this is ready .. I can take care of refactoring this one. @vladimirvivien

@harshanarayana
Copy link
Contributor

@vladimirvivien FYI, I ported this kwok work into #246 already just now.

@reetasingh
Copy link
Contributor Author

reetasingh commented Jun 21, 2023

@vladimirvivien FYI, I ported this kwok work into #246 already just now.

Hi @harshanarayana @vladimirvivien I was looking forward to merging my PR in this repo. it means a lot to a new contributor like me. I can make the changes required to update to meet the interface definiton. @harshanarayana is it ok with you that I continue to work on this PR instead and get it merged after the interface defintion PR is merged?

@harshanarayana
Copy link
Contributor

harshanarayana commented Jun 22, 2023

@reetasingh sorry for any confusion that message might have caused. Migration done to other PR is only to show it is movable there easily.. And that was done so that this PR can be merged even before #246 finishes.. I think #246 PR isn't ready yet to be merged.. Like I mentioned above if this PR is all done and @vladimirvivien is okay with the changes on this current PR, and there isn't any more pending changes, let us definitely get this merged first

@reetasingh
Copy link
Contributor Author

@reetasingh sorry for any confusion that message might have caused. Migration done to other PR is only to show it is movable there easily.. And that was done so that this PR can be merged even before #246 finishes.. I think #246 PR isn't ready yet to be merged.. Like I mentioned above if this PR is all done and @vladimirvivien is okay with the changes on this current PR, and there isn't any more pending changes, let us definitely get this merged first

thanks @harshanarayana . yes this PR is all done . @vladimirvivien please take a look. I have addressed all open review comments.

support/kwok/kwok.go Outdated Show resolved Hide resolved
@vladimirvivien
Copy link
Contributor

@reetasingh and @harshanarayana
Apologies for rehashing this, but if I understand, we can merge this PR as is. Then later we'll open a new PR once #246 is merged ?

@harshanarayana
Copy link
Contributor

@vladimirvivien Yes. Let us get this one merged if you dont have any pending review to be addressed. We can take care of refactoring and fitting this into the other interface later on in a different PR or I can take care of that in my already open PR.

@vladimirvivien
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 2, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: reetasingh, vladimirvivien

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 2, 2023
@k8s-ci-robot k8s-ci-robot merged commit 841b3d1 into kubernetes-sigs:main Jul 2, 2023
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for using Kubernetes-SIGs Kwok cluster simulator
7 participants