Skip to content

Commit

Permalink
chore: set default ignore containers in reconcile
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir committed Jan 10, 2025
1 parent 5b5a12b commit 2152a1e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
5 changes: 2 additions & 3 deletions cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ func validateUserInputProfiles(tier common.OdigosTier) {
}

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

selectedProfiles := []common.ProfileName{}
Expand All @@ -218,7 +217,7 @@ func createOdigosConfig(odigosTier common.OdigosTier) common.OdigosConfiguration
ConfigVersion: 1, // config version starts at 1 and incremented on every config change
TelemetryEnabled: telemetryEnabled,
OpenshiftEnabled: openshiftEnabled,
IgnoredNamespaces: fullIgnoredNamespaces,
IgnoredNamespaces: userInputIgnoredNamespaces,
IgnoredContainers: fullIgnoredContainers,
SkipWebhookIssuerCreation: skipWebhookIssuerCreation,
Psp: psp,
Expand Down Expand Up @@ -254,7 +253,7 @@ func init() {
installCmd.Flags().StringVar(&autoScalerImage, "autoscaler-image", "keyval/odigos-autoscaler", "autoscaler container image name")
installCmd.Flags().StringVar(&imagePrefix, "image-prefix", "", "prefix for all container images. used when your cluster doesn't have access to docker hub")
installCmd.Flags().BoolVar(&psp, "psp", false, "enable pod security policy")
installCmd.Flags().StringSliceVar(&userInputIgnoredNamespaces, "ignore-namespace", consts.SystemNamespaces, "namespaces not to show in odigos ui")
installCmd.Flags().StringSliceVar(&userInputIgnoredNamespaces, "ignore-namespace", consts.DefaultIgnoredNamespaces, "namespaces not to show in odigos ui")
installCmd.Flags().StringSliceVar(&userInputIgnoredContainers, "ignore-container", consts.IgnoredContainers, "container names to exclude from instrumentation (useful for sidecar container)")
installCmd.Flags().StringSliceVar(&userInputInstallProfiles, "profile", []string{}, "install preset profiles with a specific configuration")

Expand Down
5 changes: 0 additions & 5 deletions cli/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/odigos-io/odigos/cli/cmd/resources/odigospro"
cmdcontext "github.com/odigos-io/odigos/cli/pkg/cmd_context"
"github.com/odigos-io/odigos/cli/pkg/confirm"
"github.com/odigos-io/odigos/common/consts"
"github.com/odigos-io/odigos/common/utils"
k8sconsts "github.com/odigos-io/odigos/k8sutils/pkg/consts"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -107,9 +105,6 @@ and apply any required migrations and adaptations.`,
// update the config on upgrade
config.ConfigVersion += 1

// make sure the current system namespaces is in the ignored in config
config.IgnoredNamespaces = utils.MergeDefaultIgnoreWithUserInput(config.IgnoredNamespaces, consts.SystemNamespaces)

currentTier, err := odigospro.GetCurrentOdigosTier(ctx, client, ns)
if err != nil {
fmt.Println("Odigos cloud login failed - unable to read the current Odigos tier.")
Expand Down
4 changes: 2 additions & 2 deletions common/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ var (
)

var (
SystemNamespaces = []string{DefaultOdigosNamespace, "kube-system", "local-path-storage", "istio-system", "linkerd", "kube-node-lease"}
IgnoredContainers = []string{"istio-proxy", "vault-agent", "filebeat", "linkerd-proxy", "fluentd", "akeyless-init"}
DefaultIgnoredNamespaces = []string{"kube-system", "local-path-storage", "istio-system", "linkerd", "kube-node-lease"}
IgnoredContainers = []string{"istio-proxy", "vault-agent", "filebeat", "linkerd-proxy", "fluentd", "akeyless-init"}
)
4 changes: 4 additions & 0 deletions scheduler/controllers/odigosconfig/odigosconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func (r *odigosConfigController) Reconcile(ctx context.Context, _ ctrl.Request)
return ctrl.Result{}, err
}

// make sure the default ignored namespaces are always present
odigosConfig.IgnoredNamespaces = mergeIgnoredItemLists(odigosConfig.IgnoredNamespaces, consts.DefaultIgnoredNamespaces)
odigosConfig.IgnoredNamespaces = append(odigosConfig.IgnoredNamespaces, env.GetCurrentNamespace())

err = r.persistEffectiveConfig(ctx, odigosConfig)
if err != nil {
return ctrl.Result{}, err
Expand Down
20 changes: 20 additions & 0 deletions scheduler/controllers/odigosconfig/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package odigosconfig

func mergeIgnoredItemLists(l1 []string, l2 []string) []string {

merged := map[string]struct{}{}

for _, i := range l1 {
merged[i] = struct{}{}
}
for _, i := range l2 {
merged[i] = struct{}{}
}

mergedList := make([]string, 0, len(merged))
for i := range merged {
mergedList = append(mergedList, i)
}

return mergedList
}

0 comments on commit 2152a1e

Please sign in to comment.