L'exécution de KSM avec l'opérateur Kubernetes vous permet d'effectuer les opérations suivantes :
Surveillez l'état des ressources personnalisées en temps réel dans votre pile d'observabilité compatible avec Prometheus, ainsi que les métriques AlloyDB Omni.
Créez des tableaux de bord et des alertes basés sur les métriques de ressources personnalisées pour une meilleure visibilité opérationnelle et une détection proactive des problèmes.
Fonctionnement des ressources personnalisées de l'opérateur Kubernetes AlloyDB Omni
Par défaut, les métriques de ressources personnalisées ne sont pas activées. Vous pouvez activer les métriques de ressources personnalisées à l'aide du chart Helm de l'opérateur AlloyDB Omni Kubernetes. Lorsque vous activez les métriques de ressources personnalisées, un déploiement KSM est créé avec un configmap qui définit les métriques de ressources personnalisées et un service de type ClusterIP pour exposer le point de terminaison des métriques du déploiement KSM. Votre collecteur Prometheus peut collecter les métriques, et vous pouvez les visualiser avec d'autres métriques AlloyDB Omni. Pour en savoir plus, consultez Métriques des ressources personnalisées pour l'opérateur Kubernetes AlloyDB Omni.
Avant de commencer
Assurez-vous de disposer des éléments suivants :
Un scraper de métriques compatible avec Prometheus s'exécutant dans votre cluster Kubernetes.
Accès à l'image kube-state-metrics hébergée sur registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0. Vous pouvez pré-extraire l'image vers votre registre privé.
Installer l'opérateur Kubernetes avec les métriques de ressources personnalisées activées
Vous utilisez les variables suivantes dans le graphique Helm de l'opérateur AlloyDB Omni Kubernetes pour contrôler l'installation et la suppression des métriques de ressources personnalisées :
Variable
Type
Description
Par défaut
crdMetrics.enabled
Booléen (vrai/faux)
Active et désactive les métriques de ressources personnalisées
Si vous pré-extrait l'image KSM publique à l'adresse registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0 vers votre registre privé, ignorez cette étape et passez à la suivante. Sinon, installez l'opérateur AlloyDB Omni Kubernetes avec des métriques de ressources personnalisées, puis passez à la dernière étape de cette procédure.
Pour installer l'opérateur AlloyDB Omni Kubernetes avec des métriques de ressources personnalisées et votre propre emplacement d'image KSM, exécutez la commande suivante :
Si l'installation aboutit, la sortie suivante devrait s'afficher :
NAME: alloydbomni-operator
LAST DEPLOYED: CURRENT_TIMESTAMP
NAMESPACE: alloydb-omni-system
STATUS: deployed
REVISION: 1
TEST SUITE: None
Nettoyez l'installation en supprimant le fichier d'installation de l'opérateur Kubernetes AlloyDB Omni téléchargé. Le fichier est nommé alloydbomni-operator-VERSION_NUMBER.tgz et se trouve dans votre répertoire de travail actuel.
Activer les métriques de ressources personnalisées sur un opérateur Kubernetes existant
Si vous avez déjà installé la version 1.3.0 (ou ultérieure) de l'opérateur Kubernetes AlloyDB Omni, vous pouvez activer les métriques de ressources personnalisées en mettant à niveau l'opérateur existant.
Ouvrez un terminal de ligne de commande Linux.
Recherchez la version actuelle de l'opérateur Kubernetes AlloyDB Omni et définissez les variables d'environnement en exécutant les commandes suivantes :
Mettez à niveau l'opérateur Kubernetes AlloyDB Omni en exécutant les commandes suivantes, puis passez à la dernière étape de cette procédure. Si vous pré-extrait l'image KSM publique à l'adresse registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0 vers votre registre privé, ignorez cette étape et passez directement à la suivante.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis guide explains how to monitor AlloyDB Omni Kubernetes operator custom resources using kube-state-metrics (KSM), available from version 1.3.0 onwards.\u003c/p\u003e\n"],["\u003cp\u003eEnabling custom resource metrics with KSM allows for real-time monitoring, dashboard creation, and alert configuration in your Prometheus-compatible observability stack, along with AlloyDB Omni metrics.\u003c/p\u003e\n"],["\u003cp\u003eCustom resource metrics can be enabled during the installation of the AlloyDB Omni Kubernetes operator or by upgrading an existing installation using the Helm chart with specific variables.\u003c/p\u003e\n"],["\u003cp\u003eYou need a Prometheus-compatible metrics scraper, access to the kube-state-metrics image, and the Helm package manager to enable and use these custom resource metrics.\u003c/p\u003e\n"],["\u003cp\u003eCustom resource metrics can also be disabled on an existing Kubernetes operator by running a command through Helm.\u003c/p\u003e\n"]]],[],null,["# Monitor AlloyDB Omni Kubernetes operator custom resources\n\nSelect a documentation version: 15.7.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/monitor-kubernetes-operator-custom-resources)\n- [16.8.0](/alloydb/omni/16.8.0/docs/monitor-kubernetes-operator-custom-resources)\n- [16.3.0](/alloydb/omni/16.3.0/docs/monitor-kubernetes-operator-custom-resources)\n- [15.12.0](/alloydb/omni/15.12.0/docs/monitor-kubernetes-operator-custom-resources)\n- [15.7.1](/alloydb/omni/15.7.1/docs/monitor-kubernetes-operator-custom-resources)\n- [15.7.0](/alloydb/omni/15.7.0/docs/monitor-kubernetes-operator-custom-resources)\n\n\u003cbr /\u003e\n\nThis page describes how to monitor the status of AlloyDB Omni Kubernetes operator custom resources using [kube-state-metrics](https://kubernetes.io/docs/concepts/cluster-administration/kube-state-metrics/) (KSM).\n\n\u003cbr /\u003e\n\n| **Note:** These metrics are only available on AlloyDB Omni Kubernetes operator version 1.3.0 and later.\n\nRunning KSM with the Kubernetes operator lets you do the following:\n\n- Monitor custom resource status in real time on your Prometheus-compatible observability stack, together with [AlloyDB Omni metrics](/alloydb/omni/15.7.0/docs/reference/omni-metrics).\n- Build dashboards and alerts on top of the custom resource metrics for better operational visibility and proactive issue detection.\n\nFor more information about kube-state-metrics, see\n[Overview](https://github.com/kubernetes/kube-state-metrics/tree/main?tab=readme-ov-file#overview).\nTo learn how kube-state-metrics monitors Kubernetes custom resources, see\n[Custom Resource State Metrics](https://github.com/kubernetes/kube-state-metrics/blob/main/docs/metrics/extend/customresourcestate-metrics.md#custom-resource-state-metrics).\n\nHow AlloyDB Omni Kubernetes operator custom resources work\n----------------------------------------------------------\n\nBy default, custom resource metrics aren't enabled. You can\nenable custom resource metrics using the AlloyDB Omni Kubernetes operator Helm chart. When you\nenable custom resource metrics, a KSM deployment is created with a `configmap` that defines\nthe custom resource metrics and a service of type ClusterIP to expose the metrics endpoint\nof the KSM deployment. Your\n[Prometheus](https://prometheus.io/)\ncollector can collect the metrics, and you can visualize these metrics with\nother AlloyDB Omni metrics. For more information, see\n[Custom resources metrics for the AlloyDB Omni Kubernetes operator](/alloydb/omni/15.7.0/docs/reference/custom-resource-metrics-kubernetes-operator).\n\nBefore you begin\n----------------\n\nMake sure that you have the following:\n\n- A [Prometheus](https://prometheus.io/)-compatible metrics scraper running in your Kubernetes cluster.\n- Access to the kube-state-metrics image hosted at `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0`. You can pre-pull the image to your private registry.\n- [The `helm` package manager](https://helm.sh/docs/intro/install/). You run Helm commands in a Linux command-line terminal.\n\nInstall the Kubernetes operator with custom resource metrics enabled\n--------------------------------------------------------------------\n\nYou use the following variables in the AlloyDB Omni Kubernetes operator Helm chart\nto control the installation and removal of custom resource metrics:\n\nIf you haven't installed the operator Helm chart yet, set the variables when\nyou run the Helm install.\n\nTo install Kubernetes operator with custom resource metrics enabled,\nfollow these steps:\n\n1. Open a Linux command-line terminal.\n2. Define the following environment variables by running the following\n commands:\n\n export GCS_BUCKET=alloydb-omni-operator\n export HELM_PATH=$(gcloud storage cat gs://$GCS_BUCKET/latest)\n export OPERATOR_VERSION=\"${HELM_PATH%%/*}\"\n\n3. Download the AlloyDB Omni Kubernetes operator:\n\n gcloud storage cp gs://$GCS_BUCKET/$HELM_PATH ./ --recursive\n\n4. If you pre-pull the public KSM image at\n `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0` to your\n private registry, skip this step and proceed to the next step. Otherwise,\n install the AlloyDB Omni Kubernetes operator with custom resource metrics, and then proceed\n to the final step in this procedure.\n\n helm install alloydbomni-operator alloydbomni-operator-${OPERATOR_VERSION}.tgz \\\n --create-namespace \\\n --namespace alloydb-omni-system \\\n --set crdMetrics.enabled=true \\\n --atomic \\\n --timeout 5m\n\n5. Export the environment variable:\n\n export KSM_IMAGE=\u003cfull path to your KSM image\u003e\n\n6. To install the AlloyDB Omni Kubernetes operator with custom resource metrics and your\n own KSM image location, run the following command:\n\n helm install alloydbomni-operator alloydbomni-operator-${OPERATOR_VERSION}.tgz \\\n --create-namespace \\\n --namespace alloydb-omni-system \\\n --set crdMetrics.enabled=true,crdMetrics.ksmImage=${KSM_IMAGE} \\\n --atomic \\\n --timeout 5m\n\n A successful installation returns the following output: \n\n ```\n NAME: alloydbomni-operator\n LAST DEPLOYED: CURRENT_TIMESTAMP\n NAMESPACE: alloydb-omni-system\n STATUS: deployed\n REVISION: 1\n TEST SUITE: None\n ```\n | **Note:** If you use Red Hat OpenShift 4.12 or later, then after you install the AlloyDB Omni Kubernetes operator you must perform the [Red Hat OpenShift reconciliation steps](/alloydb/omni/15.7.0/docs/deploy-kubernetes#rhel-openshift).\n7. Clean up the installation by deleting the downloaded\n AlloyDB Omni Kubernetes operator installation file. The file is named\n `alloydbomni-operator-VERSION_NUMBER.tgz`, and is located in your current\n working directory.\n\nEnable custom resource metrics on an existing Kubernetes operator\n-----------------------------------------------------------------\n\nIf you already have the AlloyDB Omni Kubernetes operator version 1.3.0 (or later)\ninstalled, you can enable custom resource metrics by upgrading the existing operator.\n\n1. Open a Linux command-line terminal.\n2. Find your current AlloyDB Omni Kubernetes operator version and define the\n environment variables by running the following commands:\n\n export OPERATOR_VERSION=$(helm ls -n alloydb-omni-system -o json | jq -r 'map(select(.name == \"alloydbomni-operator\") | .chart)| .[0]')\n\n OPERATOR_VERSION=${OPERATOR_VERSION#\"alloydbomni-operator-\"}\n\n echo $OPERATOR_VERSION\n\n export GCS_BUCKET=alloydb-omni-operator\n\n export HELM_PATH=$OPERATOR_VERSION/alloydbomni-operator-$OPERATOR_VERSION.tgz\n\n The output is your installed AlloyDB Omni Kubernetes operator version,\n for example, `1.3.0`.\n3. Download the specified version operator:\n\n gcloud storage cp gs://$GCS_BUCKET/$HELM_PATH ./ --recursive\n\n4. Upgrade the AlloyDB Omni Kubernetes operator by running the following\n commands, and then go to the final step in this procedure. If you pre-pull\n the public KSM image at\n `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.14.0` to your\n private registry, then skip this step and proceed directly to the next step.\n\n helm upgrade alloydbomni-operator alloydbomni-operator-${OPERATOR_VERSION}.tgz \\\n --namespace alloydb-omni-system \\\n --reuse-values \\\n --set crdMetrics.enabled=true \\\n --atomic \\\n --timeout 5m\n\n5. Export the environment variable:\n\n export KSM_IMAGE=\u003cfull path to your KSM image\u003e\n\n6. To perform the upgrade, run the following command:\n\n helm upgrade alloydbomni-operator alloydbomni-operator-${OPERATOR_VERSION}.tgz \\\n --namespace alloydb-omni-system \\\n --reuse-values \\\n --set crdMetrics.enabled=true,crdMetrics.ksmImage=${KSM_IMAGE} \\\n --atomic \\\n --timeout 5m\n\n | **Note:** Performing this upgrade doesn't cause a database restart.\n\n A successful upgrade returns the following output: \n\n ```\n NAME: alloydbomni-operator\n LAST DEPLOYED: CURRENT_TIMESTAMP\n NAMESPACE: alloydb-omni-system\n STATUS: deployed\n REVISION: 2\n TEST SUITE: None\n ```\n\nDisable custom resource metrics on an existing Kubernetes operator\n------------------------------------------------------------------\n\n1. Open a Linux command-line terminal.\n2. Run the following command:\n\n export OPERATOR_VERSION=$(helm ls -n alloydb-omni-system -o json | jq -r 'map(select(.name == \"alloydbomni-operator\") | .chart)| .[0]')\n\n OPERATOR_VERSION=${OPERATOR_VERSION#\"alloydbomni-operator-\"}\n\n3. To disable custom resource metrics, run the following command:\n\n helm upgrade alloydbomni-operator alloydbomni-operator-${OPERATOR_VERSION}.tgz \\\n --namespace alloydb-omni-system \\\n --reuse-values \\\n --set crdMetrics.enabled=false \\\n --atomic \\\n --timeout 5m\n\nView metrics using the Prometheus API\n-------------------------------------\n\nTo view your metrics, see [View metrics using the Prometheus API](/alloydb/omni/15.7.0/docs/manage#kubernetes).\n\nWhat's next\n-----------\n\n- Learn about [custom resources definition metrics for the AlloyDB Omni Kubernetes operator](/alloydb/omni/15.7.0/docs/reference/custom-resource-metrics-kubernetes-operator)."]]