Questions tagged [client-go]

208 questions
4
votes
1 answer

Kubernetes client-go use Informers to watch deployments

I'm trying to use client-go informers to get the replica count on deployments. Whenever autoscaling changes the number of replicas, I need to retrieve this in order to handle some other logic. I was previously using the Watch() function, but there…
Syd
  • 71
  • 6
4
votes
1 answer

What Condition Causes the Pod Log Reader Return EOF

I am using client-go to continuouslly pull log streams from kubernetes pods. Most of the time everything works as expected, until the job runs couple of hours. The code is like below: podLogOpts := corev1.PodLogOptions{ Follow: true, } kubeJob, err…
Wallace
  • 561
  • 2
  • 21
  • 54
4
votes
1 answer

How to connect to Kubernetes Cluster using ServiceAccount Token?

For any example, the client-go connect to the kubernetes cluster with the kubeconfig file, but I don't want to do that. I've createed a service account, now I have a ServiceAccount Token, how to connect to the kubernetes cluster with this token…
yzhengwei
  • 67
  • 2
  • 6
4
votes
1 answer

unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined

I am working on a dynamic kubernetes informer to watch over my kubernetes cluster for events and the discovery of all kubernetes components. But, When I am trying to access the KUBECONFIG via the InClusterConfig method, I am getting the following…
4
votes
1 answer

Kubernetes Log Splitting (Stdout/Stderr)

When I call kubectl logs pod_name, I get both the stdout/err combined. Is it possible to specify that I only want stdout or stderr? Likewise I am wondering if it is possible to do so through the k8s rest interface. I've searched for several hours…
Zel
  • 78
  • 1
  • 6
4
votes
3 answers

How to force a full resync on a SharedIndexInformer in a custom controller

I'm writing a custom controller for Kubernetes in Go with the help of client-go. It is based on the sample-controller and working great so far. The SharedIndexInformer has the option to periodically resync all objects. (Parameter resyncPeriod is set…
4
votes
1 answer

How to write simple tests for client-go using a fake client?

Problem I am looking for the correct way to test my code below, I couldn't find any examples how can I do it. Only main_test.go but it is missing main.go and for me, it isn't obvious how can I use it. I also went through Github issues but I can not…
FL3SH
  • 2,996
  • 1
  • 17
  • 25
3
votes
0 answers

Exclude "Status" from serialized output of Kubernetes objects

I would like to serialize a Subscription resource (from github.com/operator-framework/api/pkg/operators/v1alpha1) to YAML using code like this: subscription := operatorsv1alpha1.Subscription{ TypeMeta: metav1.TypeMeta{ …
larsks
  • 277,717
  • 41
  • 399
  • 399
3
votes
2 answers

Controller not notified about final Job status

I'm building an app that spawns Jobs (batch/v1), I need to update my Custom Resource status with the Job status. I setup the controller with the following: func (r *JobsManagedByRequestedBackupActionObserver) SetupWithManager(mgr ctrl.Manager) error…
3
votes
0 answers

Kubernetes client-go informers getting "Unauthorized" error after 15 mins

What happened? Kubernetes client-go informers getting unauthorized error after 15 mins. As per Kubernetes Client Go blogs and discussion we see the client go wil refresh the token after 15 mins but it is not happening. Any way to refresh the token…
3
votes
2 answers

Filtering items are stored in Kubernetes shared informer cache

I have a Kubernetes controller written using client-go informers package. It maintains a watch on all Pods in the cluster, there are about 15k of these objects, and their YAML representation takes around 600 MB to print (I assume their in-memory…
ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214
3
votes
3 answers

How to use kubernetes go-client on amazon eks service?

I've been looking for documentation for a long time and still couldn't find any clear connection procedure. I came up with this code sample : package aws import ( "fmt" "net/http" "github.com/aws/aws-sdk-go/aws/session" …
raphael.oester
  • 416
  • 2
  • 14
3
votes
2 answers

How to Import KFServing Client Package in Golang

We are using KFServing in our kubernetes cluster. The project provides InferenceService struct and clientset in the folder pkg/. How to import these packages under pkg/client? My code is as below: package main import ( "fmt" kfs …
Wallace
  • 561
  • 2
  • 21
  • 54
3
votes
1 answer

Using client-go to explain a resource

Using kubectl I can show documentation for a resource using explain: kubectl explain storageclass Is there similar functionality available with client-go?
Trevor
  • 6,659
  • 5
  • 35
  • 68
3
votes
0 answers

Add Labels not working via dynamic resource and Client-go

I am using client-go to create resource by parsing yaml files, click code. But setting labels to resources not work via unstructed interface, how to do that? func (u *Unstructured) SetLabels(labels map[string]string) { if labels == nil…
Wallace
  • 561
  • 2
  • 21
  • 54
1
2
3
13 14