Skip to content

Commit

Permalink
Merge branch 'main' into feature/2995
Browse files Browse the repository at this point in the history
  • Loading branch information
iblancasa committed Jul 2, 2024
2 parents 5182395 + ea97b6a commit 8324e72
Show file tree
Hide file tree
Showing 36 changed files with 704 additions and 118 deletions.
16 changes: 16 additions & 0 deletions .chloggen/implement-dnsconfig.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: collector, target allocator, opamp

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Enabling PodDnsConfig for OpenTelemetry Collector, TargetAllocator and OpAMPBridge.

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

# (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/make-otelcol-mode-immutable.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: collector

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Make the `spec.mode` field of the `OpenTelemetryCollector` Custom Resource (CR) immutable"

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

# (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:
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
path: bin
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}-${{ steps.setup-go.outputs.go-version }}
- name: Install chainsaw
uses: kyverno/[email protected].4
uses: kyverno/[email protected].5
- name: Install tools
run: make install-tools
- name: Prepare e2e tests
Expand Down
55 changes: 29 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,39 +728,42 @@ By default, the OpenTelemetry Operator ensures consistent versioning between its

When a custom `Spec.Image` is used with an `OpenTelemetryCollector` resource, the OpenTelemetry Operator will not manage this versioning and upgrading. In this scenario, it is best practice that the OpenTelemetry Operator version should match the underlying core version. Given a `OpenTelemetryCollector` resource with a `Spec.Image` configured to a custom image based on underlying OpenTelemetry Collector at version `0.40.0`, it is recommended that the OpenTelemetry Operator is kept at version `0.40.0`.

### OpenTelemetry Operator vs. Kubernetes vs. Cert Manager
### OpenTelemetry Operator vs. Kubernetes vs. Cert Manager vs Prometheus Operator

We strive to be compatible with the widest range of Kubernetes versions as possible, but some changes to Kubernetes itself require us to break compatibility with older Kubernetes versions, be it because of code incompatibilities, or in the name of maintainability. Every released operator will support a specific range of Kubernetes versions, to be determined at the latest during the release.

We use `cert-manager` for some features of this operator and the third column shows the versions of the `cert-manager` that are known to work with this operator's versions.

The Target Allocator supports prometheus-operator CRDs like ServiceMonitor, and it does so by using packages imported from prometheus-operator itself. The table shows which version is shipped with a given operator version.
Generally speaking, these are backwards compatible, but specific features require the appropriate package versions.

The OpenTelemetry Operator _might_ work on versions outside of the given range, but when opening new issues, please make sure to test your scenario on a supported version.

| OpenTelemetry Operator | Kubernetes | Cert-Manager |
|------------------------|----------------| ------------ |
| v0.103.0 | v1.23 to v1.30 | v1 |
| v0.102.0 | v1.23 to v1.30 | v1 |
| v0.101.0 | v1.23 to v1.30 | v1 |
| v0.100.0 | v1.23 to v1.29 | v1 |
| v0.99.0 | v1.23 to v1.29 | v1 |
| v0.98.0 | v1.23 to v1.29 | v1 |
| v0.97.0 | v1.23 to v1.29 | v1 |
| v0.96.0 | v1.23 to v1.29 | v1 |
| v0.95.0 | v1.23 to v1.29 | v1 |
| v0.94.0 | v1.23 to v1.29 | v1 |
| v0.93.0 | v1.23 to v1.29 | v1 |
| v0.92.0 | v1.23 to v1.29 | v1 |
| v0.91.0 | v1.23 to v1.29 | v1 |
| v0.90.0 | v1.23 to v1.28 | v1 |
| v0.89.0 | v1.23 to v1.28 | v1 |
| v0.88.0 | v1.23 to v1.28 | v1 |
| v0.87.0 | v1.23 to v1.28 | v1 |
| v0.86.0 | v1.23 to v1.28 | v1 |
| v0.85.0 | v1.19 to v1.28 | v1 |
| v0.84.0 | v1.19 to v1.28 | v1 |
| v0.83.0 | v1.19 to v1.27 | v1 |
| v0.82.0 | v1.19 to v1.27 | v1 |
| v0.81.0 | v1.19 to v1.27 | v1 |
| OpenTelemetry Operator | Kubernetes | Cert-Manager | Prometheus-Operator |
|------------------------|----------------| ------------ |---------------------|
| v0.103.0 | v1.23 to v1.30 | v1 | v0.74.0 |
| v0.102.0 | v1.23 to v1.30 | v1 | v0.71.2 |
| v0.101.0 | v1.23 to v1.30 | v1 | v0.71.2 |
| v0.100.0 | v1.23 to v1.29 | v1 | v0.71.2 |
| v0.99.0 | v1.23 to v1.29 | v1 | v0.71.2 |
| v0.98.0 | v1.23 to v1.29 | v1 | v0.71.2 |
| v0.97.0 | v1.23 to v1.29 | v1 | v0.71.2 |
| v0.96.0 | v1.23 to v1.29 | v1 | v0.71.2 |
| v0.95.0 | v1.23 to v1.29 | v1 | v0.71.2 |
| v0.94.0 | v1.23 to v1.29 | v1 | v0.71.0 |
| v0.93.0 | v1.23 to v1.29 | v1 | v0.71.0 |
| v0.92.0 | v1.23 to v1.29 | v1 | v0.71.0 |
| v0.91.0 | v1.23 to v1.29 | v1 | v0.70.0 |
| v0.90.0 | v1.23 to v1.28 | v1 | v0.69.1 |
| v0.89.0 | v1.23 to v1.28 | v1 | v0.69.1 |
| v0.88.0 | v1.23 to v1.28 | v1 | v0.68.0 |
| v0.87.0 | v1.23 to v1.28 | v1 | v0.68.0 |
| v0.86.0 | v1.23 to v1.28 | v1 | v0.68.0 |
| v0.85.0 | v1.19 to v1.28 | v1 | v0.67.1 |
| v0.84.0 | v1.19 to v1.28 | v1 | v0.67.1 |
| v0.83.0 | v1.19 to v1.27 | v1 | v0.67.1 |
| v0.82.0 | v1.19 to v1.27 | v1 | v0.67.1 |
| v0.81.0 | v1.19 to v1.27 | v1 | v0.66.0 |

## Contributing and Developing

Expand Down
2 changes: 2 additions & 0 deletions apis/v1alpha1/opampbridge_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ type OpAMPBridgeSpec struct {
// https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
// +optional
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
}

// OpAMPBridgeStatus defines the observed state of OpAMPBridge.
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions apis/v1beta1/collector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ func (c CollectorWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj run
return nil, fmt.Errorf("expected an OpenTelemetryCollector, received %T", oldObj)
}

if otelcolOld.Spec.Mode != otelcol.Spec.Mode {
return admission.Warnings{}, fmt.Errorf("the OpenTelemetry Collector mode is set to %s, which does not support modification", otelcolOld.Spec.Mode)
}
warnings, err := c.validate(ctx, otelcol)
if err != nil {
return warnings, err
Expand Down
45 changes: 45 additions & 0 deletions apis/v1beta1/collector_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,51 @@ func TestOTELColValidatingWebhook(t *testing.T) {
}
}

func TestOTELColValidateUpdateWebhook(t *testing.T) {
tests := []struct { //nolint:govet
name string
otelcolOld OpenTelemetryCollector
otelcolNew OpenTelemetryCollector
expectedErr string
expectedWarnings []string
shouldFailSar bool
}{
{
name: "mode should not be changed",
otelcolOld: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{Mode: ModeStatefulSet},
},
otelcolNew: OpenTelemetryCollector{
Spec: OpenTelemetryCollectorSpec{Mode: ModeDeployment},
},
expectedErr: "which does not support modification",
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
cvw := &CollectorWebhook{
logger: logr.Discard(),
scheme: testScheme,
cfg: config.New(
config.WithCollectorImage("collector:v0.0.0"),
config.WithTargetAllocatorImage("ta:v0.0.0"),
),
reviewer: getReviewer(test.shouldFailSar),
}
ctx := context.Background()
warnings, err := cvw.ValidateUpdate(ctx, &test.otelcolOld, &test.otelcolNew)
if test.expectedErr == "" {
assert.NoError(t, err)
} else {
assert.ErrorContains(t, err, test.expectedErr)
}
assert.Equal(t, len(test.expectedWarnings), len(warnings))
assert.ElementsMatch(t, warnings, test.expectedWarnings)
})
}
}

func getReviewer(shouldFailSAR bool) *rbac.Reviewer {
c := fake.NewSimpleClientset()
c.PrependReactor("create", "subjectaccessreviews", func(action kubeTesting.Action) (handled bool, ret runtime.Object, err error) {
Expand Down
2 changes: 2 additions & 0 deletions apis/v1beta1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ type OpenTelemetryCommonFields struct {
//
// +optional
AdditionalContainers []v1.Container `json:"additionalContainers,omitempty"`
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
}

type StatefulSetCommonFields struct {
Expand Down
1 change: 1 addition & 0 deletions apis/v1beta1/zz_generated.deepcopy.go

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

23 changes: 23 additions & 0 deletions bundle/manifests/opentelemetry.io_opampbridges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,29 @@ spec:
additionalProperties:
type: string
type: object
podDnsConfig:
properties:
nameservers:
items:
type: string
type: array
x-kubernetes-list-type: atomic
options:
items:
properties:
name:
type: string
value:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
searches:
items:
type: string
type: array
x-kubernetes-list-type: atomic
type: object
podSecurityContext:
properties:
appArmorProfile:
Expand Down
23 changes: 23 additions & 0 deletions bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6928,6 +6928,29 @@ spec:
- type: string
x-kubernetes-int-or-string: true
type: object
podDnsConfig:
properties:
nameservers:
items:
type: string
type: array
x-kubernetes-list-type: atomic
options:
items:
properties:
name:
type: string
value:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
searches:
items:
type: string
type: array
x-kubernetes-list-type: atomic
type: object
podSecurityContext:
properties:
appArmorProfile:
Expand Down
8 changes: 3 additions & 5 deletions cmd/otel-allocator/collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,11 @@ func Test_runWatch(t *testing.T) {

assert.EventuallyWithT(t, func(collect *assert.CollectT) {
mapMutex.Lock()
defer mapMutex.Unlock()
assert.Len(collect, actual, len(tt.want))
assert.Equal(collect, actual, tt.want)
defer mapMutex.Unlock()
}, time.Second, time.Millisecond)

// check if the metrics were emitted correctly
assert.Equal(t, testutil.ToFloat64(collectorsDiscovered), float64(len(actual)))
assert.Equal(collect, testutil.ToFloat64(collectorsDiscovered), float64(len(actual)))
}, time.Second*3, time.Millisecond)
})
}
}
Expand Down
1 change: 0 additions & 1 deletion cmd/otel-allocator/watcher/promOperator.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ func (w *PrometheusCRWatcher) LoadConfig(ctx context.Context) (*promconfig.Confi
}

generatedConfig, err := w.configGenerator.GenerateServerConfiguration(
ctx,
"30s",
"",
nil,
Expand Down
23 changes: 23 additions & 0 deletions config/crd/bases/opentelemetry.io_opampbridges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,29 @@ spec:
additionalProperties:
type: string
type: object
podDnsConfig:
properties:
nameservers:
items:
type: string
type: array
x-kubernetes-list-type: atomic
options:
items:
properties:
name:
type: string
value:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
searches:
items:
type: string
type: array
x-kubernetes-list-type: atomic
type: object
podSecurityContext:
properties:
appArmorProfile:
Expand Down
23 changes: 23 additions & 0 deletions config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6914,6 +6914,29 @@ spec:
- type: string
x-kubernetes-int-or-string: true
type: object
podDnsConfig:
properties:
nameservers:
items:
type: string
type: array
x-kubernetes-list-type: atomic
options:
items:
properties:
name:
type: string
value:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
searches:
items:
type: string
type: array
x-kubernetes-list-type: atomic
type: object
podSecurityContext:
properties:
appArmorProfile:
Expand Down
23 changes: 23 additions & 0 deletions config/crd/bases/opentelemetry.io_targetallocators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,29 @@ spec:
- type: string
x-kubernetes-int-or-string: true
type: object
podDnsConfig:
properties:
nameservers:
items:
type: string
type: array
x-kubernetes-list-type: atomic
options:
items:
properties:
name:
type: string
value:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
searches:
items:
type: string
type: array
x-kubernetes-list-type: atomic
type: object
podSecurityContext:
properties:
appArmorProfile:
Expand Down
Loading

0 comments on commit 8324e72

Please sign in to comment.