Se il tuo database viene eseguito in un cluster Kubernetes, puoi metterlo in modalità di manutenzione disattivando i probe di attività e i probe di avvio, che vengono eseguiti sull'applicazione in container, per assicurarti che il pod del database sia in uno stato integro. La modalità di manutenzione ti consente di impostare un pod in stato di esecuzione quando devi eseguire un aggiornamento di manutenzione o riparare il pod.
Attivare la modalità di manutenzione
Verifica che esistano probe su un pod di database:
L'output non contiene i campi Liveness e Startup nella sezione spec del pod POD_NAME.
Disattivare la modalità di manutenzione
Per ripristinare il comportamento standard del cluster di database con l'esecuzione di probe di attività e avvio, utilizza il seguente comando per rimuovere maintenance dalla sezione spec del manifest DBCluster:
[[["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 outlines the process for enabling and disabling maintenance mode for a database in a Kubernetes cluster, specifically for AlloyDB Omni deployments.\u003c/p\u003e\n"],["\u003cp\u003eMaintenance mode is activated by disabling liveness and startup probes, which are typically used to monitor the health of the database pod.\u003c/p\u003e\n"],["\u003cp\u003eTo enable maintenance mode, you must set the \u003ccode\u003emode\u003c/code\u003e to \u003ccode\u003emaintenance\u003c/code\u003e within the \u003ccode\u003espec\u003c/code\u003e section of the DBCluster manifest and then apply the updated manifest using \u003ccode\u003ekubectl apply\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can verify that maintenance mode is enabled by checking that the liveness and startup fields are absent from the pod's specification.\u003c/p\u003e\n"],["\u003cp\u003eTo disable maintenance mode, you should remove the \u003ccode\u003emaintenance\u003c/code\u003e entry from the \u003ccode\u003espec\u003c/code\u003e section of your DBCluster manifest using the \u003ccode\u003ekubectl patch\u003c/code\u003e command, which will then re-enable the probes.\u003c/p\u003e\n"]]],[],null,["# Use maintenance mode on a database cluster 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-maintenance-mode)\n- [16.8.0](/alloydb/omni/16.8.0/docs/kubernetes-maintenance-mode)\n- [16.3.0](/alloydb/omni/16.3.0/docs/kubernetes-maintenance-mode)\n- [15.12.0](/alloydb/omni/15.12.0/docs/kubernetes-maintenance-mode)\n- [15.7.1](/alloydb/omni/15.7.1/docs/kubernetes-maintenance-mode)\n- [15.7.0](/alloydb/omni/15.7.0/docs/kubernetes-maintenance-mode)\n\n\u003cbr /\u003e\n\nThis page shows you how to put the database in maintenance mode in a Kubernetes cluster.\n\n\u003cbr /\u003e\n\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 put the database in maintenance mode by disabling [liveness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) and [startup probes](https://kubernetes.io/docs/concepts/configuration/liveness-readiness-startup-probes/#startup-probe), which run on your containerized application, to ensure that the database pod is in a healthy state. Maintenance mode helps you place a pod in a running state when you need to make a maintenance update or repair the pod.\n\nEnable maintenance mode\n-----------------------\n\n1. Verify that probes exist on a database pod:\n\n 1. Liveness probe:\n\n kubectl get po -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \u003cvar translate=\"no\"\u003eDATABASE_POD_NAME\u003c/var\u003e -o jsonpath='{.spec.containers[?(@.name==\"database\")].livenessProbe}'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e: the name of a namespace used to run your database---for example, `db`.\n - \u003cvar translate=\"no\"\u003eDATABASE_POD_NAME\u003c/var\u003e: the name of the database pod---for example, `al-4017-dbcluster-sample-0`.\n\n The following shows sample output with a liveness probe: \n\n {\"failureThreshold\":3,\"httpGet\":{\"path\":\"/healthz?\",\"port\":8090,\"scheme\":\"HTTP\"},\"periodSeconds\":10,\"successThreshold\":1,\"timeoutSeconds\":3}\n\n 2. Startup probe:\n\n kubectl get po -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \u003cvar translate=\"no\"\u003eDATABASE_POD_NAME\u003c/var\u003e -o jsonpath='{.spec.containers[?(@.name==\"database\")].startupProbe}'\n\n The following shows sample output with a startup probe: \n\n {\"exec\":{\"command\":[\"/usr/lib/postgresql/15/bin/psql\",\"-hlocalhost\",\"-Ualloydbadmin\",\"-c\",\"SELECT 1\"]},\"failureThreshold\":180,\"periodSeconds\":10,\"successThreshold\":1,\"timeoutSeconds\":1}\n\n2. Set `mode` to `maintenance` in the `spec` section of your DBCluster manifest:\n\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: DBCluster\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDB_CLUSTER_NAME\u003c/span\u003e\u003c/var\u003e\n namespace: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eNAMESPACE\u003c/span\u003e\u003c/var\u003e\n spec:\n allowExternalIncomingTraffic: false\n isDeleted: false\n mode: maintenance\n primarySpec:\n ...\n\n Replace \u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e with the name of this database cluster---for example, `my-db-cluster`.\n3. Apply the manifest:\n\n kubectl apply -f \u003cvar translate=\"no\"\u003eDB_CLUSTER_YAML\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eDB_CLUSTER_YAML\u003c/var\u003e with the name of this database cluster manifest file---for example, `alloydb-omni-db-cluster.yaml`.\n4. To verify that maintenance mode is enabled, run the following commands:\n\n - Liveness probe:\n\n kubectl get po -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \u003cvar translate=\"no\"\u003eDATABASE_POD_NAME\u003c/var\u003e -o jsonpath='{.spec.containers[?(@.name==\"database\")].livenessProbe}'\n\n - Startup probe:\n\n kubectl get po -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e \u003cvar translate=\"no\"\u003eDATABASE_POD_NAME\u003c/var\u003e -o jsonpath='{.spec.containers[?(@.name==\"database\")].startupProbe}'\n\n The output doesn't contain the `Liveness` and `Startup` fields in the `spec` section of your \u003cvar translate=\"no\"\u003ePOD_NAME\u003c/var\u003e pod.\n\nDisable maintenance mode\n------------------------\n\nTo return to the standard database cluster behavior with running liveliness and startup probes, use the following command to remove `maintenance` from the `spec` section of your DBCluster manifest: \n\n kubectl patch dbclusters.alloydbomni.dbadmin.goog \u003cvar translate=\"no\"\u003eDB_CLUSTER_NAME\u003c/var\u003e -p '{\"spec\":{\"mode\":\"\"}}' --type=merge -n \u003cvar translate=\"no\"\u003eDB_CLUSTER_NAMESPACE\u003c/var\u003e --type=merge\n\nSample outputs:\n\n- With a liveness probe:\n\n {\"failureThreshold\":3,\"httpGet\":{\"path\":\"/healthz?\",\"port\":8090,\"scheme\":\"HTTP\"},\"periodSeconds\":10,\"successThreshold\":1,\"timeoutSeconds\":3}\n\n- With a startup probe:\n\n {\"exec\":{\"command\":[\"/usr/lib/postgresql/15/bin/psql\",\"-hlocalhost\",\"-Ualloydbadmin\",\"-c\",\"SELECT 1\"]},\"failureThreshold\":180, \"periodSeconds\":10,\"successThreshold\":1,\"timeoutSeconds\":1}"]]