Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: Reconcile v1alpha2 crd #2637

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ BUNDLE_DEFAULT_CHANNEL := --default-channel=$(DEFAULT_CHANNEL)
endif
BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=200"
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=0"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -157,6 +157,7 @@ enable-operator-featuregates: add-operator-arg
.PHONY: deploy
deploy: set-image-controller
$(KUSTOMIZE) build config/default | kubectl apply -f -
$(KUSTOMIZE) build config/default > out.yaml
go run hack/check-operator-ready.go 300

# Undeploy controller in the current Kubernetes context, configured in ~/.kube/config
Expand Down
2 changes: 2 additions & 0 deletions apis/v1alpha1/collector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,5 @@ func SetupCollectorWebhook(mgr ctrl.Manager, cfg config.Config, reviewer *rbac.R
WithDefaulter(cvw).
Complete()
}

func (*OpenTelemetryCollector) Hub() {}
1 change: 1 addition & 0 deletions apis/v1alpha1/instrumentation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ type Nginx struct {
type InstrumentationStatus struct {
}

// +kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName=otelinst;otelinsts
// +kubebuilder:subresource:status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// TargetAllocatorAllocationStrategy represent a strategy Target Allocator uses to distribute targets to each collector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"context"
"fmt"
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/conversion"
v2 "sigs.k8s.io/controller-runtime/pkg/webhook/conversion/testdata/api/v2"
"strings"

"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -77,3 +80,29 @@ func (c CollectorWebhook) validate(r *OpenTelemetryCollector) (admission.Warning
}
return warnings, nil
}

var _ conversion.Convertible = &OpenTelemetryCollector{}

func (c *OpenTelemetryCollector) ConvertTo(dst conversion.Hub) error {
fmt.Println("ConvertTo")
switch t := dst.(type) {
case *v2.ExternalJob:
colv1 := dst.(*v1alpha1.OpenTelemetryCollector)
c.ObjectMeta = colv1.ObjectMeta
return nil
default:
return fmt.Errorf("unsupported type %v", t)
}
}

func (c *OpenTelemetryCollector) ConvertFrom(src conversion.Hub) error {
fmt.Println("ConvertFrom")
switch t := src.(type) {
case *v1alpha1.OpenTelemetryCollector:
colv1 := src.(*v1alpha1.OpenTelemetryCollector)
c.ObjectMeta = colv1.ObjectMeta
return nil
default:
return fmt.Errorf("unsupported type %v", t)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/common.go → apis/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
autoscalingv2 "k8s.io/api/autoscaling/v2"
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/config.go → apis/v1beta1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// Package v1alpha2 contains API Schema definitions for the v1alpha2 API group
// +kubebuilder:object:generate=true
// +groupName=opentelemetry.io
package v1alpha2
package v1beta1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -24,7 +24,7 @@ import (

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1alpha2"}
GroupVersion = schema.GroupVersion{Group: "opentelemetry.io", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// IngressType represents how a collector should be exposed (ingress vs route).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +kubebuilder:skip

package v1alpha2
package v1beta1

import (
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/mode.go → apis/v1beta1/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// Mode represents how the collector should be deployed (deployment vs. daemonset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +kubebuilder:skip

package v1alpha2
package v1beta1

import (
appsv1 "k8s.io/api/apps/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +kubebuilder:skip

package v1alpha2
package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package v1alpha2
package v1beta1

type (
// UpgradeStrategy represents how the operator will handle upgrades to the CR when a newer version of the operator is deployed
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ metadata:
categories: Logging & Tracing,Monitoring
certified: "false"
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
createdAt: "2024-02-02T16:02:46Z"
createdAt: "2024-02-16T13:45:29Z"
description: Provides the OpenTelemetry components, including the Collector
operators.operatorframework.io/builder: operator-sdk-v1.29.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: github.com/open-telemetry/opentelemetry-operator
support: OpenTelemetry Community
name: opentelemetry-operator.v0.93.0
name: opentelemetry-operator.v0.93.0-15-gb2ddcde
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand All @@ -86,6 +86,9 @@ spec:
name: ""
version: v1
version: v1alpha1
- kind: Instrumentation
name: instrumentations.opentelemetry.io
version: v1beta1
- description: OpAMPBridge is the Schema for the opampbridges API.
displayName: OpAMP Bridge
kind: OpAMPBridge
Expand Down Expand Up @@ -154,6 +157,9 @@ spec:
displayName: Create ServiceMonitors for OpenTelemetry Collector
path: targetAllocator.observability.metrics.enableMetrics
version: v1alpha1
- kind: OpenTelemetryCollector
name: opentelemetrycollectors.opentelemetry.io
version: v1beta1
description: |-
OpenTelemetry is a collection of tools, APIs, and SDKs. You use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior.

Expand Down Expand Up @@ -402,7 +408,7 @@ spec:
- --zap-log-level=info
- --zap-time-encoding=rfc3339nano
- --feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx
image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.93.0
image: docker.io/pavolloffay/opentelemetry-operator:dev-b2ddcde-1708091123
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -485,9 +491,9 @@ spec:
serviceAccountName: opentelemetry-operator-controller-manager
strategy: deployment
installModes:
- supported: true
- supported: false
type: OwnNamespace
- supported: true
- supported: false
type: SingleNamespace
- supported: false
type: MultiNamespace
Expand All @@ -510,8 +516,20 @@ spec:
minKubeVersion: 1.23.0
provider:
name: OpenTelemetry Community
version: 0.93.0
version: 0.93.0-15-gb2ddcde
webhookdefinitions:
- admissionReviewVersions:
- v1alpha1
- v1beta1
containerPort: 443
conversionCRDs:
- opentelemetrycollectors.opentelemetry.io
deploymentName: opentelemetry-operator-controller-manager
generateName: copentelemetrycollectors.kb.io
sideEffects: None
targetPort: 9443
type: ConversionWebhook
webhookPath: /convert
- admissionReviewVersions:
- v1
containerPort: 443
Expand Down
Loading
Loading