kubernetes-go-client

Kubernetes client go couldn't find module

时间秒杀一切 提交于 2021-02-19 02:38:06
问题 I'm trying to connect to my local Kubernetes cluster hosted on minikube , here's the code for the same, now when I do go run minikube.go , it gives me an error saying: ../../../pkg/mod/k8s.io/client-go@v11.0.0+incompatible/kubernetes/scheme/register.go:26:2: module k8s.io/api@latest found (v0.19.0), but does not contain package k8s.io/api/auditregistration/v1alpha1`. Now, I tried to manually install the package using go get then I found out that this package does not exist. How can I make it

kubernetes client-go: convert labelselector to label string

ぃ、小莉子 提交于 2021-02-07 18:29:22
问题 In the kubernetes client-go API (or another library that uses it), is there a utility function to convert a k8s.io/apimachinery/pkg/apis/meta/v1/LabelSelector to a string to fill the field LabelSelector in k8s.io/apimachinery/pkg/apis/meta/v1/ListOptions ? I digged through the code of client-go but I can't find a function like that. The LabelSelector.Marshall() nor LabelSelector.String() give me that (unsurprisingly, because that's not their purpose, but I tried it anyway). Background I have

how to get status of a pod in kubernetes using go-client

北城以北 提交于 2021-02-07 08:20:21
问题 I am trying to delete a pod in my kubernetes cluster, then check its status to see how long does it take for the pod to get down, and up again. I could not find any helpful example for the second part which is getting a specific pod status using go-client. Any help is appreciated. 回答1: You can use Get function to get specific pod information (below examples are getting whole Status struct): pod, _ := clientset.CoreV1().Pods("kubernetes").Get(pod.Name, metav1.GetOptions{}) fmt.Println(pod

how to get status of a pod in kubernetes using go-client

醉酒当歌 提交于 2021-02-07 08:19:11
问题 I am trying to delete a pod in my kubernetes cluster, then check its status to see how long does it take for the pod to get down, and up again. I could not find any helpful example for the second part which is getting a specific pod status using go-client. Any help is appreciated. 回答1: You can use Get function to get specific pod information (below examples are getting whole Status struct): pod, _ := clientset.CoreV1().Pods("kubernetes").Get(pod.Name, metav1.GetOptions{}) fmt.Println(pod

How to use the kubernetes go-client to get the same Pod status info that kubectl gives

时光毁灭记忆、已成空白 提交于 2021-02-07 05:43:05
问题 Using the kubernetes go-client ( k8s.io/client-go/kubernetes ), I know how to get pod.Status and I find the pod.Status.Phase useful (docs). For example, I can output the Pod Status Phase of all Pods using this: ... api := clientset.CoreV1() pods, err := api.Pods("").List(metav1.ListOptions{}) for i, pod := range pods.Items { podstatusPhase := string(pod.Status.Phase) podCreationTime := pod.GetCreationTimestamp() age := time.Since(podCreationTime.Time).Round(time.Second) podInfo := fmt.Sprintf

K8s CRD Error: Unsupported Media type 415

爱⌒轻易说出口 提交于 2020-04-18 12:35:42
问题 So I was following along this tutorial (https://www.youtube.com/watch?v=KBTXBUVNF2I) and after setting up the reconciler, when I execute "make run", I am getting the following error: /Users/sourav/go/bin/controller-gen object:headerFile=./hack/boilerplate.go.txt paths="./..." go fmt ./... go vet ./... /Users/sourav/go/bin/controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases go run ./main.go 2020-03-15T22:13:29