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

Remove default SDKs and supported SDKs from Odigos config #1626

Merged
merged 4 commits into from
Oct 27, 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
30 changes: 0 additions & 30 deletions api/config/crd/bases/odigos.io_odigosconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ spec:
type: object
configVersion:
type: integer
defaultSDKs:
additionalProperties:
properties:
sdkTier:
type: string
sdkType:
description: 'Odigos supports two types of OpenTelemetry SDKs:
native and ebpf.'
type: string
required:
- sdkTier
- sdkType
type: object
type: object
goAutoIncludeCodeAttributes:
description: |-
this is internal currently, and is not exposed on the CLI / helm
Expand All @@ -119,22 +105,6 @@ spec:
type: boolean
psp:
type: boolean
supportedSDKs:
additionalProperties:
items:
properties:
sdkTier:
type: string
sdkType:
description: 'Odigos supports two types of OpenTelemetry SDKs:
native and ebpf.'
type: string
required:
- sdkTier
- sdkType
type: object
type: array
type: object
telemetryEnabled:
type: boolean
required:
Expand Down

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

3 changes: 0 additions & 3 deletions api/odigos/v1alpha1/odigosconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ type OdigosConfigurationSpec struct {
OdigletImage string `json:"odigletImage,omitempty"`
InstrumentorImage string `json:"instrumentorImage,omitempty"`
AutoscalerImage string `json:"autoscalerImage,omitempty"`
SupportedSDKs map[common.ProgrammingLanguage][]common.OtelSdk `json:"supportedSDKs,omitempty"`
DefaultSDKs map[common.ProgrammingLanguage]common.OtelSdk `json:"defaultSDKs,omitempty"`
Comment on lines -48 to -49
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

CollectorGateway *CollectorGatewayConfiguration `json:"collectorGateway,omitempty"`

// this is internal currently, and is not exposed on the CLI / helm
Expand Down Expand Up @@ -103,7 +101,6 @@ func (odigosConfig *OdigosConfiguration) ToCommonConfig() *common.OdigosConfigur
OdigletImage: odigosConfig.Spec.OdigletImage,
InstrumentorImage: odigosConfig.Spec.InstrumentorImage,
AutoscalerImage: odigosConfig.Spec.AutoscalerImage,
DefaultSDKs: odigosConfig.Spec.DefaultSDKs,
CollectorGateway: &collectorGateway,
GoAutoIncludeCodeAttributes: odigosConfig.Spec.GoAutoIncludeCodeAttributes,
}
Expand Down
23 changes: 0 additions & 23 deletions api/odigos/v1alpha1/zz_generated.deepcopy.go

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

43 changes: 0 additions & 43 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,52 +179,10 @@ func createNamespace(ctx context.Context, cmd *cobra.Command, client *kube.Clien
return nil
}

func otelSdkConfigCommunity() map[common.ProgrammingLanguage]common.OtelSdk {
return map[common.ProgrammingLanguage]common.OtelSdk{
common.JavaProgrammingLanguage: common.OtelSdkNativeCommunity,
common.PythonProgrammingLanguage: common.OtelSdkNativeCommunity,
common.GoProgrammingLanguage: common.OtelSdkEbpfCommunity,
common.DotNetProgrammingLanguage: common.OtelSdkNativeCommunity,
common.JavascriptProgrammingLanguage: common.OtelSdkNativeCommunity,
}
}

func otelSdkConfigCloud() map[common.ProgrammingLanguage]common.OtelSdk {
return map[common.ProgrammingLanguage]common.OtelSdk{
common.JavaProgrammingLanguage: common.OtelSdkNativeCommunity,
common.PythonProgrammingLanguage: common.OtelSdkNativeCommunity,
common.GoProgrammingLanguage: common.OtelSdkEbpfEnterprise,
common.DotNetProgrammingLanguage: common.OtelSdkNativeCommunity,
common.JavascriptProgrammingLanguage: common.OtelSdkNativeCommunity,
}
}

func otelSdkConfigOnPrem() map[common.ProgrammingLanguage]common.OtelSdk {
return map[common.ProgrammingLanguage]common.OtelSdk{
common.JavaProgrammingLanguage: common.OtelSdkEbpfEnterprise, // Notice - for onprem, the default for java is eBPF
common.PythonProgrammingLanguage: common.OtelSdkEbpfEnterprise,
common.GoProgrammingLanguage: common.OtelSdkEbpfEnterprise,
common.DotNetProgrammingLanguage: common.OtelSdkNativeCommunity,
common.JavascriptProgrammingLanguage: common.OtelSdkEbpfEnterprise,
common.MySQLProgrammingLanguage: common.OtelSdkEbpfEnterprise,
common.NginxProgrammingLanguage: common.OtelSdkNativeCommunity,
}
}

func createOdigosConfig(odigosTier common.OdigosTier) common.OdigosConfiguration {
fullIgnoredNamespaces := utils.MergeDefaultIgnoreWithUserInput(userInputIgnoredNamespaces, consts.SystemNamespaces)
fullIgnoredContainers := utils.MergeDefaultIgnoreWithUserInput(userInputIgnoredContainers, consts.IgnoredContainers)

var defaultOtelSdkPerLanguage map[common.ProgrammingLanguage]common.OtelSdk
switch odigosTier {
case common.CommunityOdigosTier:
defaultOtelSdkPerLanguage = otelSdkConfigCommunity()
case common.CloudOdigosTier:
defaultOtelSdkPerLanguage = otelSdkConfigCloud()
case common.OnPremOdigosTier:
defaultOtelSdkPerLanguage = otelSdkConfigOnPrem()
}

selectedProfiles := []common.ProfileName{}
profiles := resources.GetAvailableProfilesForTier(odigosTier)
for _, profile := range userInputInstallProfiles {
Expand Down Expand Up @@ -253,7 +211,6 @@ func createOdigosConfig(odigosTier common.OdigosTier) common.OdigosConfiguration
OdigletImage: odigletImage,
InstrumentorImage: instrumentorImage,
AutoscalerImage: autoScalerImage,
DefaultSDKs: defaultOtelSdkPerLanguage,
Profiles: selectedProfiles,
}
}
Expand Down
57 changes: 51 additions & 6 deletions cli/cmd/resources/instrumentor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewInstrumentorServiceAccount(ns string) *corev1.ServiceAccount {
}
}

func NewInstrumentorRoleBinding(ns string) *rbacv1.RoleBinding {
func NewInstrumentorLeaderElectionRoleBinding(ns string) *rbacv1.RoleBinding {
return &rbacv1.RoleBinding{
TypeMeta: metav1.TypeMeta{
Kind: "RoleBinding",
Expand All @@ -68,6 +68,54 @@ func NewInstrumentorRoleBinding(ns string) *rbacv1.RoleBinding {
}
}

func NewInstrumentorRoleBinding(ns string) *rbacv1.RoleBinding {
return &rbacv1.RoleBinding{
TypeMeta: metav1.TypeMeta{
Kind: "RoleBinding",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "odigos-instrumentor",
Namespace: ns,
},
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
Name: "odigos-instrumentor",
},
},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "Role",
Name: "odigos-instrumentor",
},
}
}

func NewInstrumentorRole(ns string) *rbacv1.Role {
return &rbacv1.Role{
TypeMeta: metav1.TypeMeta{
Kind: "Role",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "odigos-instrumentor",
Namespace: ns,
},
Rules: []rbacv1.PolicyRule{
{
Verbs: []string{
"get",
},
APIGroups: []string{""},
Resources: []string{
"secrets",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good for now.
In the future, we might want to consider storing the tier in the odigos-deployment configmap, so we can read the tier easily without needing permissions to secrets. We can also use envFrom to automatically have these as env variables in the code

},
},
},
}
}

func NewInstrumentorClusterRole() *rbacv1.ClusterRole {
return &rbacv1.ClusterRole{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -168,11 +216,6 @@ func NewInstrumentorClusterRole() *rbacv1.ClusterRole {
Resources: []string{"instrumentedapplications/status"},
Verbs: []string{"get", "patch", "update"},
},
{
APIGroups: []string{"odigos.io"},
Resources: []string{"odigosconfigurations"},
Verbs: []string{"create", "delete", "get", "list", "patch", "update", "watch"},
},
{
APIGroups: []string{"odigos.io"},
Resources: []string{"destinations"},
Expand Down Expand Up @@ -587,7 +630,9 @@ func (a *instrumentorResourceManager) InstallFromScratch(ctx context.Context) er
certManagerInstalled := isCertManagerInstalled(ctx, a.client)
resources := []client.Object{
NewInstrumentorServiceAccount(a.ns),
NewInstrumentorRole(a.ns),
NewInstrumentorRoleBinding(a.ns),
NewInstrumentorLeaderElectionRoleBinding(a.ns),
NewInstrumentorClusterRole(),
NewInstrumentorClusterRoleBinding(a.ns),
NewInstrumentorDeployment(a.ns, a.odigosVersion, a.config.TelemetryEnabled, a.config.ImagePrefix, a.config.InstrumentorImage),
Expand Down
1 change: 0 additions & 1 deletion common/odigos_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type OdigosConfiguration struct {
OdigletImage string `json:"odigletImage,omitempty"`
InstrumentorImage string `json:"instrumentorImage,omitempty"`
AutoscalerImage string `json:"autoscalerImage,omitempty"`
DefaultSDKs map[ProgrammingLanguage]OtelSdk `json:"defaultSDKs,omitempty"`
CollectorGateway *CollectorGatewayConfiguration `json:"collectorGateway,omitempty"`
CollectorNode *CollectorNodeConfiguration `json:"collectorNode,omitempty"`
Profiles []ProfileName `json:"profiles,omitempty"`
Expand Down
1 change: 0 additions & 1 deletion helm/odigos/templates/instrumentor/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ rules:
resources:
- collectorsgroups
- instrumentedapplications
- odigosconfigurations
- destinations
verbs:
- create
Expand Down
12 changes: 12 additions & 0 deletions helm/odigos/templates/instrumentor/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: odigos-instrumentor
namespace: {{ .Release.Namespace }}
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
13 changes: 13 additions & 0 deletions helm/odigos/templates/instrumentor/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: odigos-instrumentor
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: odigos-instrumentor
subjects:
- kind: ServiceAccount
name: odigos-instrumentor
namespace: {{ .Release.Namespace }}
15 changes: 8 additions & 7 deletions instrumentor/controllers/instrumentationdevice/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/odigos-io/odigos/instrumentor/controllers/utils"
"github.com/odigos-io/odigos/instrumentor/controllers/utils/versionsupport"
"github.com/odigos-io/odigos/instrumentor/instrumentation"
"github.com/odigos-io/odigos/instrumentor/sdks"
"github.com/odigos-io/odigos/k8sutils/pkg/conditions"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
k8sutils "github.com/odigos-io/odigos/k8sutils/pkg/utils"
"github.com/odigos-io/odigos/k8sutils/pkg/workload"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -35,6 +35,11 @@ const (
appliedInstrumentationDeviceType = "AppliedInstrumentationDevice"
)

var (
// can be overridden in tests
GetDefaultSDKs = sdks.GetDefaultSDKs
)

func clearInstrumentationEbpf(obj client.Object) {
annotations := obj.GetAnnotations()
if annotations == nil {
Expand Down Expand Up @@ -82,11 +87,6 @@ func addInstrumentationDeviceToWorkload(ctx context.Context, kubeClient client.C
Kind: workload.WorkloadKind(obj.GetObjectKind().GroupVersionKind().Kind),
}

odigosConfig, err := k8sutils.GetCurrentOdigosConfig(ctx, kubeClient)
if err != nil {
return err
}

// build an otel sdk map from instrumentation rules first, and merge it with the default otel sdk map
// this way, we can override the default otel sdk with the instrumentation rules
instrumentationRules := odigosv1.InstrumentationRuleList{}
Expand All @@ -95,7 +95,8 @@ func addInstrumentationDeviceToWorkload(ctx context.Context, kubeClient client.C
return err
}

otelSdkToUse := odigosConfig.DefaultSDKs
// default otel sdk map according to Odigos tier
otelSdkToUse := GetDefaultSDKs()

for i := range instrumentationRules.Items {
instrumentationRule := &instrumentationRules.Items[i]
Expand Down
Loading
Loading