-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy ManifestWorks based on MCO-managed AddonDeploymentConfig
- Loading branch information
Showing
13 changed files
with
218 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package addon | ||
|
||
import ( | ||
addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" | ||
) | ||
|
||
const ( | ||
// Operator Subscription Channels | ||
KeyOpenShiftLoggingChannel = "openshiftLoggingChannel" | ||
|
||
// Platform Observability Keys | ||
KeyPlatformLogsCollection = "platformLogsCollection" | ||
|
||
// User Workloads Observability Keys | ||
KeyUserWorkloadLogsCollection = "userWorkloadLogsCollection" | ||
KeyUserWorkloadTracesCollection = "userWorkloadTracesCollection" | ||
KeyUserWorkloadTracesInstrumentation = "userWorkloadTracesInstrumentation" | ||
) | ||
|
||
type CollectionKind string | ||
|
||
const ( | ||
ClusterLogForwarderV1 CollectionKind = "clusterlogforwarders.v1.logging.openshift.io" | ||
OpenTelemetryCollectorV1beta1 CollectionKind = "opentelemetrycollectors.v1beta1.opentelemetry.io" | ||
) | ||
|
||
type InstrumentationKind string | ||
|
||
const ( | ||
InstrumentationV1alpha1 InstrumentationKind = "instrumentations.v1alpha1.opentelemetry.io" | ||
) | ||
|
||
type LogsOptions struct { | ||
CollectionEnabled bool | ||
SubscriptionChannel string | ||
} | ||
|
||
type TracesOptions struct { | ||
CollectionEnabled bool | ||
InstrumentationEnabled bool | ||
SubscriptionChannel string | ||
} | ||
|
||
type PlatformOptions struct { | ||
Enabled bool | ||
Logs LogsOptions | ||
} | ||
|
||
type UserWorkloadOptions struct { | ||
Enabled bool | ||
Logs LogsOptions | ||
Traces TracesOptions | ||
} | ||
|
||
type Options struct { | ||
Platform PlatformOptions | ||
UserWorkloads UserWorkloadOptions | ||
} | ||
|
||
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 { | ||
// Operator Subscriptions | ||
case KeyOpenShiftLoggingChannel: | ||
opts.Platform.Logs.SubscriptionChannel = keyvalue.Value | ||
opts.UserWorkloads.Logs.SubscriptionChannel = keyvalue.Value | ||
// Platform Observability Options | ||
case KeyPlatformLogsCollection: | ||
if keyvalue.Value == string(ClusterLogForwarderV1) { | ||
opts.Platform.Enabled = true | ||
opts.Platform.Logs.CollectionEnabled = true | ||
} | ||
// User Workload Observability Options | ||
case KeyUserWorkloadLogsCollection: | ||
if keyvalue.Value == string(ClusterLogForwarderV1) { | ||
opts.UserWorkloads.Enabled = true | ||
opts.UserWorkloads.Logs.CollectionEnabled = true | ||
} | ||
case KeyUserWorkloadTracesCollection: | ||
if keyvalue.Value == string(OpenTelemetryCollectorV1beta1) { | ||
opts.UserWorkloads.Enabled = true | ||
opts.UserWorkloads.Traces.CollectionEnabled = true | ||
} | ||
case KeyUserWorkloadTracesInstrumentation: | ||
if keyvalue.Value == string(InstrumentationV1alpha1) { | ||
opts.UserWorkloads.Enabled = true | ||
opts.UserWorkloads.Traces.InstrumentationEnabled = true | ||
} | ||
} | ||
} | ||
return opts, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.