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
3
votes
1 answer

How to display a kubectl column using a fraction format (i.e. X/Y) for a Custom Resource

In Kubernetes, is it possible to display a column using a fraction format (i.e. X/Y) using the "additionalPrinterColumns" field of a CRD? More precisely, I would like kubectl to display the description of a CR field using the same format than the…
3
votes
2 answers

How to assign default value for Enum type

From this Go code, I am generating the CRD yaml. I am using following structure in Go. I want to assign default value for parameters 'Size' and 'Case' from one of the enum options. Assigning // +kubebuilder:validation:default:=512 does not take…
user3933111
  • 31
  • 1
  • 4
3
votes
1 answer

Kubernetes: Is it possible to mutate the status subresources in the mutation admission webhooks?

I am writing the mutate and validate admission webhooks for the CRDs. I am using kubebuilder to setup the CRDs. Spec and status subresources are behaving correctly. As a part of mutation, I am having a requirement where I need to update the status…
Yudi
  • 831
  • 4
  • 10
  • 19
2
votes
0 answers

How to unit test custom resource validation logic

I am maintaining several custom operators that are using kubebuilder and the operator framework, and with the graduation of CustomResourceDefinition validation rules to beta, I wan't to move some of the more complex validation rules that were…
2
votes
1 answer

How to format the way provider resources get generated with Crossplane?

Im looking to build a crossplane provider for my organization however im running to issues with the code generation. Is there a way to manipulate how the resource names get generated? The Upjet code generations tools do not seem to respect the…
2
votes
0 answers

Operator Sdk query regarding fetching an instance from k8 cluster

memcached := &cachev1alpha1.Memcached{} err := r.Get(ctx, req.NamespacedName, memcached) in the above code are we making an empty object of the struct Memcached then getting this instance from the kubernetes cluster. if this is an empty instance…
2
votes
1 answer

Setup Kubernetes Pods via API Call using Go and Operator SDK

I am trying to create a controller that can create and delete Pods via API calls using operator-sdk with Go. The controller should be able to accept a POST call with information such as {imageTag:"", namespace:""} to setup a Pod that can return a…
Mahesh
  • 513
  • 3
  • 12
2
votes
1 answer

Update status in a custom Kubernetes controller in golang

I am building a Go Kubernetes operator. I have used kubebuilder to create it. I want to store some internal details in the CRD status. I have tried : To update the whole resource : if err = r.Client.Update(ctx, upCRD); err != nil { return…
Paul Barrié
  • 320
  • 3
  • 12
2
votes
1 answer

Why does kubebuilder include // +build !ignore_autogenerated in zz_generated.deepcopy.go files?

Every deepcopy generated file that is produced by make with kubebuilder produces a file with a // +build !ignore_autogenerated build tag directive at the top. //go:build !ignore_autogenerated // +build !ignore_autogenerated /* Licensed under the…
2
votes
0 answers

Best practice to trigger reconcile after updating K8S Operator

We have implemented an Operator for CRD in Kubernetes by Kubebuilder, and it is expected that the tasks this Operator needs to do in "reconcile" will be changed over time (more logic/handling will be appended). e.g. First release @time t1 -> logic…
2
votes
1 answer

What is the role of ControllerManagerConfig generated in kubebuilder

I use kubebuilder to quickly develop k8s operator, and now I save the yaml deployed by kustomize to a file in the following way. create: manifests kustomize ## Create chart cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} …
moluzhui
  • 1,003
  • 14
  • 34
2
votes
1 answer

How often is reconciliation loop run in Kubebuilder?

I am wondering if there is a way to check how often reconciliation loop is run when an operator is built using Kubebuilder? Thanks.
user3267989
  • 299
  • 3
  • 18
2
votes
3 answers

How to send Events with Kubebuilder-v3 / operator-sdk

The Kubebuilder V3 documentation explains that it talks about "How to batch multiple events into a single reconciliation call". However, I could not find any information about event management in this documentation. Could you please provide…
Fabrice Jammes
  • 2,275
  • 1
  • 26
  • 39
2
votes
2 answers

Kubebuilder predicates to skip certain namespaces

I'm using the kubebuilder framework in my controller and I want to completely ignore events from a list of given system namespaces. I think predicates must be the best option for this, hence I have the following…
Ishan Khare
  • 1,745
  • 4
  • 28
  • 59
2
votes
1 answer

Is there a tool to generate customer resouce object from a Custom resource definition?

I have a complex kubernetes customer resource definition. I want to generate a valid custom resource object from the definition and then replace some values with mine. This is for quick testing purposes. Instead of creating a yaml file from scratch,…
Yuhui Liu
  • 97
  • 1
  • 6