Questions tagged [client-go]

208 questions
2
votes
0 answers

How Controller-runtime client can get RESTClient to run a command

we have built an operator via kubebuilder 2.0 successfully. In this operator, we need to run a cmd in a pod before we use k8s.io/client-go/kubernetes.Clientset which it grabs restconfig and run like execReq :=…
Honord
  • 101
  • 1
  • 8
2
votes
2 answers

Listing unscheduleable kubernetes nodes by taints in operator-sdk/client-go

I am trying to list all the nodes that are set to unscheduleable in an operator-sdk operator. Generally (pre 1.12) this means they have spec.unscheduleable set. So I tried this: nodes := &corev1.NodeList{} opts := &client.ListOptions{} if err :=…
jaxxstorm
  • 12,422
  • 5
  • 57
  • 67
2
votes
1 answer

Rolling update using k8s client-go

I'm struggling to find an example of performing a rolling update of a kubernetes deployment using client-go. Currently I scale to 0 and then back to 1 but that causes downtime. I wonder if there is a way to trigger a rolling update. I have nothing…
bianchi
  • 500
  • 2
  • 12
2
votes
2 answers

What is the package `unstructured` used for in k8s.io /apimachinery?

I could not understand what the package can do, the offical doc show nothing about unstructured. What the package used for ? Is it used for converting map[string]interface{} to K8S Obj…
jamlee
  • 1,234
  • 1
  • 13
  • 26
2
votes
3 answers

How to copy file to container with kubernetes client-go?

I want to use https://github.com/kubernetes/client-go to copy a file from my file system to a container and vice versa. kubectl cp -c Is there a function in the go client that wraps the calls?…
Kyroy
  • 173
  • 1
  • 8
1
vote
1 answer

How to list Pods events based on Pod Labels in kubernetes client-go

I want to fetch the pod events by using the Pod label in Kubernetes client-go, I had tried the below code but not working by passing the namepsace nd podname , namespace := "test" podNameInital := "testpods" labelSelector :=…
HARISH
  • 193
  • 4
  • 14
1
vote
0 answers

Empty output of exec while controller is running on cluster

I have a controller with one function to execute commands in the pods (same namespace as the operator). I'm able to see the output while controller is started locally, when the same controller runs on the cluster (as pod) it gives an empty output,…
Lukasz
  • 11
  • 2
1
vote
2 answers

How to return a custom user friendly error message in Kubernetes?

I have a backend with golang that talks to k8s. I want to reformulate the error response that i get from k8s and send it to the frontend. I want to return a meaningful validation error messages for the user, when he add a non valid name, something…
dom1
  • 425
  • 1
  • 2
  • 19
1
vote
1 answer

Kubernetes informer fails with Unauthorized

I'm trying to construct a Kubernetes informer outside of the EKS cluster that it's watching. I'm using aws-iam-authenticator plugin to provide the exec-based credentials to the EKS cluster. For the plugin to work, I'm assuming an IAM role and…
tskuzzy
  • 35,812
  • 14
  • 73
  • 140
1
vote
1 answer

How to get "kind" response from Kubernetes APIServer using ReST interface

I am using the Golang client-go library to communicate with the Kubernetes API Server at the ReST GET, POST level. The response received is not a well-formed JSON structure and also not a "kind" API Object. The program snippet is: kubeconfig :=…
surajit_c
  • 21
  • 3
1
vote
0 answers

client-go: watch.RetryWatcher: How to obtain a stream of resource changes with monotonically increasing resource versions?

I need to react to changes to CRs inside a K8s cluster, and have created the following PoC. Running the program yields the following output after creating a new pod kubectl run NAME --image=nginx --restart=Never. Output: $ go run ./cmd/watcher/ …
Shuzheng
  • 11,288
  • 20
  • 88
  • 186
1
vote
0 answers

How to install dependencies in the vendor directory of a Go project for running k8s.io/code-generator/generate-groups.sh

I don't have much experience in working with go projects so I am not exactly sure how the go modules feature works. I am following along the sample-controller from the book 'Programming Kubernetes' which describes creating a custom operator, and the…
1
vote
2 answers

Find if pod is being terminated due to statefulset deletion

I need to perform some operations on a different server statefulset when pods inside a client statefulset comes down only because of a statefulset deletion. I can trap the sigterm signal which is sent during pod termination from inside the pod, but…
1
vote
2 answers

The equivalent of "kubectl get crds" in golang

If I want to list namespaces on the cluster using client-go I can use a simple command to do this: clientset.CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{}) And what would the equivalent of the kubectl get crd command look like? Is…
samuelus
  • 13
  • 2
1
vote
1 answer

client-go var set from function which returns empty interface; can't seem to use it though("obj is not a type")...need clarification

So, I'm writing a client-go app and took some code as boilerplate, but I'm struggling with a portion of code: Here's what I'm using for boilerplate: https://www.codetd.com/en/article/7292846 and I'm tweaking to my needs. Here's my code: //…
Jim
  • 1,499
  • 1
  • 24
  • 43