Skip to content

Commit

Permalink
Migrate to kubebuilder v4 layout (#1092)
Browse files Browse the repository at this point in the history
* Migrate to kubebuilder v4 layout

Signed-off-by: Ruben Vargas <[email protected]>

* remove deprecated config component

Signed-off-by: Ruben Vargas <[email protected]>

* modifications to config

Signed-off-by: Ruben Vargas <[email protected]>

* reintroduce config validation

Signed-off-by: Ruben Vargas <[email protected]>

* bump sdk to 1.36

Signed-off-by: Ruben Vargas <[email protected]>

* update documents

Signed-off-by: Ruben Vargas <[email protected]>

* address observations, merge files, add tests

Signed-off-by: Ruben Vargas <[email protected]>

* fix lint

Signed-off-by: Ruben Vargas <[email protected]>

* remove pprof endpoints

Signed-off-by: Ruben Vargas <[email protected]>

* add namepace permissions

Signed-off-by: Ruben Vargas <[email protected]>

---------

Signed-off-by: Ruben Vargas <[email protected]>
  • Loading branch information
rubenvp8510 authored Dec 18, 2024
1 parent a29a921 commit c2c2f7b
Show file tree
Hide file tree
Showing 168 changed files with 1,354 additions and 1,246 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ test: manifests generate fmt setup-envtest ## Run tests.

.PHONY: build
build: generate fmt ## Build manager binary.
CGO_ENABLED=0 go build -o bin/manager -ldflags ${LD_FLAGS} main.go
CGO_ENABLED=0 go build -o bin/manager -ldflags ${LD_FLAGS} cmd/main.go

.PHONY: must-gather
must-gather:
Expand All @@ -164,7 +164,7 @@ run: manifests generate ## Run a controller from your host.
RELATED_IMAGE_TEMPO_GATEWAY=$(TEMPO_GATEWAY_IMAGE) \
RELATED_IMAGE_TEMPO_GATEWAY_OPA=$(TEMPO_GATEWAY_OPA_IMAGE) \
RELATED_IMAGE_OAUTH_PROXY=$(OAUTH_PROXY_IMAGE) \
go run -ldflags ${LD_FLAGS} ./main.go --zap-log-level=info start
go run -ldflags ${LD_FLAGS} ./cmd/main.go --zap-log-level=info start

.PHONY: container-must-gather
container-must-gather:
Expand Down Expand Up @@ -223,10 +223,10 @@ $(LOCALBIN):

## Tool Versions
KUSTOMIZE_VERSION ?= v5.0.3
CONTROLLER_GEN_VERSION ?= v0.15.0
CONTROLLER_GEN_VERSION ?= v0.16.5
GEN_API_DOCS_VERSION ?= v0.6.0
ENVTEST_VERSION ?= latest
OPERATOR_SDK_VERSION ?= 1.32.0
OPERATOR_SDK_VERSION ?= 1.36.0
OLM_VERSION ?= v0.28.0
CERTMANAGER_VERSION ?= 1.9.1
CHAINSAW_VERSION ?= v0.2.4
Expand Down Expand Up @@ -488,7 +488,7 @@ docs/spec/%: bundle/community/manifests/% | gen-api-docs
$(GEN_API_DOCS) < $^ > $@

docs/operator/config.yaml: gen-api-docs
$(GEN_API_DOCS) -pkg github.com/grafana/tempo-operator/apis/config/v1alpha1 -type ProjectConfig -format multiline > $@
$(GEN_API_DOCS) -pkg github.com/grafana/tempo-operator/api/config/v1alpha1 -type ProjectConfig -format multiline > $@

##@ Release
CHLOGGEN_VERSION=v0.11.0
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
domain: grafana.com
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
multigroup: true
plugins:
manifests.sdk.operatorframework.io/v2: {}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
cfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
)

const (
Expand Down Expand Up @@ -223,14 +223,76 @@ type FeatureGates struct {
GrafanaOperator bool `json:"grafanaOperator,omitempty"`
}

// ControllerManagerConfigurationSpec defines the desired state of GenericControllerManagerConfiguration.
type ControllerManagerConfigurationSpec struct {
// LeaderElection is the LeaderElection config to be used when configuring
// the manager.Manager leader election
// +optional
LeaderElection *configv1alpha1.LeaderElectionConfiguration `json:"leaderElection,omitempty"`

// Metrics contains the controller metrics configuration
// +optional
Metrics ControllerMetrics `json:"metrics,omitempty"`

// Health contains the controller health configuration
// +optional
Health ControllerHealth `json:"health,omitempty"`

// Webhook contains the controllers webhook configuration
// +optional
Webhook ControllerWebhook `json:"webhook,omitempty"`
}

// ControllerMetrics defines the metrics configs.
type ControllerMetrics struct {
// BindAddress is the TCP address that the controller should bind to
// for serving prometheus metrics.
// It can be set to "0" to disable the metrics serving.
// +optional
BindAddress string `json:"bindAddress,omitempty"`
}

// ControllerHealth defines the health configs.
type ControllerHealth struct {
// HealthProbeBindAddress is the TCP address that the controller should bind to
// for serving health probes
// It can be set to "0" or "" to disable serving the health probe.
// +optional
HealthProbeBindAddress string `json:"healthProbeBindAddress,omitempty"`
}

// ControllerWebhook defines the webhook server for the controller.
type ControllerWebhook struct {
// Port is the port that the webhook server serves at.
// It is used to set webhook.Server.Port.
// +optional
Port *int `json:"port,omitempty"`
}

//+kubebuilder:object:root=true

// ControllerManagerConfiguration is the Schema for the GenericControllerManagerConfigurations API.
type ControllerManagerConfiguration struct {
metav1.TypeMeta `json:",inline"`

// ControllerManagerConfiguration returns the configurations for controllers
ControllerManagerConfigurationSpec `json:",inline"`
}

// Complete returns the configuration for controller-runtime.
func (c *ControllerManagerConfigurationSpec) Complete() (ControllerManagerConfigurationSpec, error) {
return *c, nil
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// ProjectConfig is the Schema for the projectconfigs API.
type ProjectConfig struct {
metav1.TypeMeta `json:",inline"`

// ControllerManagerConfigurationSpec returns the configurations for controllers
cfg.ControllerManagerConfigurationSpec `json:",inline"`
ControllerManagerConfigurationSpec `json:",inline"`

// The images are read from environment variables and not from the configuration file
DefaultImages ImagesSpec
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"

configv1alpha1 "github.com/grafana/tempo-operator/apis/config/v1alpha1"
configv1alpha1 "github.com/grafana/tempo-operator/api/config/v1alpha1"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

configv1alpha1 "github.com/grafana/tempo-operator/apis/config/v1alpha1"
configv1alpha1 "github.com/grafana/tempo-operator/api/config/v1alpha1"
)

var (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/grafana/tempo-operator/apis/config/v1alpha1"
"github.com/grafana/tempo-operator/api/config/v1alpha1"
)

// ManagementStateType defines the type for CR management states.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions bundle/community/bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=tempo-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.32.0
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.36.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
Expand Down
Loading

0 comments on commit c2c2f7b

Please sign in to comment.