Se il tuo database viene eseguito in un cluster Kubernetes, puoi aggiungere
container sidecar al cluster di database utilizzando l'operatore AlloyDB Omni Kubernetes.
I container sidecar dell'operatore AlloyDB Omni sono normali
container
Kubernetes che vengono eseguiti
in modo indipendente insieme al container dell'applicazione principale all'interno dello stesso pod.
Puoi utilizzare questi container sidecar per gestire le richieste di monitoraggio, logging e tracciamento delle applicazioni.
I container sidecar dell'operatore AlloyDB Omni sono diversi dai
container sidecar
integrati in Kubernetes.
Per aggiungere manualmente un contenitore sidecar a un'installazione
AlloyDB Omni esistente, crea una risorsa personalizzata (CR) sidecar e aggiungila al cluster di database.
CONTAINER_IMAGE: il nome del file immagine da eseguire nel container sidecar. Ad esempio, busybox.
CONTAINER_COMMAND: il comando per il container
che viene eseguito nel pod. Il comando può essere un elenco di stringhe tra virgolette.
Per saperne di più, vedi
Definisci un comando e argomenti quando crei un pod.
CONTAINER_ARGS: argomenti per
CONTAINER_COMMAND.
CONTAINER_NAME: il nome del contenitore. Puoi
avere più container nello stesso CR sidecar e ogni
container ha un nome, un'immagine, un comando e
argomenti diversi.
Per verificare che la CR sidecar sia stata creata, esegui questo comando:
kubectldescribeSidecar/SIDECAR_CR_NAME
L'output è simile al seguente:
Name:SIDECAR_CR_NAMELabels:<none>
Annotations:<none>
API Version:alloydbomni.dbadmin.goog/v1Kind:SidecarMetadata:Creation Timestamp:2024-04-15T21:49:00ZFinalizers:sidecars.dbadmin.goog/finalizerGeneration:2Resource Version:2561336UID:e57f2e13-20c5-4905-b13b-39203bab36b4Spec:Sidecars:Args:CONTAINER_ARGSCommand:CONTAINER_COMMANDImage:CONTAINER_IMAGEName:CONTAINER_NAMEResources:Status:Observed Generation:2Reconciled:trueEvents:<none>
Registrare un container sidecar
Per registrare il nome del container sidecar nel cluster di database, utilizza il
seguente comando per applicare la specifica aggiornata:
DB_CLUSTER_NAME: il nome del tuo cluster di database.
SIDECAR_CR_NAME: il nome del container sidecar.
Accedere ai log da un container collaterale
Crea o modifica un container sidecar esistente in modo che
spec.sidecars.volumeMounts.name sia impostato su obsdisk e
spec.sidecars.volumeMounts.mountPath su un percorso visibile all'interno del
container sidecar.
CONTAINER_IMAGE: il nome del file immagine da eseguire nel container collaterale. Ad esempio, busybox.
CONTAINER_COMMAND: il comando per il container che
viene eseguito nel pod. Il comando può essere un elenco di stringhe tra virgolette. Per ulteriori informazioni, consulta
Definisci un comando e argomenti quando crei un pod.
CONTAINER_ARGS: gli argomenti per
CONTAINER_COMMAND.
CONTAINER_NAME: il nome del contenitore. Puoi
avere più container nello stesso CR sidecar e ogni container ha
un nome, un'immagine, un comando e argomenti diversi.
LOGS_PATH: il percorso all'interno del container sidecar in cui
AlloyDB Omni deve generare i log.
Registra il nuovo container sidecar o quello modificato.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis guide pertains specifically to Kubernetes-based AlloyDB Omni deployments, not single-server setups.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB Omni operator sidecar containers, distinct from built-in Kubernetes sidecars, run alongside the main application in the same Pod, facilitating tasks like monitoring and logging.\u003c/p\u003e\n"],["\u003cp\u003eAdding a sidecar involves creating a Sidecar custom resource (CR) with details like container image, command, arguments, and name.\u003c/p\u003e\n"],["\u003cp\u003eChanges to an active sidecar container will cause the pod to restart, which may cause database downtime.\u003c/p\u003e\n"],["\u003cp\u003eTo associate your created sidecar with your database cluster, patch your database cluster resource using the provided command, including the sidecar name.\u003c/p\u003e\n"]]],[],null,["# Use a sidecar container in Kubernetes\n\nSelect a documentation version: Current (16.8.0)keyboard_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\nsidecar containers to your database cluster using the AlloyDB Omni Kubernetes operator.\nAlloyDB Omni operator sidecar containers are regular\nKubernetes\n[containers](https://kubernetes.io/docs/concepts/containers/) that run\nindependently alongside the main application container within the same Pod.\nYou can use these sidecar containers to serve requests for application\nmonitoring, logging, and tracing.\n\nAlloyDB Omni operator sidecar containers are distinct from\nKubernetes built-in\n[sidecar containers](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/#pod-sidecar-containers).\n\nTo manually add a sidecar container to an existing\nAlloyDB Omni installation, you create a sidecar custom\nresource (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 result in database downtime.\n\nCreate a sidecar CR\n-------------------\n\n1. Apply the following manifest:\n\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: Sidecar\n metadata:\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 spec:\n sidecars:\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 command: [\"\u003cvar translate=\"no\"\u003eCONTAINER_COMMAND\u003c/var\u003e\"]\n args: [\"\u003cvar translate=\"no\"\u003eCONTAINER_ARGS\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\n Replace the following variables:\n - \u003cvar translate=\"no\"\u003eSIDECAR_CR_NAME\u003c/var\u003e: the name for your sidecar container.\n - \u003cvar translate=\"no\"\u003eCONTAINER_IMAGE\u003c/var\u003e: the name of the image file to run in your 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: arguments for \u003cvar translate=\"no\"\u003eCONTAINER_COMMAND\u003c/var\u003e.\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 Sidecar/\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, use the\nfollowing 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\nReplace the following variables:\n\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 for your sidecar container.\n\nAccess logs from a sidecar container\n------------------------------------\n\n1. Create, or modify an existing, sidecar container so that\n `spec.sidecars.volumeMounts.name` is set to `obsdisk` and\n `spec.sidecars.volumeMounts.mountPath` to a path visible within the\n sidecar container.\n\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: Sidecar\n metadata:\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 spec:\n sidecars:\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 command: [\"\u003cvar translate=\"no\"\u003eCONTAINER_COMMAND\u003c/var\u003e\"]\n args: [\"\u003cvar translate=\"no\"\u003eCONTAINER_ARGS\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 volumeMounts:\n - name: obsdisk\n mountPath: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eLOGS_PATH\u003c/span\u003e\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSIDECAR_CR_NAME\u003c/var\u003e: the name for your sidecar container.\n - \u003cvar translate=\"no\"\u003eCONTAINER_IMAGE\u003c/var\u003e: the name of the image file to run in your 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 \u003cvar translate=\"no\"\u003eCONTAINER_COMMAND\u003c/var\u003e.\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.\n - \u003cvar translate=\"no\"\u003eLOGS_PATH\u003c/var\u003e: the path within the sidecar container that AlloyDB Omni should output logs to.\n2. [Register](#register-sidecar-container) your new, or modified, sidecar\n container.\n\nWhat's next\n-----------\n\n- [Configure AlloyDB Omni](/alloydb/omni/current/docs/configure-omni).\n- [Manage and monitor AlloyDB Omni](/alloydb/omni/current/docs/manage)."]]