如果您的数据库在 Kubernetes 集群中运行,则可以向数据库集群添加边车容器。边车容器与主容器一起独立运行,可处理应用监控、日志记录和跟踪方面的请求。您可以使用针对 AlloyDB Omni 的自定义代理将日志、指标和跟踪记录导出到您选择的后端。
如果您的数据库在 Kubernetes 集群中运行,则可以使用 AlloyDB Omni Kubernetes 操作器向数据库集群添加边车容器。AlloyDB Omni 操作器边车容器是常规 Kubernetes 容器,可独立地与主要应用容器一起在同一个 Pod 中运行。您可以使用这些边车容器来处理应用监控、日志记录和跟踪方面的请求。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-05。"],[[["\u003cp\u003eThis information applies specifically to Kubernetes-based AlloyDB Omni deployments, not single-server setups.\u003c/p\u003e\n"],["\u003cp\u003eSidecar containers can be added to Kubernetes-based AlloyDB Omni database clusters for application monitoring, logging, and tracing purposes.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB Omni Operator sidecar containers are regular Kubernetes containers that run independently alongside the main database container within the same Pod.\u003c/p\u003e\n"],["\u003cp\u003eTo add a sidecar container, you must create a sidecar custom resource (CR) with the necessary image, command, arguments, and container name, then register it with your database cluster.\u003c/p\u003e\n"],["\u003cp\u003eModifying an active sidecar container will restart the associated Pod, potentially causing database downtime.\u003c/p\u003e\n"]]],[],null,["# Use a sidecar container in Kubernetes\n\nSelect a documentation version: 15.5.5keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/kubernetes-sidecar-container)\n- [16.8.0](/alloydb/omni/16.8.0/docs/kubernetes-sidecar-container)\n- [16.3.0](/alloydb/omni/16.3.0/docs/kubernetes-sidecar-container)\n- [15.12.0](/alloydb/omni/15.12.0/docs/kubernetes-sidecar-container)\n- [15.7.1](/alloydb/omni/15.7.1/docs/kubernetes-sidecar-container)\n- [15.7.0](/alloydb/omni/15.7.0/docs/kubernetes-sidecar-container)\n- [15.5.5](/alloydb/omni/15.5.5/docs/kubernetes-sidecar-container)\n- [15.5.4](/alloydb/omni/15.5.4/docs/kubernetes-sidecar-container)\n- [15.5.2](/alloydb/omni/15.5.2/docs/kubernetes-sidecar-container)\n\n\u003cbr /\u003e\n\n| The information on this page applies only to AlloyDB Omni for Kubernetes. It does not apply to AlloyDB Omni for containers.\n\n\u003cbr /\u003e\n\nIf your database runs in a Kubernetes cluster, then you can add *sidecar containers* to your database cluster. Sidecar containers run independently alongside the main container and serve requests for application monitoring, logging, and tracing. You can export logs, metrics, and traces to the backend of your choice using custom agents to AlloyDB Omni.\n\nIf your database runs in a Kubernetes cluster, then you can add sidecar containers to your database cluster using the AlloyDB Omni Kubernetes Operator. AlloyDB Omni Operator sidecar containers are regular Kubernetes [containers](https://kubernetes.io/docs/concepts/containers/) that run independently alongside the main application container within the same Pod. You can use these sidecar containers to serve requests for application monitoring, logging, and tracing.\n\nAlloyDB Omni Operator sidecar containers are distinct from Kubernetes built-in [sidecar containers](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/#pod-sidecar-containers).\n\nTo manually add a sidecar container to an existing AlloyDB Omni installation, you create a sidecar custom resource (CR) and add it to your database cluster.\n| **Caution:** Making changes to an active sidecar container restarts the Pod that it runs on, which might lead to database downtime.\n\nCreate a sidecar CR\n-------------------\n\n1. Apply the following manifest:\n\n ```\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: Sidecar\n metadata:\n name: SIDECAR_CR_NAME\n spec:\n sidecars:\n — image: CONTAINER_IMAGE\n command: [\"CONTAINER_COMMAND\"]\n args: [\"CONTAINER_ARGS\"]\n name: CONTAINER_NAME\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSIDECAR_CR_NAME\u003c/var\u003e: the name to apply to your sidecar container.\n - \u003cvar translate=\"no\"\u003eCONTAINER_IMAGE\u003c/var\u003e: the name of the file containing the image to run in the sidecar container, for example, `busybox`.\n - \u003cvar translate=\"no\"\u003eCONTAINER_COMMAND\u003c/var\u003e: the command for the container that runs in the Pod. The command can be a list of quoted strings. For more information, see [Define a command and arguments when you create a Pod](https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/).\n - \u003cvar translate=\"no\"\u003eCONTAINER_ARGS\u003c/var\u003e: the arguments for the command for the container that runs in the Pod.\n - \u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e: the name of the container. You can have multiple containers in the same sidecar CR, and each container has a different container name, image, command, and arguments.\n2. To verify that the sidecar CR is created, run the following command:\n\n kubectl describe \u003cvar translate=\"no\"\u003eSIDECAR_CR_NAME\u003c/var\u003e\n\n The output is similar to the following: \n\n Name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSIDECAR_CR_NAME\u003c/span\u003e\u003c/var\u003e\n Labels: \u003cnone\u003e\n Annotations: \u003cnone\u003e\n API Version: alloydbomni.dbadmin.goog/v1\n Kind: Sidecar\n Metadata:\n Creation Timestamp: 2024-04-15T21:49:00Z\n Finalizers:\n sidecars.dbadmin.goog/finalizer\n Generation: 2\n Resource Version: 2561336\n UID: e57f2e13-20c5-4905-b13b-39203bab36b4\n Spec:\n Sidecars:\n Args:\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCONTAINER_ARGS\u003c/span\u003e\u003c/var\u003e\n Command:\n \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCONTAINER_COMMAND\u003c/span\u003e\u003c/var\u003e\n Image: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCONTAINER_IMAGE\u003c/span\u003e\u003c/var\u003e\n Name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eCONTAINER_NAME\u003c/span\u003e\u003c/var\u003e\n Resources:\n Status:\n Observed Generation: 2\n Reconciled: true\n Events: \u003cnone\u003e\n\nRegister a sidecar container\n----------------------------\n\nTo register the sidecar container name to your database cluster, complete the following steps:\n\n1. Add the `sidecarRef` attribute to your database cluster `spec` object specification in its manifest:\n\n sidecarRef:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSIDECAR_CR_NAME\u003c/span\u003e\u003c/var\u003e\n\n2. Use the following command to apply the updated specification:\n\n kubectl patch dbclusters.alloydbomni.dbadmin.goog \u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e -p '{\"spec\":{\"primarySpec\":{\"sidecarRef\":{\"name\":\u003cvar translate=\"no\"\u003eSIDECAR_CR_NAME\u003c/var\u003e}}}}' --type=merge\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e: the name of your database cluster.\n - \u003cvar translate=\"no\"\u003eSIDECAR_CR_NAME\u003c/var\u003e: the name to apply to your sidecar container.\n\nWhat's next\n-----------\n\n- [Configure AlloyDB Omni](/alloydb/omni/15.5.5/docs/configure-omni)\n- [Manage and monitor AlloyDB Omni](/alloydb/omni/15.5.5/docs/manage)"]]