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

Add management support for the multicluster-observability-operator #53

Merged
merged 6 commits into from
Jun 12, 2024
Merged
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
43 changes: 34 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,53 @@ Then every time you want to test a new version, you can just:
```shell
make oci
# Delete the mcoa pod which will make the Deployment pull the new image
oc -n open-cluster-management delete pod -l app=multicluster-observability-addon-manager
oc -n open-cluster-management-observability delete pod -l app=multicluster-observability-addon-manager
```

### Disabeling specific signals
### Enable specific Observability Capabilities

The addon supports disabling signals using the resource `AddOnDeploymentConfig`. For instance, to disable the logging signal create the following resource on the hub cluster:
The addon supports enabling observability capabilities using the resource `AddOnDeploymentConfig`. For instance, to enable platform and user workloads logging/tracing/instrumentation create the following resource on the hub cluster:

```yaml
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: AddOnDeploymentConfig
metadata:
name: multicluster-observability-addon
namespace: open-cluster-management
namespace: open-cluster-management-observability
spec:
customizedVariables:
- name: loggingDisabled
value: "true"
# Platform Observability
- name: platformLogsCollection
value: clusterlogforwarders.v1.logging.openshift.io
# User Workloads Observability
- name: userWorkloadLogsCollection
value: clusterlogforwarders.v1.logging.openshift.io
periklis marked this conversation as resolved.
Show resolved Hide resolved
- name: userWorkloadTracesCollection
value: opentelemetrycollectors.v1beta1.opentelemetry.io
- name: userWorkloadInstrumentation
value: instrumentations.v1alpha1.opentelemetry.io
```

Supported keys are `metricsDisabled`, `loggingDisabled` and `tracingDisabled`
Supported keys are:
periklis marked this conversation as resolved.
Show resolved Hide resolved
- `platformLogsCollection`: Supports values `clusterlogforwarders.v1.logging.openshift.io`
- `userWorkloadLogsCollection`: Supports values `clusterlogforwarders.v1.logging.openshift.io`
- `userWorkloadTracesCollection`: Supports values `opentelemetrycollectors.v1beta1.opentelemetry.io`
- `userWorkloadTracesInstrumentation`: Supports values `instrumentations.v1alpha1.opentelemetry.io`

## Install the addon on a Spoke Cluster
__Note__: Some keys can hold multiple values separated by semicolon to support multiple data collection capabilities in parallel, e.g:

```yaml
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: AddOnDeploymentConfig
metadata:
name: multicluster-observability-addon
namespace: open-cluster-management-observability
spec:
customizedVariables:
# User Workloads Observability with multiple collectors
- name: userWorkloadLogsCollection
value: clusterlogforwarders.v1.logging.openshift.io;opentelemetrycollectors.v1beta1.opentelemetry.io
```

The addon installation is managed by the addon-manager. This means that users
don't need to explicetelly create resources to install the addon on spoke
Expand Down Expand Up @@ -118,7 +143,7 @@ This MCOA supports all outputs defined in [OpenShift Documentation](https://docs

Note: the service account used by the `ClusterLogForwarder` deployed by MCOA is `openshift-logging/mcoa-logcollector`, this information is esential when using the AWS STS authentication.

### Configuring Traces
### Traces Collection

Currently MCOA supports deploying a single instance of `OpenTelemetryCollector`
templated with the stanza created in the hub cluster. The instance deployed in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: logging.openshift.io/v1
kind: ClusterLogForwarder
metadata:
name: instance
namespace: open-cluster-management
namespace: open-cluster-management-observability
periklis marked this conversation as resolved.
Show resolved Hide resolved
spec:
outputs:
{{- range $_, $dic := .Values.outputs }}
Expand Down Expand Up @@ -38,4 +38,4 @@ spec:
{{- end }}
outputRefs:
- {{ $dic.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: logging-auth
namespace: open-cluster-management
namespace: open-cluster-management-observability
labels:
mcoa.openshift.io/signal: logging
data:
Expand All @@ -15,4 +15,4 @@ data:
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: spoke-otelcol
namespace: open-cluster-management
namespace: open-cluster-management-observability
spec:
config: |
receivers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: tracing-auth
namespace: open-cluster-management
namespace: open-cluster-management-observability
labels:
mcoa.openshift.io/signal: tracing
data:
otlp: mTLS
{{- end }}
{{- end }}
6 changes: 3 additions & 3 deletions demo/addon-install/templates/managed-cluster-addon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
# Logging Auth ConfigMap
- resource: configmaps
name: logging-auth
namespace: open-cluster-management
namespace: open-cluster-management-observability
# Logging URLs for Loki ConfigMap
{{- range $_, $dic := $.Values.logging.outputs }}
{{- if eq $dic.type "loki" }}
Expand All @@ -38,10 +38,10 @@ spec:
# Tracing Auth ConfigMap
- resource: configmaps
name: tracing-auth
namespace: open-cluster-management
namespace: open-cluster-management-observability
# Tracing ca-bundle configmap
- resource: secrets
name: otel-gateway
namespace: observability
{{- end }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions demo/mcoa-demo/templates/logging-static-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apiVersion: v1
kind: Secret
metadata:
name: static-authentication
namespace: open-cluster-management
namespace: open-cluster-management-observability
data:
aws_access_key_id: {{ .Values.logging.aws.keyID | b64enc }}
aws_secret_access_key: {{ .Values.logging.aws.keySecret | b64enc }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion deploy/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ images:
newName: quay.io/rhobs/multicluster-observability-addon
newTag: v0.0.1

namespace: open-cluster-management
namespace: open-cluster-management-observability

resources:
- resources/cluster_role_binding.yaml
Expand Down
17 changes: 14 additions & 3 deletions deploy/resources/addondeploymentconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ apiVersion: addon.open-cluster-management.io/v1alpha1
kind: AddOnDeploymentConfig
metadata:
name: multicluster-observability-addon
namespace: open-cluster-management
namespace: open-cluster-management-observability
spec:
customizedVariables:
- name: loggingSubscriptionChannel
value: stable-5.9
# Operator Subscription Channels
- name: openshiftLoggingChannel
value: stable-5.9
# Platform Observability
- name: platformLogsCollection
value: clusterlogforwarders.v1.logging.openshift.io
# User Workloads Observability
- name: userWorkloadLogsCollection
value: clusterlogforwarders.v1.logging.openshift.io
- name: userWorkloadTracesCollection
value: opentelemetrycollectors.v1beta1.opentelemetry.io
- name: userWorkloadInstrumentation
value: instrumentations.v1alpha1.opentelemetry.io
6 changes: 3 additions & 3 deletions deploy/resources/cluster-management-addon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
resource: addondeploymentconfigs
defaultConfig:
name: multicluster-observability-addon
namespace: open-cluster-management
namespace: open-cluster-management-observability
# Describes the default log forwarding outputs for each log type applied to all managed clusters.
- group: logging.openshift.io
resource: clusterlogforwarders
Expand All @@ -32,8 +32,8 @@ spec:
- group: logging.openshift.io
resource: clusterlogforwarders
name: instance
namespace: open-cluster-management
namespace: open-cluster-management-observability
- group: opentelemetry.io
resource: opentelemetrycollectors
name: instance
namespace: open-cluster-management
namespace: open-cluster-management-observability
2 changes: 1 addition & 1 deletion hack/addon-install/templates/aws-secret-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Secret
metadata:
name: aws-credentials-default
namespace: open-cluster-management
namespace: open-cluster-management-observability
type: Opaque
data:
aws_access_key_id: {{ .Values.awsCredentials.accessKeyID | b64enc }}
Expand Down
2 changes: 1 addition & 1 deletion hack/addon-install/templates/clf-instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: logging.openshift.io/v1
kind: ClusterLogForwarder
metadata:
name: instance
namespace: open-cluster-management
namespace: open-cluster-management-observability
spec:
outputs:
- cloudwatch:
Expand Down
4 changes: 2 additions & 2 deletions hack/addon-install/templates/instance-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: logging.openshift.io/v1
kind: ClusterLogForwarder
metadata:
name: instance-default
namespace: open-cluster-management
namespace: open-cluster-management-observability
spec:
outputs:
- cloudwatch:
Expand All @@ -17,4 +17,4 @@ spec:
inputRefs:
- infrastructure
outputRefs:
- cw
- cw
2 changes: 1 addition & 1 deletion hack/addon-install/templates/otelcol-instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: instance
namespace: open-cluster-management
namespace: open-cluster-management-observability
spec:
config:
exporters:
Expand Down
55 changes: 11 additions & 44 deletions internal/addon/helm/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package helm

import (
"context"
"strconv"

"github.com/rhobs/multicluster-observability-addon/internal/addon"
lhandlers "github.com/rhobs/multicluster-observability-addon/internal/logging/handlers"
lmanifests "github.com/rhobs/multicluster-observability-addon/internal/logging/manifests"
thandlers "github.com/rhobs/multicluster-observability-addon/internal/tracing/handlers"
tmanifests "github.com/rhobs/multicluster-observability-addon/internal/tracing/manifests"
"k8s.io/klog/v2"
"open-cluster-management.io/addon-framework/pkg/addonfactory"
addonutils "open-cluster-management.io/addon-framework/pkg/utils"
addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
Expand All @@ -25,36 +23,35 @@ type HelmChartValues struct {
Tracing tmanifests.TracingValues `json:"tracing"`
}

type Options struct {
LoggingDisabled bool
TracingDisabled bool
}

func GetValuesFunc(ctx context.Context, k8s client.Client) addonfactory.GetValuesFunc {
return func(
cluster *clusterv1.ManagedCluster,
addon *addonapiv1alpha1.ManagedClusterAddOn,
mcAddon *addonapiv1alpha1.ManagedClusterAddOn,
) (addonfactory.Values, error) {
// if hub cluster, then don't install anything
if isHubCluster(cluster) {
return addonfactory.JsonStructToValues(HelmChartValues{})
}

aodc, err := getAddOnDeploymentConfig(ctx, k8s, addon)
aodc, err := getAddOnDeploymentConfig(ctx, k8s, mcAddon)
if err != nil {
return nil, err
}
opts, err := buildOptions(aodc)
opts, err := addon.BuildOptions(aodc)
if err != nil {
return nil, err
}

if !opts.Platform.Enabled && !opts.UserWorkloads.Enabled {
return addonfactory.JsonStructToValues(HelmChartValues{})
}

userValues := HelmChartValues{
Enabled: true,
}

if !opts.LoggingDisabled {
loggingOpts, err := lhandlers.BuildOptions(ctx, k8s, addon, aodc)
if opts.Platform.Logs.CollectionEnabled || opts.UserWorkloads.Logs.CollectionEnabled {
loggingOpts, err := lhandlers.BuildOptions(ctx, k8s, mcAddon, opts.Platform.Logs, opts.UserWorkloads.Logs)
if err != nil {
return nil, err
}
Expand All @@ -66,9 +63,8 @@ func GetValuesFunc(ctx context.Context, k8s client.Client) addonfactory.GetValue
userValues.Logging = *logging
}

if !opts.TracingDisabled {
klog.Info("Tracing enabled")
tracingOpts, err := thandlers.BuildOptions(ctx, k8s, addon, aodc)
if opts.UserWorkloads.Traces.CollectionEnabled {
tracingOpts, err := thandlers.BuildOptions(ctx, k8s, mcAddon, opts.UserWorkloads.Traces)
if err != nil {
return nil, err
}
Expand All @@ -94,35 +90,6 @@ func getAddOnDeploymentConfig(ctx context.Context, k8s client.Client, mcAddon *a
return addOnDeployment, nil
}

func buildOptions(addOnDeployment *addonapiv1alpha1.AddOnDeploymentConfig) (Options, error) {
var opts Options
if addOnDeployment == nil {
return opts, nil
}

if addOnDeployment.Spec.CustomizedVariables == nil {
return opts, nil
}

for _, keyvalue := range addOnDeployment.Spec.CustomizedVariables {
switch keyvalue.Name {
case addon.AdcLoggingDisabledKey:
value, err := strconv.ParseBool(keyvalue.Value)
if err != nil {
return opts, err
}
opts.LoggingDisabled = value
case addon.AdcTracingisabledKey:
value, err := strconv.ParseBool(keyvalue.Value)
if err != nil {
return opts, err
}
opts.TracingDisabled = value
}
}
return opts, nil
}

func isHubCluster(cluster *clusterv1.ManagedCluster) bool {
val, ok := cluster.Labels[annotationLocalCluster]
if !ok {
Expand Down
Loading
Loading