Questions tagged [client-go]

208 questions
2
votes
1 answer

How to get schema.GroupVersionResource for given k8s resource's json

client-go v0.19.2 golang 1.13 I'm building a tool to create k8s resources from json(just like kubectl create -f). I found that dynamic client can do such things,but when i use it with code bellow,i found it is hard to find…
Jonyhy96
  • 168
  • 1
  • 2
  • 10
2
votes
1 answer

Filter secret objects by label in client-go

I am trying to get some secret objects from my cluster using the k8s go client library as follows secret, err := clientset.CoreV1().Secrets("mynamespace").Get("name-of-my-secret", metav1.GetOptions{}) This worked well as long as I had to get just…
pkaramol
  • 16,451
  • 43
  • 149
  • 324
2
votes
1 answer

What is the merge logic of client-go MergePatch or StragegyMergePatch for map type field?

What does the MergePatch or StragegyMergePatch do when patching map type field like labels? When I use MergePatch or StragegyMergePatch, if I add some labels in yaml file, then transfer the data of the entire yaml file to patch method, it could…
shuiqiang
  • 437
  • 1
  • 6
  • 11
2
votes
0 answers

How to use a context other than the current context in client-go to access multiple clusters?

I followed Kubernetes documentation to access clusters using client-go: https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-api-from-within-a-pod Now, in my case, in my kubeconfig, I've more than a single cluster.…
pep8
  • 371
  • 3
  • 18
2
votes
1 answer

client-go watch events for specific pods

I am watching events via clientset, but I want to watch events for a specific Pod, so I add lablelselector to filter them, unfortunately it doesn't work. Adding LabelSelector is a good way to watch pod status, but it doesn't work for events. …
Joe
  • 623
  • 7
  • 16
2
votes
1 answer

Is it possible to add an already existing CRD into a custom Kubernetes operator using Go?

I'm currently working on my own custom operator that deploys a fully functional Wordpress. I'm required to implement SSL. Now this is where I'm stuck, I'm not really sure how to implement this using Go. Is there a way of adding already existing…
Modx
  • 223
  • 2
  • 9
2
votes
1 answer

How to create docker Secret with client-go

Assume I know the following secret parameters: "name": "aaa", "docker-server": "a.b.com", "docker-username": "aaa", "docker-password": "aaaa", "docker-email": "aaa@gmail.com" Then I want to use client-go to create a pull-image…
Joe
  • 623
  • 7
  • 16
2
votes
1 answer

Kubernetes services for all pods and another for only the leader

In Kubernetes, is it possible to have 2 services for a single deployment, one which is "standard" and proxies in front of all ready pods, and a second service which sends traffic only the elected leader? If so how? I am using client-go for leader…
user2133814
  • 2,431
  • 1
  • 24
  • 34
2
votes
1 answer

Openshift API query with Openshift/Client-go

Im trying to list all the build configs in openshift with help of openshift/client-go import ( "context" "flag" "fmt" "os" "path/filepath" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" …
2
votes
1 answer

Unexpected results from clientset.AuthorizationV1().SelfSubjectAccessReviews().Create()

I'm trying to incorporate the kubectl auth can-i logic into my code base, but while the code is working, the results are not what I expect. I have 2 users (minikube/jenny). minikube has full cluster wide access, but jenny is limited to a namespaced…
GrandVizier
  • 499
  • 7
  • 19
2
votes
1 answer

Can I create many Job at the same time in kubernetes by client api?

I want to create hundreds of Jobs in kubernetes by its api. Is there any way to do this? I have to create them one by one now. Thanks.
kyleqian
  • 311
  • 1
  • 3
  • 14
2
votes
1 answer

How to execute multiple commands in a Pod's container with client-go?

So I've tried to execute a chain i.e. multiple commands on a Pod's container using client-go, and it seems to only work for some commands like ls. Here is what I've tried: req :=…
Gigaxel
  • 1,058
  • 1
  • 9
  • 20
2
votes
2 answers

How to get Kubernetes cluster name from K8s API using client-go

How to get Kubernetes cluster name from K8s API mentions that curl http://metadata/computeMetadata/v1/instance/attributes/cluster-name -H "Metadata-Flavor: Google" (from within the cluster), or kubectl run curl --rm --restart=Never -it…
2
votes
1 answer

Go mod download complaining about build constraints

I can't for the life of me figure out why this is doing this. Another guy claims this works for him and that I have an environment issue. Yet every other dozen projects are working fine for me. So just for the fun of it I started out with a…
user11471017
2
votes
2 answers

How to create kubernetes objects by passing a yaml file like kubectl apply in golang

I am creating a tool that will create kubernetes object using a yaml file. I am writing it in golang. The tool would like to achieve same behaviour as kubectl apply -f test.yaml
Know Nothing
  • 1,121
  • 2
  • 10
  • 21