Cette page explique comment vous connecter à votre instance Cloud SQL en utilisant l'opérateur proxy Cloud SQL. Pour en savoir plus sur le fonctionnement de l'opérateur proxy Cloud SQL, consultez la page À propos de l'opérateur proxy Cloud SQL.
Présentation
L'opérateur proxy Cloud SQL configure les applications déployées sur Google Kubernetes Engine (GKE) pour qu'elles se connectent aux instances de base de données Cloud SQL à l'aide du proxy d'authentification Cloud SQL. L'utilisation du proxy d'authentification Cloud SQL est la méthode recommandée pour se connecter à une instance Cloud SQL. Pour en savoir plus sur le proxy d'authentification Cloud SQL, consultez la section À propos du proxy d'authentification Cloud SQL.
Les applications exécutées dans GKE peuvent également se connecter à l'aide du proxy d'authentification Cloud SQL.
Avant de commencer
Pour pouvoir vous connecter à une instance Cloud SQL, procédez comme suit :
Pour un utilisateur ou un compte de service, assurez-vous que le compte dispose du rôle Client Cloud SQL. Ce rôle contient l'autorisation cloudsql.instances.connect, qui autorise un compte principal à se connecter à toutes les instances Cloud SQL d'un projet.
Vous pouvez éventuellement inclure une condition IAM dans la liaison de stratégie IAM qui autorise le compte à se connecter à une seule instance Cloud SQL spécifique.
Installez cert-manager à l'aide de Helm. Vous devrez utiliser les arguments de version et CLI spécifiés ici pour utiliser cert-manager sur votre cluster GKE.
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)."],[],[],null,["# Connect using the Cloud SQL Proxy Operator\n\n\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/connect-proxy-operator \"View this page for the MySQL database engine\") \\| [PostgreSQL](/sql/docs/postgres/connect-proxy-operator \"View this page for the PostgreSQL database engine\") \\| SQL Server\n\n\u003cbr /\u003e\n\nThis page describes how to connect to your Cloud SQL instance using the\nCloud SQL Proxy Operator. For more information about how the Cloud SQL Proxy Operator works, see\n[About the Cloud SQL Proxy Operator](/sql/docs/sqlserver/sql-proxy#proxy-operator).\n\nOverview\n--------\n\nThe Cloud SQL Proxy Operator configures applications deployed on Google Kubernetes Engine\n(GKE) to connect to Cloud SQL database instances\nusing the Cloud SQL Auth Proxy. Using the\n[Cloud SQL Auth Proxy](/sql/docs/sqlserver/sql-proxy) is the recommended\nmethod for connecting to a Cloud SQL instance. To learn more about\nthe Cloud SQL Auth Proxy, see [About the Cloud SQL Auth Proxy](/sql/docs/sqlserver/sql-proxy).\n\nApplications running in [GKE](/sql/docs/sqlserver/connect-kubernetes-engine#proxy) can connect using the Cloud SQL Auth Proxy.\n\nBefore you begin\n----------------\n\nBefore you can connect to a Cloud SQL instance, do the following:\n\n1. For a user or service account, make sure the account has the\n Cloud SQL Client role. This role contains the\n `cloudsql.instances.connect` permission,\n which authorizes a principal to connect to all Cloud SQL instances\n in a project.\n\n [Go to the IAM page](https://console.cloud.google.com/iam-admin/iam)\n\n You can optionally include an\n [IAM condition](/sql/docs/mysql/project-access-control#allow_users_to_connect_to_specific_instances)\n in the IAM policy binding that grants the account permission\n to connect only to one specific Cloud SQL instance.\n2.\n\n\n Enable the Cloud SQL Admin API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=sqladmin)\n3. Install and initialize the [gcloud CLI](/sdk/docs/install).\n\nInstall the Cloud SQL Proxy Operator\n------------------------------------\n\nUse the following steps to install the Cloud SQL Proxy Operator.\n\n1. Confirm that `kubectl` can connect to your GKE cluster. \n\n ```bash\n kubectl cluster-info\n ```\n For more information about connecting Google Kubernetes Engine to Cloud SQL, see [Connect from Google Kubernetes Engine](/sql/docs/sqlserver/connect-kubernetes-engine).\n2. Install `cert-manager` using helm. You will need to use the version and cli arguments specified here to use `cert-manager` on your GKE cluster. \n\n ```bash\n helm repo add jetstack https://charts.jetstack.io\n helm repo update\n helm install \\\n cert-manager jetstack/cert-manager \\\n --namespace cert-manager \\\n --version \"v1.9.1\" \\\n --create-namespace \\\n --set global.leaderElection.namespace=cert-manager \\\n --set installCRDs=true\n \n ```\n3. Install the Cloud SQL Proxy Operator to your kubernetes cluster: \n\n ```bash\n kubectl apply -f https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy-operator/v1.6.1/cloud-sql-proxy-operator.yaml\n \n ```\n4. Wait for the Cloud SQL Proxy Operator to start. \n\n ```bash\n kubectl rollout status deployment -n cloud-sql-proxy-operator-system cloud-sql-proxy-operator-controller-manager --timeout=90s\n \n ```\n5. Confirm that the Cloud SQL Proxy Operator is installed and running: \n\n ```bash\n kubectl get pods -n cloud-sql-proxy-operator-system\n \n ```\n\nWhat's next\n-----------\n\n\u003cbr /\u003e\n\n- Learn more about the [Cloud SQL Auth Proxy](/sql/docs/sqlserver/sql-proxy).\n- Learn more about [Identity and Access Management (IAM)](/iam/docs/overview).\n- Learn more about [Service Accounts](/iam/docs/understanding-service-accounts).\n- Learn about the [two levels of access control](/sql/docs/sqlserver/instance-access-control) for Cloud SQL instances.\n- Create [users](/sql/docs/sqlserver/create-manage-users) and [databases](/sql/docs/sqlserver/create-manage-databases).\n- Learn about [connecting to your instance from your application](/sql/docs/sqlserver/instance-access-control#instanceaccess).\n- Learn about [options for support](/sql/docs/support).\n\n\u003cbr /\u003e"]]