-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add config option for mount method hostpath or virtual device (#…
…2459) This allows the user to choose how to apply the mount. - `k8s-host-path` will add volume to the pod with "host-path". - `k8s-virtual-device` will add the "instrumentation.odigos.io/generic" device to the resource part of relevant containers. This allows control of how the mounting is achieved. Future work: auto detect if hostpath may fail and automatically fallback to virtual device. --------- Co-authored-by: Tamir David <[email protected]>
- Loading branch information
1 parent
90bf334
commit 442f266
Showing
17 changed files
with
263 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package k8sconsts | ||
|
||
const ( | ||
// the name of the device that only mounts the odigos agents root directory, | ||
// allowing any agent to be access it's files. | ||
// it would be more ideal to only mount what is needed, | ||
// but it's not desirable to have tons of different devices for each case. | ||
OdigosGenericDeviceName = "instrumentation.odigos.io/generic" | ||
) |
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,14 @@ | ||
package common | ||
|
||
// Note: this configuration is currently only relevant for k8s, | ||
// but is used in odigosconfig which is declared in the common package. | ||
// We should revisit this decision later on and consider if the config should be k8s specific, | ||
// then move it to the api module. | ||
|
||
// +kubebuilder:validation:Enum=virtual-device;host-path | ||
type MountMethod string | ||
|
||
const ( | ||
K8sVirtualDeviceMountMethod MountMethod = "k8s-virtual-device" | ||
K8sHostPathMountMethod MountMethod = "k8s-host-path" | ||
) |
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
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,93 @@ | ||
--- | ||
title: "Agent Mount Method" | ||
sidebarTitle: "Mount Method" | ||
icon: "gear" | ||
description: "For Odigos agents to run inside instrumented pod containers, certain files must be mounted into the container. In Kubernetes, these files are mounted under `/var/odigos` directory, with subdirectories for each agent. There are few mechanisms to achieve this, which are explained in this document." | ||
--- | ||
|
||
## Mount Method | ||
|
||
<Warning> | ||
This section is for advanced users and odigos administrators. | ||
|
||
It is recommended to use the default settings, unless you have specific requirements or run into an issue. | ||
</Warning> | ||
|
||
## Supported Mount Methods | ||
|
||
Odigos supports 2 mount methods, which can be used depending on the user preference, cluster policies, integration with existing tools, etc. | ||
|
||
### 1. VirtualDevice | ||
|
||
<Info> | ||
This is the default mount method | ||
</Info> | ||
|
||
#### Pod Manifest Additions | ||
|
||
For agents and languages that requires filesystem mounts, odigos webhook will add the following: | ||
|
||
- For each instrumented container in the pod spec, odigos will add a resource requirement under the `spec.containers[].resources` field: | ||
|
||
```yaml | ||
resources: | ||
limits: | ||
instrumentation.odigos.io/generic: "1" | ||
requests: | ||
instrumentation.odigos.io/generic: "1" | ||
``` | ||
#### Caveats | ||
- May sometimes not integrate well with node auto-scaling tools like [Karpenter](https://karpenter.sh/). | ||
- Odiglet daemonset needs to be running on a node for instrumented pods to be scheduled on that node. | ||
### 2. HostPath | ||
This method is an opt-in configuration option which can be used if the virtual device method is not suitable for your cluster. | ||
If it is supported in the cluster, it is preferred to use over the VirtualDevice method which requires odiglet component to run. | ||
**Enabling HostPath** | ||
- Profile: `odigos profile add mount-method-k8s-host-path` | ||
|
||
- Odigos CLI: `odigos config set mount-method k8s-host-path` | ||
|
||
- Helm Chart: in your values file, set `instrumentor.mountMethod` to `k8s-host-path`, or use helm cli `--set instrumentor.mountMethod=k8s-host-path` flag with helm upgrade. | ||
|
||
- Kubernetes Manifest: under the `odigos-config` ConfigMap in odigos namespace, set the value in the `mountMethod` field of `config.yaml` to `k8s-host-path`. | ||
|
||
**Pod Manifest Additions** | ||
|
||
For agents and languages that requires filesystem mounts, odigos webhook will add the following: | ||
|
||
- Volume to the pod spec, under the `spec.volumes` field: | ||
|
||
```yaml | ||
- hostPath: | ||
path: /var/odigos | ||
type: "" | ||
name: odigos-agent | ||
``` | ||
|
||
- VolumeMount to the instrumented container specs, under the `spec.containers[].volumeMounts` field: | ||
|
||
```yaml | ||
- mountPath: /var/odigos/{agent_sub_dir} | ||
name: odigos-agent | ||
readOnly: true | ||
subPath: {agent_sub_dir} | ||
``` | ||
|
||
**Caveats** | ||
|
||
The "HostPath" option should be enabled in the cluster. Some policy tools may block this, like: | ||
|
||
- [Open Policy Agent](https://www.openpolicyagent.org/) | ||
- [Kyverno](https://kyverno.io/) | ||
|
||
If your cluster enforces such policies, you have the following options: | ||
|
||
- Use the VirtualDevice method. | ||
- Request the cluster administrator to whitelist the Odigos agent host path in the policy tool. |
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
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.