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
1
vote
3 answers

Kubebuilder project with a component config - could not decode file into runtime.Object

I tried to add a custom config for a Kubernetes operator with a kubebuilder ComponentConfig, but I received the bellow mentioned error: ERROR setup unable to load the config file {"error": "could not decode file into runtime.Object"} I set the…
Kubus
  • 677
  • 6
  • 18
1
vote
1 answer

Use url.URL with controller-gen

I'm trying to develop a custom resource on kubernetes with kubebuilder. In this CR, I have a field of type url.URL I get this error : (*in).DeepCopyInto undefined (type *url.URL has no field or method DeepCopyInto) Is there a way to work with type…
Quentin
  • 327
  • 3
  • 10
1
vote
2 answers

Generating Controller Gen with Kubebuilder

I am trying to build out my Custom Resource project in Kubebuilder but it seems like I am missing my controller gen whenever I build it out. I keep getting the error: /Users/*****/Kubernetes/postgres-writer-operator/bin/controller-gen…
Mabel Oza
  • 557
  • 8
  • 22
1
vote
1 answer

How to trigger a rollout restart on deployment resource from controller-runtime

I have been using kubebuilder for writing custom controller, and aware of Get(), Update(), Delete() methods that it provides. But Now I am looking for a method which mimic the behaviour of kubectl rollout restart deployment. If there is no such…
hrishi
  • 443
  • 2
  • 12
1
vote
1 answer

How to add RBAC roles to a Controller for a different kind of resource in Kubebuilder

I am creating a new Operator with Kubebuilder to deploy a Kubernetes controller to manage a new CRD Custom Resource Definition. This new CRD (let's say is called MyNewResource), needs to list/create/delete CronJobs. So in the Controller Go code…
TPPZ
  • 4,447
  • 10
  • 61
  • 106
1
vote
1 answer

How to print Status fields defined in Kubebuilder to show up when using Kubectl

How do I have to specify the comments like +kubebuilder:printcolumn to add columns to the output of the command kubectl get my-crd.my-group.my-domain.com? I've a CRD (Custom Resource Definition) with the usual structs for the specs and the status…
1
vote
0 answers

webhook missing file or directory [kubebuilder]

I'm trying to create webhook for my existing project, And after following every steps i'm getting an error 2021-12-06T12:37:06.624Z ERROR setup problem running manager {"error": "open …
alok verma
  • 97
  • 7
1
vote
0 answers

Kubernetes Operator to read watch namespace from config map

I have an operator built via kube builder that reads from a "WATCH_NAMESPACE" env to understand which namespace to watch. This is how the current setup works. namespaces := os.Getenv("WATCH_NAMESPACE") if strings.Contains(namespaces, ",") { …
CSUNNY
  • 414
  • 1
  • 7
  • 23
1
vote
1 answer

How to add SSL certificates using AWS console on a ALB spun up by alb-ingress-controller AWS?

I have a requirement where I need to maintain multiple public domains to point to our server, so I use alb-ingress-controller which spins up an ALB and also allows me to pass a 25 cert ARNS in certificateArns annotation, However if I add any new SSL…
1
vote
2 answers

how to reuse k8s validation in my own CRD controller

I created an CRD like this: import v1 "k8s.io/api/core/v1" type ApplicationSpec struct { Name string `json:"name"` PodSpec v1.PodSpec `json:"podSpec"` ... } notice that I reused PodSpec from core apigroup in my CRD To avoid user…
DiveInto
  • 2,158
  • 3
  • 27
  • 50
1
vote
0 answers

How can I specify an optional field in an external struct using Kubernetes controller-gen?

I am implementing a Kubernetes controller and am creating an API using a struct that looks like: import ( corev1 "k8s.io/api/core/v1" ) type MySpec struct { corev1.PodSpec `json:",inline"` } However, since the Containers field in PodSpec…
dippynark
  • 2,743
  • 20
  • 58
1
vote
1 answer

Updating Metadata Annotations

I am using kubebuilder to create a Kubernetes operator. When an object of my kind is initiated I have to parse the spec and update the objects based on a few calculations. From what I can tell I can either update the status of the object, the…
BBS
  • 1,351
  • 2
  • 12
  • 27
1
vote
1 answer

Why does client.Update(...) ignore non-primitive values?

I'm trying to modify the Spec of non-owned objects as part of the Reconcile of my Custom Resource, but it seems like it ignores any fields that are not primitives. I am using controller-runtime. I figured since it was only working on primitives,…
1
vote
1 answer

Rbac rules with Kubebuilder

My probelm is that i am trying to use the unstructured.Unstructured type to create a deployment as such: // +kubebuilder:rbac:groups=stable.resource.operator.io,resources=resource,verbs=get;list;watch;create;update;patch;delete //…
Spazzy757
  • 889
  • 4
  • 20
1
vote
1 answer

Unable to get K8S resources in kubebuilder's client.Client for unit test

I am writing some unit-tests for a sample Kubernetes CRD and controller created using Kubebuilder. The main code in the controller creates Kubernetes resources (a namespace and a ResourceQuota inside it). In my unit-tests, I want to verify that the…
Shri Javadekar
  • 307
  • 4
  • 15