Questions tagged [kubebuilder]

Kubebuilder is a toolkit for building Kubernetes controllers in Go. Use this tag for questions about building custom Kubernetes controllers or operators using the Kubebuilder framework.

Kubebuilder is a toolkit for building Kubernetes controllers in . It provides several of the required parts of a controller, including a core event loop that can monitor changes to Kubernetes resources, freeing you to write only the object-reconciliation code.

In addition to the material in The Kubebuilder Book it will be helpful to understand core concepts, especially The Kubernetes API and the API reference documentation.

Questions about building custom controllers or operators using Kubebuilder should have the tag. These questions will also frequently be related to and . An operator frequently builds as well.

79 questions
2
votes
1 answer

Kubebuilder: resource deletion not having expected side effects

I'm creating a custom resource definition (CRD) with an associated controller using kubebuilder. My controller reconcile loop creates a deployment sub-resource and parents it to the custom resource using …
Chris Gillum
  • 14,526
  • 5
  • 48
  • 61
2
votes
1 answer

How to generate Events for a certain resource Kubernetes Go Operator

I'm writing a Kubernetes Operator in Go and I would like to generate events in the same way Pods do, i.e. at each point of the reconciliation I want to write an event which can be examined using kubectl describe myresource. I found the package that…
2
votes
1 answer

In k8s operators, how do I link the unique metadata.name in spec of a CRD to a unique object ID that my server generates

I am developing a new Operator to manage CRDs of my business logic objects. My business objects are stored in Mongo, and thus, we need this BSON ID (12 letter length GUID) to make subsequent changes to this object. The question is, how do I link…
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
1 answer

Is kubebuilder/controller-runtime still maintained

I used to define my custom resources using apiserver-builder, which is currently deprecated and recommended to use kubebuilder instead. I tried to generate my resources using kubebuilder, but i found sigs.k8s.io/controller-runtime version in…
Siyu Wang
  • 31
  • 5
2
votes
1 answer

Golang dep unable to resolve dependencies

I am using kubebuilder to create kubernetes operator project. After running the project init command described in quickstart guide kubebuilder init --domain k8s.io --license apache2 --owner "The Kubernetes Authors" dep ensure returns with error log…
captainchhala
  • 831
  • 1
  • 7
  • 14
1
vote
0 answers

How to handle loss of Event in Custom Controller in K8s

We have implemented a custom controller in kubernetes, which kind is Pod using the kubebuilder tool. This controller is listening for the Pod event in namespace Queue on pods with label of router. mgr, err :=…
1
vote
2 answers

kubebuilder api v1 dependency to v1beta1

Is it ok for a v1 CRD to have data structure dependency to a struct defined in v1beta1 package? v1 looks like this: type MyCRDSpec struct { Field1 *v1beta1.MyCustomStruct1 `json:"field1,omitempty" validate:"dive"` //dependency to…
mammad
  • 175
  • 8
1
vote
1 answer

How to generate OpenAPI spec file using kubebuilder

I am generating Kubernetes CRD (Custom Resource Definition) using kubebuilder. Along with CRD, I also need to document the REST endpoints by creating OpenAPI v3 Spec (OAS) file. Is there a way to get this done using kubebuilder? Also does…
Santi
  • 67
  • 7
1
vote
0 answers

Using ecszap logger with Kubernetes controller-runtime

I am wrestling with logging in a Kubernetes operator built with: KubeBuilderVersion: 3.7.0 go version: go1.20.1 linux/amd64 Up and until now, for logging purposes, I have made use of the zap logger package…
Morné Kruger
  • 309
  • 1
  • 12
1
vote
1 answer

Some executable files show "no such file or directory" after run in docker, while some are not

This is my Dockerfile: FROM gcr.io/distroless/static:nonroot WORKDIR / COPY ls . COPY tail . COPY test . COPY manager . ENTRYPOINT ["/manager"] after [root@master go-docker-test]# docker build -t strangething:v1.13 . [root@master go-docker-test]#…
1
vote
1 answer

How to provide Owner Reference to the `ListOptions` of KubeBuilder's List method?

I want to list the pods that are owned by the resource X from the Kubernetes cluster using Kubuilder's List(ctx context.Context, list ObjectList, opts ...ListOption) method. ListOptions contains options for limiting or filtering results. Here is…
1
vote
1 answer

Maximize the number of CustomResources that a CustomResourceDefinition can have | kubebuilder & operator-sdk

I'm developing a kubernetes operator that represents a very simple api and a controller. I would like to maximize the number of the CustomResources those could belonging to the specific CustomResourceDefinition that the operator defines. (As…
Miklós
  • 51
  • 6
1
vote
0 answers

Is it possible to manually trigger Kubernetes reconciliation for a particular CR?

We have a defined a Custom resource called Tenant (we use kubebuilder for writing the operator) apiVersion: iam.ai.com/v1alpha1 kind: Tenant metadata: name: testing-tenant spec: The operator creates a few resources like namespace, roles, and…
Never Back Down
  • 138
  • 2
  • 12
1
vote
0 answers

Injecting error in Kubernetes fake client

I'm using the FakeClient by sigs.k8s.io/controller-runtime/pkg/client/fake. In one of my unit tests, the Update() method of FakeClient should fail to update the k8s object and return an error. How to achieve this without faking the Update() method.…