Skip to content

Commit

Permalink
Use a subchart to install CRDs via helm (#1604)
Browse files Browse the repository at this point in the history
* Move operator CRD installation to the crds/ folder via a subchart to resolve Helm install ordering issues

* Update changelog

* remove setting CRDs in test, use subchart

* disable installing CRDs by default

---------

Co-authored-by: jvoravong <[email protected]>
  • Loading branch information
atoulme and jvoravong authored Jan 10, 2025
1 parent b12eb4f commit ce19b52
Show file tree
Hide file tree
Showing 14 changed files with 12,939 additions and 12,167 deletions.
12 changes: 12 additions & 0 deletions .chloggen/move-operator-crd-install-method.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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. agent, clusterReceiver, gateway, operator, chart, other)
component: operator
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Move operator CRD installation to the crds/ folder via a subchart to resolve Helm install ordering issues
# One or more tracking issues related to the change
issues: [1561]
# (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:

Large diffs are not rendered by default.

58 changes: 0 additions & 58 deletions functional_tests/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,41 +172,6 @@ func deployChartsAndApps(t *testing.T) {
}
}

// deploy the operator CRDs
stream, err = os.ReadFile(filepath.Join(testDir, manifestsDir, "operator_crds.yaml"))
require.NoError(t, err)

for _, resourceYAML := range strings.Split(string(stream), "---") {
if len(resourceYAML) == 0 {
continue
}

obj, groupVersionKind, err := decode(
[]byte(resourceYAML),
nil,
nil)
require.NoError(t, err)
if groupVersionKind.Group == "apiextensions.k8s.io" &&
groupVersionKind.Version == "v1" &&
groupVersionKind.Kind == "CustomResourceDefinition" {
crd := obj.(*appextensionsv1.CustomResourceDefinition)
apiExtensions := extensionsClient.ApiextensionsV1().CustomResourceDefinitions()
crd, err := apiExtensions.Create(context.Background(), crd, metav1.CreateOptions{})
require.NoError(t, err)
t.Logf("Deployed CRD %s", crd.Name)
for _, version := range crd.Spec.Versions {
sch.AddKnownTypeWithName(
schema.GroupVersionKind{
Group: crd.Spec.Group,
Version: version.Name,
Kind: crd.Spec.Names.Kind,
},
&unstructured.Unstructured{},
)
}
}
}

codecs := serializer.NewCodecFactory(sch)
crdDecode := codecs.UniversalDeserializer().Decode
// Prometheus pod monitor
Expand Down Expand Up @@ -536,29 +501,6 @@ func teardown(t *testing.T) {
}
}

crdstream, err = os.ReadFile(filepath.Join(testDir, manifestsDir, "operator_crds.yaml"))
require.NoError(t, err)
for _, resourceYAML := range strings.Split(string(crdstream), "---") {
if len(resourceYAML) == 0 {
continue
}

obj, groupVersionKind, err := decode(
[]byte(resourceYAML),
nil,
nil)
require.NoError(t, err)
if groupVersionKind.Group == "apiextensions.k8s.io" &&
groupVersionKind.Version == "v1" &&
groupVersionKind.Kind == "CustomResourceDefinition" {
crd := obj.(*appextensionsv1.CustomResourceDefinition)
apiExtensions := extensionsClient.ApiextensionsV1().CustomResourceDefinitions()
_ = apiExtensions.Delete(context.Background(), crd.Name, metav1.DeleteOptions{
GracePeriodSeconds: &waitTime,
})
}
}

for _, nm := range namespaces {
nmClient := client.CoreV1().Namespaces()
_ = nmClient.Delete(context.Background(), nm.Name, metav1.DeleteOptions{
Expand Down
5 changes: 2 additions & 3 deletions functional_tests/testdata/values/aks_test_values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ readinessProbe:
initialDelaySeconds: 60
livenessProbe:
initialDelaySeconds: 60

operatorcrds:
install: true
operator:
enabled: true
crds:
create: false
admissionWebhooks:
certManager:
enabled: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,10 @@ clusterName: test
environment: test
cloudProvider: gcp
distribution: gke/autopilot

operatorcrds:
install: true
operator:
enabled: true
crds:
create: false
admissionWebhooks:
certManager:
enabled: false
Expand Down
4 changes: 2 additions & 2 deletions functional_tests/testdata/values/test_values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ extraAttributes:
value: "customvalue2"

environment: dev
operatorcrds:
install: true
operator:
enabled: true
crds:
create: false
targetAllocator:
enabled: true

Expand Down
8 changes: 6 additions & 2 deletions helm-charts/splunk-otel-collector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ maintainers:
- name: atoulme
dependencies:
# Subchart Notes:
# - Avoid uppercase letters in names/aliases, they cause install failure due to subchart resource naming
# - Avoid hyphen characters in names/aliases, they introduce template rendering complications (https://github.com/helm/helm/issues/2192)
# - Avoid uppercase letters in aliases, they cause install failure due to subchart resource naming
# - Avoid hyphen characters in aliases, they introduce template rendering complications (https://github.com/helm/helm/issues/2192)
- name: cert-manager
version: v1.14.4
alias: certmanager
repository: https://charts.jetstack.io
condition: certmanager.enabled
- name: opentelemetry-operator-crds
version: "0.0.1"
alias: operatorcrds
condition: operatorcrds.install
- name: opentelemetry-operator
version: 0.71.2
alias: operator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: v2
name: opentelemetry-operator-crds
version: 0.0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# OpenTelemetry Collector CRDs

This chart contains the CRDs for _*installation*_ only right now for the opentelemetry-operator. This allows the Splunk OpenTelemetry Collector chart to work on install. You can see more discussion about this [here](https://github.com/open-telemetry/opentelemetry-helm-charts/issues/677) and [here](https://github.com/open-telemetry/opentelemetry-helm-charts/pull/1203).

This approach is inspired by the [opentelemetry-kube-stack chart](https://github.com/open-telemetry/opentelemetry-helm-charts/tree/main/charts/opentelemetry-kube-stack) approach.

> [!NOTE]
> The splunk-otel-collector chart only supports and tests functionality related to the auto-instrumentation that requires the Instrumentation CRD.
> Other CRDs, such as OpenTelemetryCollector and OpAMPBridge, are included solely to allow the Operator to start up and are not currently supported or tested.
# Upgrade Notes

Right now, upgrades are NOT handled by this chart, however that could change in the future. This is what is run to bring in the CRDs today.

```bash
wget https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/main/config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml
wget https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/main/config/crd/bases/opentelemetry.io_opampbridges.yaml
wget https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/main/config/crd/bases/opentelemetry.io_instrumentations.yaml
```
Loading

0 comments on commit ce19b52

Please sign in to comment.