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

Unable to build a binary or compile the example files #3

Open
sanjiths opened this issue Dec 23, 2020 · 3 comments
Open

Unable to build a binary or compile the example files #3

sanjiths opened this issue Dec 23, 2020 · 3 comments

Comments

@sanjiths
Copy link

I am trying to build a binary for https://github.com/vladimirvivien/k8s-client-examples/blob/master/go/podlist/maing.go
I have imported the required packages and facing the below issue:

[sansampa@localhost podlist]$ go build maing.go 
import cycle not allowed
package main
	imports k8s.io/apimachinery/pkg/apis/meta/v1
	imports k8s.io/apimachinery/pkg/labels
	imports k8s.io/apimachinery/pkg/util/validation
	imports net
	imports internal/nettrace
	imports net/http/httptrace
	imports crypto/tls
	imports crypto/tls
import cycle not allowed
package main
	imports k8s.io/apimachinery/pkg/apis/meta/v1
	imports k8s.io/apimachinery/pkg/labels
	imports k8s.io/apimachinery/pkg/util/validation
	imports net
	imports internal/nettrace
	imports net/http/httptrace
	imports internal/nettrace
/usr/local/go/src/net/dnsclient.go:12:8: non-standard import "golang.org/x/net/dns/dnsmessage" in standard package "net"
/usr/local/go/src/net/http/h2_bundle.go:47:9: non-standard import "golang.org/x/net/http/httpguts" in standard package "net/http"

Could you pls tell me how to proceed?

@vladimirvivien
Copy link
Owner

@sanjiths I updated the Go example with support for Go modules. Take a look to see if that helps.

@sanjiths
Copy link
Author

sanjiths commented Jan 26, 2021

Hi @vladimirvivien! It really helped :) thank you so much (y)
Now, I have one more problem! How can i use this binary from inside a container or a pod?

I am facing below issue:


./podlist tree
2021/01/26 10:42:39 stat /home/vault/.kube/config: no such file or directory
[vault@vaultagent-0 tmp]$ vi /home/vault/.kube/config:

Thanks,
Sanjith S

@vladimirvivien
Copy link
Owner

@sanjiths the code in this example is written to be used outside of a cluster.
But it's easy to change your code to make it work from within a cluster.
Checkout the link below (from the client-go project), it shows what to change to fix your issue:

https://github.com/kubernetes/client-go/blob/b72204b2445de5ac815ae2bb993f6182d271fdb4/examples/in-cluster-client-configuration/main.go#L42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants