Questions tagged [client-go]

208 questions
3
votes
0 answers

How to retrieve ephemeral storage kubernetes metric via client-go and golang

I am able to fetch CPU and memory usage of a pod in a Kubernetes cluster with client-go using the following piece of code. podContainers := podMetric.Containers for _, container := range podContainers { cpu +=…
shailesh
  • 75
  • 1
  • 10
3
votes
1 answer

How to list my k8s jobs with a complex LabelSelector by client-go?

I want to list my k8s jobs with a label selector by client-go like this command: $ kubectl get jobs -l 'hello-world in (London, China, NewYork)' I looked through the source code of client-go, then I wrote some code like this: func listJobs(cli…
Reed Chan
  • 525
  • 6
  • 16
3
votes
1 answer

Is there a better way to list K8s Events that belong to a specific K8s Object?

Is there a better way to list K8s Events that belong to a specific K8s Object? For example, if I wanted to list all events that belonged to a Pod named "podname", I'd do the following: opts := metav1.ListOptions{ TypeMeta: …
Daniel W
  • 31
  • 3
3
votes
1 answer

How to handle K8s go client informer error events

I have written a Go-based K8s client application to connect with the K8s cluster. To handle the realtime notification from the K8s cluster (add, delete, update) of Pod, Namespace, and Node, I have programmed an informer. The code snippet is below. I…
3
votes
1 answer

Getting error "http: TLS handshake error from EOF" in kubernetes go program

I have a kubernetes pod configured as a webserver supporting https. This pod is giving the TLS handshake error logs. When we try to access the loadbalancer service IP on the browser, it gives error - the connection is not secure proceed to unsafe.…
PREETI BANSAL
  • 185
  • 2
  • 12
3
votes
3 answers

How to retrieve all the data from kubectl describe pods from an in-cluster client-go api call

I need to grab some pod information which will be used for some unit tests which will be run in-cluster. I need all the information which kubectl describe po gives but from an in cluster api call. I have some working code which makes an api call…
sensedata1
  • 31
  • 2
  • 3
3
votes
2 answers

Using Kubernetes client-go how to check programatically if Node is "Ready"?

It looks like I might need to traverse the v1.Node->NodeStatus->Conditions[] slice and sort by transition time and find if the most recent timed condition is NodeConditionType == "Ready". I am wondering if there is a better way or if that approach…
Philip Lombardi
  • 1,276
  • 2
  • 17
  • 26
3
votes
2 answers

kubernetes client-go error: an empty namespace may not be set during creation

Programmatically creating a pod using the Kubernetes client-go gives me the following error: an empty namespace may not be set during creation Started from this…
C. Damoc
  • 476
  • 4
  • 9
3
votes
1 answer

How to idiomatically fill empty fields with default values for Kubernetes API objects?

I want to compare two Kubernetes API objects (e.g. v1.PodSpecs): one of them was created manually (expected state), the other one was received from the Kubernetes API/client (actual state). The problem is that even if the two objects are…
kispaljr
  • 1,942
  • 2
  • 16
  • 22
3
votes
0 answers

Issue using in-cluster kubernetes configuration with client-go library on google cloud build

I'm having a bit of a challenge try to build my app which is using the golang client-go library. What the app does is provide and api which then deploys a pod to a kubernetes cluster. Now the app is able to deploy a pod successfully if I use an out…
Fadyboy
  • 107
  • 1
  • 2
  • 11
3
votes
2 answers

Patching deployments via kubernetes/client-go

Having trouble figuring out what is wrong. I have a remote kubernetes cluster up and have copied the config locally. I know it is correct because I have gotten other commands to work for me. The one I can't get to work is a deployment patch. My…
L. Norman
  • 483
  • 7
  • 21
2
votes
2 answers

Facing issue in using github.com/kedacore/keda/pkg/apis/keda/v1alpha1

I am using Keda along with client-go in golang. I am facing issue in getting the imported package This is the error message go get github.com/kedacore/keda/pkg/apis/keda/v1alpha1 go: downloading github.com/kedacore/keda v1.5.0 go:…
2
votes
2 answers

How to get current namespace of an out-cluster go Kubernetes client?

How can I get the current namespace of an out-of-cluster Go Kubernetes client using the client-go library? I am using this code example: https://github.com/kubernetes/client-go/blob/master/examples/out-of-cluster-client-configuration/main.go for…
Fabrice Jammes
  • 2,275
  • 1
  • 26
  • 39
2
votes
0 answers

When I pull the k8s related scheduler code, I always report an error. How can I solve it?

My goproxy config: https://goproxy.cn,direct When I try to: go get k8s.io/kubernetes/pkg/scheduler/framework And then show error: go: k8s.io/api@v0.0.0: reading k8s.io/api/go.mod at revision v0.0.0: git ls-remote -q origin Whow should I do? At the…
Shyunn
  • 23
  • 3
2
votes
0 answers

K8s Test - NewSimpleClientset for schemaless custom resource

I have a method which uses client-go's dynamic.Interface to dynamically fetch a schemaless custom resource called IstioOperator. iops, err := client.Dynamic().Resource(constants.IstioOperatorGVR). Namespace(brConfig.IstioNamespace). …
Kaushal28
  • 5,377
  • 5
  • 41
  • 72
1 2
3
13 14