Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into remove-unused-contr…
Browse files Browse the repository at this point in the history
…oller
  • Loading branch information
blumamir committed Jan 10, 2025
2 parents f6f4a6a + 899906b commit 82821c9
Show file tree
Hide file tree
Showing 185 changed files with 379 additions and 5,497 deletions.
37 changes: 24 additions & 13 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ This command will install k8s components that will auto-instrument your applicat
odigosProToken = odigosOnPremToken
}

// validate user input profiles against available profiles
validateUserInputProfiles(odigosTier)

config := createOdigosConfig(odigosTier)

fmt.Printf("Installing Odigos version %s in namespace %s ...\n", versionFlag, ns)
Expand Down Expand Up @@ -182,25 +185,33 @@ func createNamespace(ctx context.Context, cmd *cobra.Command, client *kube.Clien
return nil
}

func validateUserInputProfiles(tier common.OdigosTier) {
// Fetch available profiles for the given tier
availableProfiles := resources.GetAvailableProfilesForTier(tier)

// Create a map for fast lookups of valid profile names
profileMap := make(map[string]struct{})
for _, profile := range availableProfiles {
profileMap[string(profile.ProfileName)] = struct{}{}
}

// Check each user input profile against the map
for _, input := range userInputInstallProfiles {
if _, exists := profileMap[input]; !exists {
fmt.Printf("\033[31mERROR\033[0m Profile '%s' not available.\n", input)
os.Exit(1)
}
}
}

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

selectedProfiles := []common.ProfileName{}
profiles := resources.GetAvailableProfilesForTier(odigosTier)

for _, profile := range userInputInstallProfiles {
found := false
for _, p := range profiles {
if string(p.ProfileName) == profile {
found = true
break
}
}
if !found {
fmt.Printf("\033[34mINFO\033[0m Profile '%s' skipped - not available for tier '%s'.\n", profile, odigosTier)
} else {
selectedProfiles = append(selectedProfiles, common.ProfileName(profile))
}
selectedProfiles = append(selectedProfiles, common.ProfileName(profile))
}

return common.OdigosConfiguration{
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ In this doc, we'll keep track of the permissions requested across different reso
| Odiglet | "" | configmaps | get, list, watch | Reads `odigos_config` for ignored containers. |
| Instrumentor | "" | configmaps | get, list, watch | Accesses `odigos-config` for instrumentation configuration. |
| Instrumentor | odigos.io | collectorsgroups | get, list, watch | Monitors collectors and their statuses. |
| Scheduler | "" | configmaps | get, list, watch | Reads configuration details from `odigos-config`. |
| Scheduler | "" | configmaps | get, list, watch | react and reconcile `odigos-config` changes to effective config. |
| Scheduler | "" | configmaps | get, list, watch, patch | apply effective config after reconciling (defaulting and profile applying) and react to it |
| Scheduler | odigos.io | collectorsgroups | get, list, create, patch, update, watch, delete | Manages `collectorsgroups`. |
| Scheduler | odigos.io | destinations | get, list, watch | Tracks destinations for scheduling behavior. |
| Autoscaler | "" | configmaps, services | get, list, watch, create, patch, update, delete, deletecollection | Manages collector configurations and services. |
Expand Down
9 changes: 5 additions & 4 deletions cli/cmd/resources/instrumentor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
"github.com/odigos-io/odigos/cli/pkg/crypto"
"github.com/odigos-io/odigos/cli/pkg/kube"
"github.com/odigos-io/odigos/common"
"github.com/odigos-io/odigos/common/consts"

"github.com/odigos-io/odigos/k8sutils/pkg/consts"
k8sutilsconsts "github.com/odigos-io/odigos/k8sutils/pkg/consts"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -88,7 +89,7 @@ func NewInstrumentorRole(ns string) *rbacv1.Role {
{
APIGroups: []string{""},
Resources: []string{"configmaps"},
ResourceNames: []string{"odigos-config"},
ResourceNames: []string{consts.OdigosEffectiveConfigName},
Verbs: []string{"get", "list", "watch"},
},
{
Expand Down Expand Up @@ -289,7 +290,7 @@ func NewMutatingWebhookConfiguration(ns string, caBundle []byte) *admissionregis
TimeoutSeconds: intPtr(10),
ObjectSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
consts.OdigosInjectInstrumentationLabel: "true",
k8sutilsconsts.OdigosInjectInstrumentationLabel: "true",
},
},
AdmissionReviewVersions: []string{
Expand Down Expand Up @@ -411,7 +412,7 @@ func NewInstrumentorDeployment(ns string, version string, telemetryEnabled bool,
{
ConfigMapRef: &corev1.ConfigMapEnvSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: consts.OdigosDeploymentConfigMapName,
Name: k8sutilsconsts.OdigosDeploymentConfigMapName,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/resources/odiglet.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewOdigletRole(ns string) *rbacv1.Role {
{ // Needed to read the odigos_config for ignored containers
APIGroups: []string{""},
Resources: []string{"configmaps"},
ResourceNames: []string{consts.OdigosConfigurationName},
ResourceNames: []string{consts.OdigosEffectiveConfigName},
Verbs: []string{"get", "list", "watch"},
},
},
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/resources/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func GetAvailableCommunityProfiles() []k8sprofiles.Profile {

func GetAvailableOnPremProfiles() []k8sprofiles.Profile {
return append([]k8sprofiles.Profile{k8sprofiles.FullPayloadCollectionProfile, k8sprofiles.DbPayloadCollectionProfile, k8sprofiles.CategoryAttributesProfile,
k8sprofiles.HostnameAsPodNameProfile, k8sprofiles.JavaNativeInstrumentationsProfile, k8sprofiles.KratosProfile, k8sprofiles.QueryOperationDetector,
k8sprofiles.HostnameAsPodNameProfile, k8sprofiles.JavaNativeInstrumentationsProfile, k8sprofiles.JavaEbpfInstrumentationsProfile, k8sprofiles.KratosProfile, k8sprofiles.QueryOperationDetector,
k8sprofiles.SmallBatchesProfile},
GetAvailableCommunityProfiles()...)
}
Expand Down
12 changes: 12 additions & 0 deletions cli/cmd/resources/profiles/java-ebpf-instrumentations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: odigos.io/v1alpha1
kind: InstrumentationRule
metadata:
name: java-ebpf-instrumentations
spec:
ruleName: "java ebpf instrumentations"
notes: "Auto generated rule from java-ebpf-instrumentations profile. Do not edit."
otelSdks:
otelSdkByLanguage:
java:
sdkTier: "enterprise"
sdkType: "ebpf"
12 changes: 0 additions & 12 deletions cli/cmd/resources/profiles/java-native-instrumentations.yaml

This file was deleted.

11 changes: 8 additions & 3 deletions cli/cmd/resources/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ func NewSchedulerRole(ns string) *rbacv1.Role {
Namespace: ns,
},
Rules: []rbacv1.PolicyRule{
{ // Needed to extract the configmap of odigos-config
{ // Needed to react and reconcile odigos-config changes to effective config
APIGroups: []string{""},
Resources: []string{"configmaps"},
Verbs: []string{"get", "list", "watch"},
},
{ // Needed to apply effective config after reconciling (defaulting and profile applying) and react to it
APIGroups: []string{""},
Resources: []string{"configmaps"},
ResourceNames: []string{consts.OdigosConfigurationName},
Verbs: []string{"get", "list", "watch"},
ResourceNames: []string{consts.OdigosEffectiveConfigName},
Verbs: []string{"patch"},
},
{ // Needed because the scheduler is managing the collectorsgroups
APIGroups: []string{"odigos.io"},
Expand Down
4 changes: 0 additions & 4 deletions cli/cmd/resources/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ func NewUIService(ns string) *corev1.Service {
Name: "ui",
Port: 3000,
},
{
Name: "legacy-ui",
Port: 3001,
},
{
Name: "otlp",
Port: consts.OTLPPort,
Expand Down
22 changes: 7 additions & 15 deletions cli/cmd/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import (
)

const (
defaultPort = 3000
legacyDefaultPort = 3001
defaultPort = 3000
)

// uiCmd represents the ui command
Expand All @@ -50,29 +49,23 @@ var uiCmd = &cobra.Command{
}
}

legacyFlag, _ := cmd.Flags().GetBool("legacy")
localPort := cmd.Flag("port").Value.String()
clusterPort := defaultPort

if legacyFlag {
clusterPort = legacyDefaultPort
}

localAddress := cmd.Flag("address").Value.String()

uiPod, err := findOdigosUIPod(client, ctx, ns)
if err != nil {
fmt.Printf("\033[31mERROR\033[0m Cannot find odigos-ui pod: %s\n", err)
os.Exit(1)
}

if err := portForwardWithContext(ctx, uiPod, client, localPort, localAddress, clusterPort); err != nil {
if err := portForwardWithContext(ctx, uiPod, client, localPort, localAddress); err != nil {
fmt.Printf("\033[31mERROR\033[0m Cannot start port-forward: %s\n", err)
os.Exit(1)
}
},
}

func portForwardWithContext(ctx context.Context, uiPod *corev1.Pod, client *kube.Client, localPort string, localAddress string, clusterPort int) error {
func portForwardWithContext(ctx context.Context, uiPod *corev1.Pod, client *kube.Client, localPort string, localAddress string) error {
stopChannel := make(chan struct{}, 1)
readyChannel := make(chan struct{})
signals := make(chan os.Signal, 1)
Expand Down Expand Up @@ -102,7 +95,7 @@ func portForwardWithContext(ctx context.Context, uiPod *corev1.Pod, client *kube
Name(uiPod.Name).
SubResource("portforward")

return forwardPorts("POST", req.URL(), client.Config, stopChannel, readyChannel, localPort, localAddress, clusterPort)
return forwardPorts("POST", req.URL(), client.Config, stopChannel, readyChannel, localPort, localAddress)
}

func createDialer(method string, url *url.URL, cfg *rest.Config) (httpstream.Dialer, error) {
Expand All @@ -122,13 +115,13 @@ func createDialer(method string, url *url.URL, cfg *rest.Config) (httpstream.Dia
return dialer, nil
}

func forwardPorts(method string, url *url.URL, cfg *rest.Config, stopCh chan struct{}, readyCh chan struct{}, localPort string, localAddress string, clusterPort int) error {
func forwardPorts(method string, url *url.URL, cfg *rest.Config, stopCh chan struct{}, readyCh chan struct{}, localPort string, localAddress string) error {
dialer, err := createDialer(method, url, cfg)
if err != nil {
return err
}

port := fmt.Sprintf("%s:%d", localPort, clusterPort)
port := fmt.Sprintf("%s:%d", localPort, defaultPort)
fw, err := portforward.NewOnAddresses(dialer,
[]string{localAddress},
[]string{port}, stopCh, readyCh, nil, os.Stderr)
Expand Down Expand Up @@ -163,5 +156,4 @@ func init() {
rootCmd.AddCommand(uiCmd)
uiCmd.Flags().Int("port", defaultPort, "Port to listen on")
uiCmd.Flags().String("address", "localhost", "Address to listen on")
uiCmd.Flags().Bool("legacy", false, "Use the legacy UI port")
}
1 change: 1 addition & 0 deletions common/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
CurrentNamespaceEnvVar = "CURRENT_NS"
DefaultOdigosNamespace = "odigos-system"
OdigosConfigurationName = "odigos-config"
OdigosEffectiveConfigName = "effective-config"
OdigosConfigurationFileName = "config.yaml"
OTLPPort = 4317
OTLPHttpPort = 4318
Expand Down
11 changes: 0 additions & 11 deletions docs/quickstart/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,3 @@ odigos ui
```

By default, Odigos UI is available at http://localhost:3000.

## Using the Legacy UI

```bash
odigos ui --legacy
```

<Warning>
The new UI is the default experience. The legacy UI remains available for
users who prefer the previous version.
</Warning>
1 change: 0 additions & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ FROM --platform=$BUILDPLATFORM golang:1.23 AS backend
WORKDIR /app
COPY . .
COPY --from=builder /webapp/out frontend/webapp/out
COPY --from=builder /webapp/dep-out frontend/webapp/dep-out
WORKDIR /app/frontend
ARG TARGETARCH
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o odigos-ui
Expand Down
100 changes: 0 additions & 100 deletions frontend/endpoints/actions/addclusterinfo.go

This file was deleted.

Loading

0 comments on commit 82821c9

Please sign in to comment.