Guide de démarrage rapide : synchroniser les configurations à partir d'un dépôt
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Dans ce tutoriel, vous allez créer un cluster Google Kubernetes Engine (GKE) Enterprise Edition et utiliser Config Sync pour synchroniser les configurations dans le dépôt d'exemples multirepos.
Imaginons que votre équipe de conformité soit chargée de s'assurer que tous les membres de votre organisation respectent les règles internes. Pour appliquer ces règles, l'équipe de conformité a créé des configurations qu'elle a ajoutées au dépôt d'exemples. Tous les clusters de votre organisation doivent être synchronisés avec le dépôt. Vous êtes responsable de la création et de la synchronisation des clusters.
Avant de commencer
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
In the Principal column, find all rows that identify you or a group that
you're included in. To learn which groups you're included in, contact your
administrator.
For all rows that specify or include you, check the Role column to see whether
the list of roles includes the required roles.
Dans le champ Nouveaux comptes principaux, saisissez votre identifiant utilisateur.
Il s'agit généralement de l'adresse e-mail d'un compte Google.
Dans la liste Sélectionner un rôle, sélectionnez un rôle.
Pour attribuer des rôles supplémentaires, cliquez sur addAjouter un autre rôle et ajoutez chaque rôle supplémentaire.
Cliquez sur Enregistrer.
Créer un cluster
Dans cette section, vous allez créer un cluster que vous pourrez utiliser dans ce tutoriel.
Dans la réalité, vous géreriez probablement plusieurs clusters. Pour simplifier ce tutoriel, vous ne créerez et ne gérerez qu'un seul cluster.
Pour créer un cluster, procédez comme suit :
Activez l'API Google Kubernetes Engine (GKE) Enterprise Edition. C'est essentiel pour Config Sync.
Dans la section Autopilot, sélectionnez Configurer.
Dans la section Paramètres de base du cluster, saisissez cs-cluster dans le champ Nom.
Dans la section Niveau de cluster, sélectionnez Niveau Enterprise. Conservez les valeurs par défaut recommandées dans tous les autres champs.
Cliquez sur Créer. Vous êtes redirigé vers la page Clusters Kubernetes. La création du cluster prend plusieurs minutes. Lorsqu'une coche verte apparaît dans la colonne État à côté de votre cluster, cela signifie qu'il est prêt.
Configurer le cluster
Maintenant que vous avez créé un cluster, vous pouvez configurer Config Sync pour qu'il se synchronise avec les configurations du répertoire config-sync-quickstart du dépôt d'exemples.
Pour configurer Config Sync dans la console Google Cloud , procédez comme suit :
Dans la console Google Cloud , accédez à la page Configuration sous la section Fonctionnalités.
Sélectionnez la version de Config Sync que vous souhaitez utiliser.
Sous Options d'installation, sélectionnez Installer Config Sync sur des clusters individuels.
Dans le tableau Clusters disponibles, sélectionnez cs-cluster, puis cliquez sur Installer Config Sync.
Dans l'onglet Paramètres, l'état de cs-cluster devrait être Activé après quelques minutes.
Sur le tableau de bord Config Sync, cliquez sur Déployer le package de cluster.
Dans le tableau Sélectionner les clusters pour le déploiement du package, sélectionnez cs-cluster, puis cliquez sur Continuer.
Laissez l'option Package hébergé sur Git, puis cliquez sur Continuer.
Dans le champ Nom du package, saisissez sample-repository.
Dans le champ URL du dépôt, saisissez https://github.com/GoogleCloudPlatform/anthos-config-management-samples.
Dans le champ Chemin d'accès, saisissez config-sync-quickstart/multirepo/root.
Conservez les valeurs par défaut dans les autres champs.
Cliquez sur Déployer le package.
Après quelques minutes, Synchronisé doit s'afficher dans la colonne État de synchronisation de cs-cluster.
Maintenant que Config Sync est synchronisé avec un dépôt, il synchronise en permanence l'état de vos clusters avec les configurations du dépôt.
Afficher les détails du package
Pour afficher tous les objets gérés par Config Sync, accédez à l'onglet Packages, puis cliquez sur cs-cluster pour afficher la page d'informations sur le package. Cette page vous donne un aperçu de toutes les ressources synchronisées par package, ainsi que des détails tels que le type de ressource et l'espace de noms dans lequel les ressources sont synchronisées.
Vous pouvez accéder au dossier /config-sync-quickstart/multirepo/ du dépôt dans GitHub pour examiner les configurations qui ont entraîné la création de ces espaces de noms. Le répertoire config-sync-quickstart inclut les configurations ClusterRole, CustomResourceDefinition, Rolebinding, Namespace et RepoSync. Il inclut également des configurations pour Prometheus Operator pour la surveillance.
Effectuer un nettoyage
Accédez au menu GKE dans la console Google Cloud .
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/01 (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/01 (UTC)."],[],[],null,["In this tutorial, you create a Google Kubernetes Engine cluster and\nuse Config Sync to sync to configs in the\n[multi-repo samples repository](https://github.com/GoogleCloudPlatform/anthos-config-management-samples/tree/main/config-sync-quickstart/multirepo).\n\nImagine that your compliance team is responsible for making sure that everyone\nin your organization is following internal rules. To enforce these rules, the\ncompliance team has created configs, which they have added to the samples\nrepository. Each cluster in your organization is required to sync to the\nrepository and you are responsible for creating and syncing clusters.\n\nBefore you begin\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n1.\n\n Make sure that you have the following role or roles on the project:\n\n Kubernetes Engine Admin\n\n Check for the roles\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3.\n In the **Principal** column, find all rows that identify you or a group that\n you're included in. To learn which groups you're included in, contact your\n administrator.\n\n 4. For all rows that specify or include you, check the **Role** column to see whether the list of roles includes the required roles.\n\n Grant the roles\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3. Click person_add **Grant access**.\n 4.\n In the **New principals** field, enter your user identifier.\n\n This is typically the email address for a Google Account.\n\n 5. In the **Select a role** list, select a role.\n 6. To grant additional roles, click add **Add\n another role** and add each additional role.\n 7. Click **Save**.\n\nCreate a cluster\n\nIn this section, you create a cluster that you can use in this tutorial.\nAlthough in a real-world scenario you would likely manage multiple\nclusters, to simplify this tutorial you only create and manage one cluster.\n\nTo create a cluster, complete the following steps:\n\n1. Enable the Google Kubernetes Engine API.\n\n [Go to GKE](https://console.cloud.google.com/apis/library/container.googleapis.com)\n2. In the Google Cloud console, go to the **Kubernetes Engine** page.\n\n [Go to Google Kubernetes Engine](https://console.cloud.google.com/kubernetes/list)\n3. Click *add_box* **Create**.\n\n4. In the **Autopilot** section, select **Configure**.\n\n5. In the **Cluster basics** section, enter `cs-cluster` in the **Name**\n field. Leave all other fields with their recommended defaults.\n\n6. Click **Create** . You are taken to the **Kubernetes clusters** page. It\n takes several minutes for your cluster to be created. When you see a green\n check mark in the **Status** column next to your cluster, it's ready.\n\nConfigure your cluster\n\nNow that you've created a cluster, you can configure Config Sync to sync\nto the configs in the [`config-sync-quickstart` directory](https://github.com/GoogleCloudPlatform/anthos-config-management-samples/tree/main/config-sync-quickstart)\nof the samples repository.\n\nTo configure Config Sync on the Google Cloud console, complete the\nfollowing steps:\n\n1. In the Google Cloud console, go to the **Config** page under the **Features** section.\n\n \u003cbr /\u003e\n\n [Go to Config](https://console.cloud.google.com/kubernetes/config_management)\n2. Click *add* **Install Config Sync**.\n3. Select the Config Sync version that you want to use.\n4. Under **Installation options** , select **Install Config Sync on individual clusters**.\n5. In the **Available clusters** table, select `cs-cluster` and click **Install Config Sync** . In the **Settings** tab, you should see the status for the `cs-cluster` as **Enabled** after a few minutes.\n6. On the **Config Sync dashboard** , click **Deploy cluster package**.\n7. In the **Select clusters for package deployment** table, select `cs-cluster` and then click **Continue**.\n8. Leave **Package hosted on Git** selected and then click **Continue**.\n9. In the **Package name** field, enter `sample-repository`.\n10. In the **Repository URL** field, enter `https://github.com/GoogleCloudPlatform/anthos-config-management-samples`.\n11. In the **Path** field, enter `config-sync-quickstart/multirepo/root`.\n12. Leave all other fields with their default values.\n13. Click **Deploy Package**.\n\n After a few minutes, you should see **Synced** in the **Sync status**\n column for `cs-cluster`.\n\nNow that Config Sync is synced to a repository, it continuously reconciles\nthe state of your clusters with the configs in the repository.\n\nView package details\n\nTo view all the objects that are managed by Config Sync, from the **Packages** tab, click `cs-cluster`\nand view the package details page. From this page, you get an overview of all\nresources synced per package and details like the resource type and which namespace\nthe resources is synced to.\n\nYou can navigate to the\n[/config-sync-quickstart/multirepo/](https://github.com/GoogleCloudPlatform/anthos-config-management-samples/tree/main/config-sync-quickstart/multirepo)\nfolder of the repository in GitHub to explore the configs\nthat caused these namespaces to be created. The `config-sync-quickstart` directory includes ClusterRole,\nCustomResourceDefinition, Rolebinding, Namespace, and RepoSync configs. It\nalso includes configurations for the Prometheus Operator for monitoring.\n\nClean up\n\n1. Go to the GKE menu in Google Cloud console.\n\n [Go to GKE](https://console.cloud.google.com/kubernetes/list)\n2. Next to the `cs-cluster`, click *more_vert* **Actions** , then click *delete* **Delete**.\n\n3. When prompted to confirm, click **Delete** again.\n\nWhat's next\n\n- Learn about [validating configs](/kubernetes-engine/enterprise/config-sync/docs/how-to/validating-configs)."]]