Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/odiglet/github.com/odi…
Browse files Browse the repository at this point in the history
…gos-io/opentelemetry-zap-bridge-0.0.5
  • Loading branch information
blumamir authored May 13, 2024
2 parents 555769d + d9db9fd commit a5a747c
Show file tree
Hide file tree
Showing 37 changed files with 376 additions and 101 deletions.
1 change: 1 addition & 0 deletions api/config/crd/bases/odigos.io_instrumentationconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ spec:
- javascript
- mysql
- unknown
- ignored
type: string
required:
- instrumentationLibraryName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ spec:
- javascript
- mysql
- unknown
- ignored
type: string
required:
- containerName
Expand Down
4 changes: 4 additions & 0 deletions api/config/crd/bases/odigos.io_odigosconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ spec:
- sdkType
type: object
type: object
ignoredContainers:
items:
type: string
type: array
ignoredNamespaces:
items:
type: string
Expand Down

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

1 change: 1 addition & 0 deletions api/odigos/v1alpha1/odigosconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type OdigosConfigurationSpec struct {
ConfigVersion int `json:"configVersion"`
TelemetryEnabled bool `json:"telemetryEnabled,omitempty"`
IgnoredNamespaces []string `json:"ignoredNamespaces,omitempty"`
IgnoredContainers []string `json:"ignoredContainers,omitempty"`
Psp bool `json:"psp,omitempty"`
ImagePrefix string `json:"imagePrefix,omitempty"`
OdigletImage string `json:"odigletImage,omitempty"`
Expand Down
5 changes: 5 additions & 0 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.

2 changes: 1 addition & 1 deletion autoscaler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/goccy/go-yaml v1.11.3
github.com/odigos-io/odigos/api v0.0.0
github.com/odigos-io/odigos/common v0.0.0
github.com/odigos-io/opentelemetry-zap-bridge v0.0.4
github.com/odigos-io/opentelemetry-zap-bridge v0.0.5
github.com/stretchr/testify v1.8.4
k8s.io/api v0.30.0
k8s.io/apimachinery v0.30.0
Expand Down
4 changes: 2 additions & 2 deletions autoscaler/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/odigos-io/opentelemetry-zap-bridge v0.0.4 h1:Ew8xH8z5yIJnbunzX/qMO0j/USFgrUlzJVOWwKYRXw0=
github.com/odigos-io/opentelemetry-zap-bridge v0.0.4/go.mod h1:K98wHhktQ6vCTqeFztcpBDtPTe88vxVgZFlbeGobt24=
github.com/odigos-io/opentelemetry-zap-bridge v0.0.5 h1:UDEKtgab42nGVSvA/F3lLKUYFPETtpl7kpxM9BKBlWk=
github.com/odigos-io/opentelemetry-zap-bridge v0.0.5/go.mod h1:K98wHhktQ6vCTqeFztcpBDtPTe88vxVgZFlbeGobt24=
github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8=
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
Expand Down
6 changes: 5 additions & 1 deletion cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
telemetryEnabled bool
psp bool
userInputIgnoredNamespaces []string
userInputIgnoredContainers []string

instrumentorImage string
odigletImage string
Expand Down Expand Up @@ -164,13 +165,15 @@ func createNamespace(ctx context.Context, cmd *cobra.Command, client *kube.Clien

func createOdigosConfigSpec() odigosv1.OdigosConfigurationSpec {

fullIgnoredNamespaces := utils.AddSystemNamespacesToIgnored(userInputIgnoredNamespaces, consts.SystemNamespaces)
fullIgnoredNamespaces := utils.MergeDefaultIgnoreWithUserInput(userInputIgnoredNamespaces, consts.SystemNamespaces)
fullIgnoredContainers := utils.MergeDefaultIgnoreWithUserInput(userInputIgnoredContainers, consts.IgnoredContainers)

return odigosv1.OdigosConfigurationSpec{
OdigosVersion: versionFlag,
ConfigVersion: 1, // config version starts at 1 and incremented on every config change
TelemetryEnabled: telemetryEnabled,
IgnoredNamespaces: fullIgnoredNamespaces,
IgnoredContainers: fullIgnoredContainers,
Psp: psp,
ImagePrefix: imagePrefix,
OdigletImage: odigletImage,
Expand Down Expand Up @@ -202,6 +205,7 @@ func init() {
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(&userInputIgnoredContainers, "ignore-container", consts.IgnoredContainers, "container names to exclude from instrumentation (useful for sidecar container)")

if OdigosVersion != "" {
versionFlag = OdigosVersion
Expand Down
8 changes: 8 additions & 0 deletions cli/cmd/resources/crds/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ func NewConfiguration() *apiextensionsv1.CustomResourceDefinition {
},
},
},
"ignoredContainers": {
Type: "array",
Items: &apiextensionsv1.JSONSchemaPropsOrArray{
Schema: &apiextensionsv1.JSONSchemaProps{
Type: "string",
},
},
},
"imagePrefix": {
Type: "string",
},
Expand Down
3 changes: 3 additions & 0 deletions cli/cmd/resources/crds/instrumentedapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func NewInstrumentedApp() *apiextensionsv1.CustomResourceDefinition {
{
Raw: []byte(`"unknown"`),
},
{
Raw: []byte(`"ignored"`),
},
},
},
"envVars": {
Expand Down
9 changes: 9 additions & 0 deletions cli/cmd/resources/odiglet.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ func NewOdigletClusterRole(psp bool) *rbacv1.ClusterRole {
Name: "odiglet",
},
Rules: []rbacv1.PolicyRule{
{
Verbs: []string{
"get",
"list",
"watch",
},
APIGroups: []string{"odigos.io"},
Resources: []string{"odigosconfigurations"},
},
{
Verbs: []string{
"get",
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ and apply any required migrations and adaptations.`,
config.Spec.ConfigVersion += 1

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

currentTier, err := odigospro.GetCurrentOdigosTier(ctx, client, ns)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion common/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ var (
)

var (
SystemNamespaces = []string{DefaultNamespace, "kube-system", "local-path-storage", "istio-system", "linkerd", "kube-node-lease"}
SystemNamespaces = []string{DefaultNamespace, "kube-system", "local-path-storage", "istio-system", "linkerd", "kube-node-lease"}
IgnoredContainers = []string{"istio-proxy"}
)
20 changes: 16 additions & 4 deletions common/envOverwrite/overwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "strings"
// The key is the environment variable name and the value is the value to be set or appended
// to the environment variable. We need to make sure that in case any of these environment
// variables is already set, we append the value to it instead of overwriting it.
var EnvValues = map[string]struct{
var EnvValues = map[string]struct {
Value string
Delim string
}{
Expand All @@ -20,9 +20,21 @@ var EnvValues = map[string]struct{
},
}

func ShouldPatch(envName string, value string) bool {
_, ok := EnvValues[envName]
return ok
func ShouldPatch(envName string, observedValue string) bool {
odigosEnvValue, ok := EnvValues[envName]
if !ok {
// Odigos does not manipulate this environment variable, so ignore it
return false
}

if odigosEnvValue.Value == observedValue {
// if the observed value is the same as the value odigos sets,
// that means the user does not add any additional values,
// so we should not add it to the deployment manifest
return false
}

return true
}

func ShouldRevert(envName string, value string) bool {
Expand Down
8 changes: 5 additions & 3 deletions common/lang_detection.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package common

// +kubebuilder:validation:Enum=java;python;go;dotnet;javascript;mysql;unknown
// +kubebuilder:validation:Enum=java;python;go;dotnet;javascript;mysql;unknown;ignored
type ProgrammingLanguage string

const (
Expand All @@ -11,7 +11,9 @@ const (
JavascriptProgrammingLanguage ProgrammingLanguage = "javascript"
// This is an experimental feature, It is not a language
// but in order to avoid huge refactoring we are adding it here for now
MySQLProgrammingLanguage ProgrammingLanguage = "mysql"
MySQLProgrammingLanguage ProgrammingLanguage = "mysql"
// Used when the language detection is not successful for all the available inspectors
UnknownProgrammingLanguage ProgrammingLanguage = "unknown"
UnknownProgrammingLanguage ProgrammingLanguage = "unknown"
// Ignored is used when the odigos is configured to ignore the process/container
IgnoredProgrammingLanguage ProgrammingLanguage = "ignored"
)
14 changes: 7 additions & 7 deletions common/utils/ignoredns.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ func arrayContainsString(arr []string, str string) bool {
return false
}

func AddSystemNamespacesToIgnored(userIgnoredNamespaces []string, systemNamespaces []string) []string {
func MergeDefaultIgnoreWithUserInput(userInputIgnore []string, defaultIgnored []string) []string {

mergedList := make([]string, len(userIgnoredNamespaces))
copy(mergedList, userIgnoredNamespaces)
mergedList := make([]string, len(userInputIgnore))
copy(mergedList, userInputIgnore)

for _, ns := range systemNamespaces {
for _, ns := range defaultIgnored {
if !arrayContainsString(mergedList, ns) {
mergedList = append(mergedList, ns)
}
Expand All @@ -23,9 +23,9 @@ func AddSystemNamespacesToIgnored(userIgnoredNamespaces []string, systemNamespac
return mergedList
}

func IsNamespaceIgnored(namespace string, ignoredNamespaces []string) bool {
for _, ignoredNamespace := range ignoredNamespaces {
if namespace == ignoredNamespace {
func IsItemIgnored(item string, ignoredList []string) bool {
for _, ignoredListItem := range ignoredList {
if item == ignoredListItem {
return true
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/cli/odigos_install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ odigos install [flags]
--image-prefix prefix for collector images. Used when your cluster doesn't have access to docker hub.
--psp enable pod security policy
--ignore-namespace namespaces not to show in odigos ui
--ignore-container container names to exclude from instrumentation (useful for sidecar container)
```

The `--api-key` is required if you use Odigos Cloud.
Expand Down
8 changes: 7 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@
{
"group": "Setup",
"pages": [
"setup/installation",
{
"group": "Installation",
"pages": [
"setup/installation",
"setup/installation-options"
]
},
"setup/upgrade",
"setup/uninstall"
]
Expand Down
40 changes: 40 additions & 0 deletions docs/setup/installation-options.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: "Installation Options"
sidebarTitle: "Options"
---

You can configure odigos installation using the following options:

## Ignore Namespaces

Don't show specific uninteresting namespaces in the Odigos UI.

Default values: `kube-system`, `local-path-storage`, `istio-system`, `linkerd`, `kube-node-lease`

Add additional namespaces to ignore with **cli**:
```shell
odigos install --ignore-namespace <namespace1> --ignore-namespace <namespace2>
```

List all namespaces to be ignored with **helm chart**:
```shell
helm install odigos odigos/odigos --set ignoreNamespace=<namespace1>,<namespace2>
```

Any `odigos-instrumentation` label on the namespace and workloads in the namespace will still be honored.

## Ignore Containers

This option is useful for excluding specific sidecar containers from being instrumentated by odigos.

Default values: `istio-proxy`

Add additional containers to ignore with **cli**:
```shell
odigos install --ignore-container <container1> --ignore-container <container2>
```

List all containers to be ignored with **helm chart**:
```shell
helm install odigos odigos/odigos --set ignoreContainer=<container1>,<container2>
```
2 changes: 2 additions & 0 deletions docs/setup/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sidebarTitle: "Installation"
Installation issues? Need help? Message us on [Slack](https://join.slack.com/t/odigos/shared_invite/zt-24u91yknm-0fLXu6qnqYfNHS_GSUgTJw)
</Tip>

Checkout the [installation options](./installation-options) to customize your installation.

There are 2 ways to install odigos in your kubernetes cluster:
- [Odigos CLI](#odigos-cli)
- [Helm Chart](#helm-chart)
Expand Down
2 changes: 1 addition & 1 deletion frontend/endpoints/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GetNamespaces(c *gin.Context, odigosns string) {

var response GetNamespacesResponse
for _, namespace := range list.Items {
if utils.IsNamespaceIgnored(namespace.Name, odigosConfig.Spec.IgnoredNamespaces) {
if utils.IsItemIgnored(namespace.Name, odigosConfig.Spec.IgnoredNamespaces) {
continue
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import styled from 'styled-components';
import { KeyvalImage, KeyvalText } from '@/design.system';
import { ManagedSource } from '@/types/sources';
import { LANGUAGES_LOGOS } from '@/utils';
import { LANGUAGES_LOGOS, getMainContainerLanguage } from '@/utils';

const ManageSourceHeaderWrapper = styled.div`
display: flex;
Expand All @@ -28,7 +28,7 @@ const IMAGE_STYLE: React.CSSProperties = {
};

export function ManageSourceHeader({ source }: { source: ManagedSource }) {
const mainLanguage = source?.languages?.[0].language;
const mainLanguage = getMainContainerLanguage(source?.languages);
const imageUrl = LANGUAGES_LOGOS[mainLanguage];
return (
<ManageSourceHeaderWrapper>
Expand Down
Loading

0 comments on commit a5a747c

Please sign in to comment.