Giter Club home page Giter Club logo

Comments (16)

drssdinblck avatar drssdinblck commented on July 21, 2024 1

I suspect this is not going to be fixed anymore. Probably the standard way now is to use the API project and generate the client using the Kubernetes client code generator. I followed the documentation in the API project and got it working for kubevirt and CDI.

did you port 'kubecli' into your project? I still encounter such problem after copied the kubecli package from client-go into my project.

No, what I did is follow the instructions from https://github.com/kubevirt/api. Namely, first install the client-gen binary via

go install k8s.io/code-generator/cmd/client-gen@latest

Then add the API project as a dependency to your project

go get kubevirt.io/api

Then run the code generator

client-gen --input-base="kubevirt.io/api/" --input="core/v1" --output-package="testapi/client" --output-base="../" --clientset-name="versioned" --go-header-file boilerplate.go.txt

Then you can use the generated API client in your code.

from client-go.

drssdinblck avatar drssdinblck commented on July 21, 2024

I can confirm the same using golang 1.20.6.

from client-go.

jeven2016 avatar jeven2016 commented on July 21, 2024

Finally, I have to generate the client by myself. And I link my project here for reference : https://github.com/jeven2016/kubevirt-manager

I generated a project named 'kubevirt.io' based on 'kubevirt/api' (https://github.com/kubevirt/api), and it now can work for go 1.19 with kubernetes v0.27.1

from client-go.

Roysav avatar Roysav commented on July 21, 2024

Same here, currently unusable

from client-go.

yavidor avatar yavidor commented on July 21, 2024

Also here

from client-go.

jeven2016 avatar jeven2016 commented on July 21, 2024

any updates?

from client-go.

drssdinblck avatar drssdinblck commented on July 21, 2024

I suspect this is not going to be fixed anymore. Probably the standard way now is to use the API project and generate the client using the Kubernetes client code generator. I followed the documentation in the API project and got it working for kubevirt and CDI.

from client-go.

yavidor avatar yavidor commented on July 21, 2024

Can you share it?

from client-go.

jeven2016 avatar jeven2016 commented on July 21, 2024

I suspect this is not going to be fixed anymore. Probably the standard way now is to use the API project and generate the client using the Kubernetes client code generator. I followed the documentation in the API project and got it working for kubevirt and CDI.

did you port 'kubecli' into your project? I still encounter such problem after copied the kubecli package from client-go into my project.

from client-go.

mtaylor91 avatar mtaylor91 commented on July 21, 2024

I suspect this is not going to be fixed anymore. Probably the standard way now is to use the API project and generate the client using the Kubernetes client code generator. I followed the documentation in the API project and got it working for kubevirt and CDI.

I was able to generate the client using client-gen, however it seems it doesn't include the Start/Stop methods.

Seems like a bit of a sub-optimal solution. If generating the client is the recommended path forward, is the recommended way to handle start/stop actions just to patch the VirtualMachine.Spec.Running field? Or is there a straightforward way to support the Start/Stop methods in the generated client? Or will this issue (module imports) be fixed in kubevirt/client-go?

from client-go.

jeven2016 avatar jeven2016 commented on July 21, 2024

I suspect this is not going to be fixed anymore. Probably the standard way now is to use the API project and generate the client using the Kubernetes client code generator. I followed the documentation in the API project and got it working for kubevirt and CDI.

I was able to generate the client using client-gen, however it seems it doesn't include the Start/Stop methods.

Seems like a bit of a sub-optimal solution. If generating the client is the recommended path forward, is the recommended way to handle start/stop actions just to patch the VirtualMachine.Spec.Running field? Or is there a straightforward way to support the Start/Stop methods in the generated client? Or will this issue (module imports) be fixed in kubevirt/client-go?

I think you have to directly call the rest api after checked the code of kubecli, the below code I currently used can work as expected:

VmSubresourceURLFmt = "/apis/subresources.kubevirt.io/%s/namespaces/%s/virtualmachines/%s/%s"

// invoke rest api to start a VMI
func (v *VmManager) start(ctx context.Context, namespace string, name string, startOptions *kv1.StartOptions) error {
uri := fmt.Sprintf(constants.VmSubresourceURLFmt, kv1.ApiStorageVersion, namespace, name, "start")

optsJson, err := json.Marshal(startOptions)
if err != nil {
	return err
}
    // here kvClient  is  *versioned.Clientset 
return v.kvClient.RESTClient().Put().AbsPath(uri).Body(optsJson).Do(ctx).Error()

}

// invoke rest api to stop a VMI
func (v *VmManager) stop(ctx context.Context, namespace string, name string, stopOptions *kv1.StopOptions) error {
uri := fmt.Sprintf(constants.VmSubresourceURLFmt, kv1.ApiStorageVersion, namespace, name, "stop")
optsJson, err := json.Marshal(stopOptions)
if err != nil {
return err
}
return v.kvClient.RESTClient().Put().AbsPath(uri).Body(optsJson).Do(ctx).Error()
}

from client-go.

yavidor avatar yavidor commented on July 21, 2024

I suspect this is not going to be fixed anymore. Probably the standard way now is to use the API project and generate the client using the Kubernetes client code generator. I followed the documentation in the API project and got it working for kubevirt and CDI.

did you port 'kubecli' into your project? I still encounter such problem after copied the kubecli package from client-go into my project.

No, what I did is follow the instructions from https://github.com/kubevirt/api. Namely, first install the client-gen binary via

go install k8s.io/code-generator/cmd/client-gen@latest

Then add the API project as a dependency to your project

go get kubevirt.io/api

Then run the code generator

client-gen --input-base="kubevirt.io/api/" --input="core/v1" --output-package="testapi/client" --output-base="../" --clientset-name="versioned" --go-header-file boilerplate.go.txt

Then you can use the generated API client in your code.

How do I reference it in my code instead of the normal package?

from client-go.

kubevirt-bot avatar kubevirt-bot commented on July 21, 2024

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

from client-go.

kubevirt-bot avatar kubevirt-bot commented on July 21, 2024

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten

from client-go.

kubevirt-bot avatar kubevirt-bot commented on July 21, 2024

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

from client-go.

kubevirt-bot avatar kubevirt-bot commented on July 21, 2024

@kubevirt-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

/close

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.

from client-go.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.