Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Apr 12, 2024
2 parents 02dfb63 + d1fae0d commit 59d891d
Show file tree
Hide file tree
Showing 47 changed files with 4,309 additions and 982 deletions.
16 changes: 16 additions & 0 deletions .chloggen/2763 - add hostPort support.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add support for adding/extending otc-collector container ports."

# One or more tracking issues related to the change
issues: [2763]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
16 changes: 16 additions & 0 deletions .chloggen/bug_2823.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: collector

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Create automatically the RBAC permissions to manage replicasets when using the k8sattributesprocessor"

# One or more tracking issues related to the change
issues: [2823]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
16 changes: 16 additions & 0 deletions .chloggen/fix-keepequal-dropequal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: target allocator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix for keepequal/dropequal action

# One or more tracking issues related to the change
issues: [2793]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
16 changes: 16 additions & 0 deletions .chloggen/fix-truncated-description-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
component: documentation

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: The description for some fields was truncated in the documentation.

# One or more tracking issues related to the change
issues: [2563]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
16 changes: 16 additions & 0 deletions .chloggen/support-extensions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: auto-instrumentation

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Support Java auto-instrumentation extensions.

# One or more tracking issues related to the change
issues: [1785]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ release-artifacts: set-image-controller
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=$(MANIFEST_DIR)

# Run tests
# setup-envtest uses KUBEBUILDER_ASSETS which points to a directory with binaries (api-server, etcd and kubectl)
Expand Down Expand Up @@ -475,8 +475,11 @@ bundle-push:
api-docs: crdoc kustomize
@{ \
set -e ;\
TMP_MANIFEST_DIR=$$(mktemp -d) ; \
cp -r config/crd/* $$TMP_MANIFEST_DIR; \
$(MAKE) CRD_OPTIONS=$(CRD_OPTIONS),maxDescLen=1200 MANIFEST_DIR=$$TMP_MANIFEST_DIR/bases manifests ;\
TMP_DIR=$$(mktemp -d) ; \
$(KUSTOMIZE) build config/crd -o $$TMP_DIR/crd-output.yaml ;\
$(KUSTOMIZE) build $$TMP_MANIFEST_DIR -o $$TMP_DIR/crd-output.yaml ;\
$(CRDOC) --resources $$TMP_DIR/crd-output.yaml --output docs/api.md ;\
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
pipelines:
traces:
receivers: [otlp]
processors: []
processors: [memory_limiter, batch]
exporters: [debug]
EOF
```
Expand Down
76 changes: 47 additions & 29 deletions apis/v1alpha1/collector_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,19 @@ func TestOTELColValidatingWebhook(t *testing.T) {
thrift_http:
endpoint: 0.0.0.0:15268
`,
Ports: []v1.ServicePort{
Ports: []PortsSpec{
{
Name: "port1",
Port: 5555,
ServicePort: v1.ServicePort{
Name: "port1",
Port: 5555,
},
},
{
Name: "port2",
Port: 5554,
Protocol: v1.ProtocolUDP,
ServicePort: v1.ServicePort{
Name: "port2",
Port: 5554,
Protocol: v1.ProtocolUDP,
},
},
},
Autoscaler: &AutoscalerSpec{
Expand Down Expand Up @@ -533,15 +537,19 @@ func TestOTELColValidatingWebhook(t *testing.T) {
thrift_http:
endpoint: 0.0.0.0:15268
`,
Ports: []v1.ServicePort{
Ports: []PortsSpec{
{
Name: "port1",
Port: 5555,
ServicePort: v1.ServicePort{
Name: "port1",
Port: 5555,
},
},
{
Name: "port2",
Port: 5554,
Protocol: v1.ProtocolUDP,
ServicePort: v1.ServicePort{
Name: "port2",
Port: 5554,
Protocol: v1.ProtocolUDP,
},
},
},
Autoscaler: &AutoscalerSpec{
Expand Down Expand Up @@ -601,15 +609,19 @@ func TestOTELColValidatingWebhook(t *testing.T) {
thrift_http:
endpoint: 0.0.0.0:15268
`,
Ports: []v1.ServicePort{
Ports: []PortsSpec{
{
Name: "port1",
Port: 5555,
ServicePort: v1.ServicePort{
Name: "port1",
Port: 5555,
},
},
{
Name: "port2",
Port: 5554,
Protocol: v1.ProtocolUDP,
ServicePort: v1.ServicePort{
Name: "port2",
Port: 5554,
Protocol: v1.ProtocolUDP,
},
},
},
Autoscaler: &AutoscalerSpec{
Expand Down Expand Up @@ -687,12 +699,14 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid port name",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Ports: []v1.ServicePort{
Ports: []PortsSpec{
{
// this port name contains a non alphanumeric character, which is invalid.
Name: "-test🦄port",
Port: 12345,
Protocol: v1.ProtocolTCP,
ServicePort: v1.ServicePort{
// this port name contains a non alphanumeric character, which is invalid.
Name: "-test🦄port",
Port: 12345,
Protocol: v1.ProtocolTCP,
},
},
},
},
Expand All @@ -703,10 +717,12 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid port name, too long",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Ports: []v1.ServicePort{
Ports: []PortsSpec{
{
Name: "aaaabbbbccccdddd", // len: 16, too long
Port: 5555,
ServicePort: v1.ServicePort{
Name: "aaaabbbbccccdddd", // len: 16, too long
Port: 5555,
},
},
},
},
Expand All @@ -717,10 +733,12 @@ func TestOTELColValidatingWebhook(t *testing.T) {
name: "invalid port num",
otelcol: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{
Ports: []v1.ServicePort{
Ports: []PortsSpec{
{
Name: "aaaabbbbccccddd", // len: 15
// no port set means it's 0, which is invalid
ServicePort: v1.ServicePort{
Name: "aaaabbbbccccddd", // len: 15
// no port set means it's 0, which is invalid
},
},
},
},
Expand Down
45 changes: 43 additions & 2 deletions apis/v1alpha1/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"gopkg.in/yaml.v3"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/conversion"

Expand Down Expand Up @@ -96,7 +97,7 @@ func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
Image: copy.Spec.Image,
ImagePullPolicy: copy.Spec.ImagePullPolicy,
VolumeMounts: copy.Spec.VolumeMounts,
Ports: copy.Spec.Ports,
Ports: tov1beta1Ports(copy.Spec.Ports),
Env: copy.Spec.Env,
EnvFrom: copy.Spec.EnvFrom,
VolumeClaimTemplates: copy.Spec.VolumeClaimTemplates,
Expand Down Expand Up @@ -144,6 +145,26 @@ func tov1beta1(in OpenTelemetryCollector) (v1beta1.OpenTelemetryCollector, error
}, nil
}

func tov1beta1Ports(in []PortsSpec) []v1beta1.PortsSpec {
var ports []v1beta1.PortsSpec

for _, p := range in {
ports = append(ports, v1beta1.PortsSpec{
ServicePort: v1.ServicePort{
Name: p.Name,
Protocol: p.Protocol,
AppProtocol: p.AppProtocol,
Port: p.Port,
TargetPort: p.TargetPort,
NodePort: p.NodePort,
},
HostPort: p.HostPort,
})
}

return ports
}

func tov1beta1TA(in OpenTelemetryTargetAllocator) v1beta1.TargetAllocatorEmbedded {
return v1beta1.TargetAllocatorEmbedded{
Replicas: in.Replicas,
Expand Down Expand Up @@ -249,6 +270,26 @@ func tov1beta1ConfigMaps(in []ConfigMapsSpec) []v1beta1.ConfigMapsSpec {
return mapsSpecs
}

func tov1alpha1Ports(in []v1beta1.PortsSpec) []PortsSpec {
var ports []PortsSpec

for _, p := range in {
ports = append(ports, PortsSpec{
ServicePort: v1.ServicePort{
Name: p.Name,
Protocol: p.Protocol,
AppProtocol: p.AppProtocol,
Port: p.Port,
TargetPort: p.TargetPort,
NodePort: p.NodePort,
},
HostPort: p.HostPort,
})
}

return ports
}

func tov1alpha1(in v1beta1.OpenTelemetryCollector) (*OpenTelemetryCollector, error) {
copy := in.DeepCopy()
configYaml, err := copy.Spec.Config.Yaml()
Expand Down Expand Up @@ -287,7 +328,7 @@ func tov1alpha1(in v1beta1.OpenTelemetryCollector) (*OpenTelemetryCollector, err
ImagePullPolicy: copy.Spec.ImagePullPolicy,
Config: configYaml,
VolumeMounts: copy.Spec.VolumeMounts,
Ports: copy.Spec.Ports,
Ports: tov1alpha1Ports(copy.Spec.Ports),
Env: copy.Spec.Env,
EnvFrom: copy.Spec.EnvFrom,
VolumeClaimTemplates: copy.Spec.VolumeClaimTemplates,
Expand Down
7 changes: 4 additions & 3 deletions apis/v1alpha1/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ func Test_tov1beta1AndBack(t *testing.T) {
Name: "aaa",
},
},
Ports: []v1.ServicePort{
{
Ports: []PortsSpec{{
ServicePort: v1.ServicePort{
Name: "otlp",
},
},
HostPort: 0,
}},
Env: []v1.EnvVar{
{
Name: "foo",
Expand Down
13 changes: 13 additions & 0 deletions apis/v1alpha1/instrumentation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ type Java struct {
// Resources describes the compute resource requirements.
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Extensions defines java specific extensions.
// All extensions are copied to a single directory; if a JAR with the same name exists, it will be overwritten.
// +optional
Extensions []Extensions `json:"extensions,omitempty"`
}

type Extensions struct {
// Image is a container image with extensions auto-instrumentation JAR.
Image string `json:"image"`

// Dir is a directory with extensions auto-instrumentation JAR.
Dir string `json:"dir"`
}

// NodeJS defines NodeJS SDK and instrumentation configuration.
Expand Down
12 changes: 11 additions & 1 deletion apis/v1alpha1/opentelemetrycollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ type OpenTelemetryCollectorSpec struct {
// used to open additional ports that can't be inferred by the operator, like for custom receivers.
// +optional
// +listType=atomic
Ports []v1.ServicePort `json:"ports,omitempty"`
Ports []PortsSpec `json:"ports,omitempty"`
// ENV vars to set on the OpenTelemetry Collector's Pods. These can then in certain cases be
// consumed in the config file for the Collector.
// +optional
Expand Down Expand Up @@ -291,6 +291,16 @@ type OpenTelemetryCollectorSpec struct {
DeploymentUpdateStrategy appsv1.DeploymentStrategy `json:"deploymentUpdateStrategy,omitempty"`
}

// PortsSpec defines the OpenTelemetryCollector's container/service ports additional specifications.
type PortsSpec struct {
// Allows defining which port to bind to the host in the Container.
// +optional
HostPort int32 `json:"hostPort,omitempty"`

// Maintain previous fields in new struct
v1.ServicePort `json:",inline"`
}

// OpenTelemetryTargetAllocator defines the configurations for the Prometheus target allocator.
type OpenTelemetryTargetAllocator struct {
// Replicas is the number of pod instances for the underlying TargetAllocator. This should only be set to a value
Expand Down
Loading

0 comments on commit 59d891d

Please sign in to comment.