Skip to content

Commit

Permalink
Merge branch 'master' into remove-name-and-version-from-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
turytsia authored Nov 14, 2024
2 parents 08f5ddf + 63043e9 commit 9d39338
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/buildAndDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
- name: Add dependency chart repos
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo add jetstack https://charts.jetstack.io
- name: Generate docker image tag
id: generate-tag
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/buildAndTestHelm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
- name: Add dependency chart repos
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo add jetstack https://charts.jetstack.io
- name: Download chart dependencies before linting
run: helm dependency build deploy/helm
Expand Down Expand Up @@ -81,6 +83,8 @@ jobs:
- name: Add dependency chart repos
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo add jetstack https://charts.jetstack.io
- name: Build
run: skaffold build -p=ci-helm-e2e --file-output=/tmp/tags.json
Expand Down Expand Up @@ -122,6 +126,8 @@ jobs:
- name: Add dependency chart repos
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo add jetstack https://charts.jetstack.io
helm repo add solarwinds https://helm.solarwinds.com
helm repo update
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/releaseHelm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
- name: Add dependency chart repos
run: |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo add jetstack https://charts.jetstack.io
- name: Set env
run: |
Expand Down
5 changes: 5 additions & 0 deletions deploy/helm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [4.3.0-alpha.1] - 2024-11-11

### Added
- Adding OTEL Operator as subchart

### Added

- It is now possible to customize prefix of discovered metrics using `otel.metrics.autodiscovery.prefix` (default `k8s.`)
Expand Down
10 changes: 8 additions & 2 deletions deploy/helm/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ dependencies:
- name: kube-state-metrics
repository: https://prometheus-community.github.io/helm-charts
version: 5.26.0
digest: sha256:ef4659b2db8346b66d53018055f914b77e7ab9fc835b5faf7a5c4ac422bd347c
generated: "2024-11-04T15:56:48.3890719+01:00"
- name: opentelemetry-operator
repository: https://open-telemetry.github.io/opentelemetry-helm-charts
version: 0.68.3
- name: cert-manager
repository: https://charts.jetstack.io
version: v1.16.1
digest: sha256:531536930d6703d7eac1fef0edc60b586790199100d10af78f82a58ba839694b
generated: "2024-11-11T10:34:43.72979+01:00"
12 changes: 11 additions & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: swo-k8s-collector
version: 4.2.1
version: 4.3.0-alpha.2
appVersion: 0.11.8
description: SolarWinds Kubernetes Integration
keywords:
Expand All @@ -22,6 +22,16 @@ dependencies:
repository: https://prometheus-community.github.io/helm-charts
version: "~> 5.26.0"
condition: kube-state-metrics.enabled
- name: opentelemetry-operator
repository: https://open-telemetry.github.io/opentelemetry-helm-charts
version: 0.68.3 # 0.68.3 chart version includes otel-operator version 0.107.0
alias: operator
condition: operator.enabled
- name: cert-manager
version: v1.16.1
alias: certmanager
repository: https://charts.jetstack.io
condition: certmanager.enabled
annotations:
artifacthub.io/prerelease: "false"
artifacthub.io/license: Apache-2.0
Expand Down
85 changes: 85 additions & 0 deletions deploy/helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Installation](#installation)
- [Configuration](#configuration)
- [Limitations](#limitations)
- [Auto instrumentation](#autoinstrumentation)

## Installation

Expand Down Expand Up @@ -93,6 +94,28 @@ otel:
IsMatch(body, "\\[[^\\]]*\\] \"\\S+ \\S+ HTTP/\\d(\\.\\d)*\" 200.*")
```

### Manifests

Starting with version 4.0.0, `swo-k8s-collector` observes changes in supported resources and collects their manifests.

By default, manifest collection is enabled, but it can be disabled by setting `otel.manifests.enabled` to `false`. Manifest collection runs in the event collector, so `otel.events.enabled` must be set to `true` (default).

Currently, the following resources are watched for changes: `pods`, `deployments`, `statefulsets`, `replicasets`, `daemonsets`, `jobs`, `cronjobs`, `nodes`, `services`, `persistentvolumes`, `persistentvolumeclaims`, `configmaps`, `ingresses` and Istio's `virtualservices`.

By default, `swo-k8s-collector` collects all manifests. You can use the `otel.manifests.filter` setting to filter out manifests that should not be collected.

An example of filter for collecting all manifests, but `configmaps` just for `kube-system` namespace.

```yaml
otel:
manifests:
enabled: true
filter:
log_record:
- attributes["k8s.object.kind"] == "ConfigMap" and resource.attributes["k8s.namespace.name"] != "kube-system"
```


## Receive 3rd party metrics

SWO K8s Collector has an OTEL service endpoint which is able to forward metrics and logs into SolarWinds Observability. All incoming data is properly associated with current cluster. Additionally, metrics are decorated with prefix `k8s.`.
Expand Down Expand Up @@ -133,3 +156,65 @@ config:
- Local Kubernetes deployments (e.q. Minikube, Docker Desktop) are not supported (although most of the functionality may be working).
- Note: since Kubernetes v1.24 Docker container runtime will not be reporting pod level network metrics (`kubenet` and other network plumbing was removed from upstream as part of the dockershim removal/deprecation)
- Supported architectures: Linux x86-64 (`amd64`), Linux ARM (`arm64`), Windows x86-64 (`amd64`).

## AutoInstrumentation

This chart allows you to deploy the [OpenTelemetry Operator](https://github.com/open-telemetry/opentelemetry-operator), which can be used to auto-instrument applications with [SWO APM](https://documentation.solarwinds.com/en/success_center/observability/content/intro/services.htm).

### Setting up

#### 1. Enable deployment of the operator
Set the following option in `values.yaml`: `operator.enable=true`

#### 2. Ensure proper TLS Certificate management
The operator expects that Cert Manager is already present on the cluster. There are a few different ways you can use to generate/configure the required TLS certificate:
1. Deploy `cert-manager` as part of this chart.
- Ensure there is no cert-manager instance already present in the cluster.
- Set `certmanager.enabled=true`.
2. Read the OTEL Operator documentation for alternative options: https://opentelemetry.io/docs/kubernetes/helm/operator/#configuration. All OTEL Operator configuration options are available below the `operator` key in `values.yaml`.

#### 3. Create an `Instrumentation` custom resource
- Create an `Instrumentation` custom resource with the following image set:
- Java: `ghcr.io/solarwinds/autoinstrumentation-java:2.9.0`
- Set `SW_APM_SERVICE_KEY` with the SWO ingestion API_TOKEN (the same API_TOKEN that is used for this chart can be used).
- Set `SW_APM_COLLECTOR` with the APM SWO endpoint (e.g., `apm.collector.na-01.st-ssp.solarwinds.com`).

##### Example

```
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: java-instrumentation
spec:
java:
image: ghcr.io/solarwinds/autoinstrumentation-java:2.9.0
env:
- name: SW_APM_SERVICE_KEY
valueFrom:
secretKeyRef:
name: swo-token
key: SOLARWINDS_API_TOKEN
- name: SW_APM_COLLECTOR
value: apm.collector.na-01.st-ssp.solarwinds.com
```
{{- end }}
#### 4. Instrument applications by setting the annotation
The final step is to opt your services into automatic instrumentation. This is done by updating your service’s `spec.template.metadata.annotations` to include a language-specific annotation:
- .NET: `instrumentation.opentelemetry.io/inject-dotnet: "true"`
- Go: `instrumentation.opentelemetry.io/inject-go: "true"`
- Java: `instrumentation.opentelemetry.io/inject-java: "true"`
- Node.js: `instrumentation.opentelemetry.io/inject-nodejs: "true"`
- Python: `instrumentation.opentelemetry.io/inject-python: "true"`
The possible values for the annotation can be:
- `"true"` - to inject the Instrumentation resource with the default name from the current namespace.
- `"my-instrumentation"` - to inject the Instrumentation CR instance with the name "my-instrumentation" in the current namespace.
- `"my-other-namespace/my-instrumentation"` - to inject the Instrumentation CR instance with the name "my-instrumentation" from another namespace "my-other-namespace".
- `"false"` - do not inject.
Alternatively, the annotation can be added to a namespace, which will result in all services in that namespace opting into automatic instrumentation. See the [Operator's auto-instrumentation documentation](https://github.com/open-telemetry/opentelemetry-operator/blob/main/README.md#opentelemetry-auto-instrumentation-injection) for more details.
7 changes: 7 additions & 0 deletions deploy/helm/events-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ processors:
- set(attributes["k8s.persistentvolume.annotations"], body["metadata"]["annotations"]) where body["kind"] == "PersistentVolume"
- set(attributes["k8s.persistentvolumeclaim.annotations"], body["metadata"]["annotations"]) where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.annotations"], body["metadata"]["annotations"]) where body["kind"] == "Ingress"
- set(attributes["k8s.configmap.annotations"], body["metadata"]["annotations"]) where body["kind"] == "ConfigMap"

# set entity labels for the resource
- set(attributes["k8s.pod.labels"], body["metadata"]["labels"]) where body["kind"] == "Pod"
Expand All @@ -126,6 +127,7 @@ processors:
- set(attributes["k8s.persistentvolume.labels"], body["metadata"]["labels"]) where body["kind"] == "PersistentVolume"
- set(attributes["k8s.persistentvolumeclaim.labels"], body["metadata"]["labels"]) where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.labels"], body["metadata"]["labels"]) where body["kind"] == "Ingress"
- set(attributes["k8s.configmap.labels"], body["metadata"]["labels"]) where body["kind"] == "ConfigMap"
{{- end }}
{{- if .Values.otel.manifests.enabled }}
transform/manifest:
Expand Down Expand Up @@ -158,6 +160,7 @@ processors:
- set(attributes["k8s.namespace.name"], body["metadata"]["namespace"])
- set(attributes["k8s.ingress.name"], body["metadata"]["name"]) where body["kind"] == "Ingress" or body["kind"] == "VirtualService"
- set(attributes["sw.k8s.ingress.type"], body["kind"]) where body["kind"] == "Ingress" or body["kind"] == "VirtualService"
- set(attributes["k8s.configmap.name"], body["metadata"]["name"]) where body["kind"] == "ConfigMap"
- set(attributes["k8s.object.kind"], body["kind"]) where body["kind"] != nil

# There are some attributes added by k8sobjects receiver, SWO do not need them so removing it
Expand Down Expand Up @@ -191,6 +194,7 @@ processors:
- k8s.persistentvolumeclaim.name
- k8s.ingress.name
- sw.k8s.ingress.type
- k8s.configmap.name

- k8s.pod.labels
- k8s.deployment.labels
Expand All @@ -205,6 +209,7 @@ processors:
- k8s.persistentvolume.labels
- k8s.persistentvolumeclaim.labels
- k8s.ingress.labels
- k8s.configmap.labels

- k8s.pod.annotations
- k8s.deployment.annotations
Expand All @@ -219,6 +224,7 @@ processors:
- k8s.persistentvolume.annotations
- k8s.persistentvolumeclaim.annotations
- k8s.ingress.annotations
- k8s.configmap.annotations
{{- end }}

resource/events:
Expand Down Expand Up @@ -305,6 +311,7 @@ receivers:
"persistentvolumes"
"persistentvolumeclaims"
"ingresses"
"configmaps"
}}
{{- if or (.Capabilities.APIVersions.Has "networking.istio.io/v1alpha3") (.Capabilities.APIVersions.Has "networking.istio.io/v1beta1") (.Capabilities.APIVersions.Has "networking.istio.io/v1") -}}
{{- $arrayOfWatchedResources = append $arrayOfWatchedResources "virtualservices" }}
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/templates/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ rules:
- services
- persistentvolumes
- persistentvolumeclaims
- configmaps
verbs:
- get
- list
Expand Down
Loading

0 comments on commit 9d39338

Please sign in to comment.