[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-01。"],[],[],null,["# Add configs to a source of truth\n\nThis page explains how to add and organize configurations stored in a\n.\n\nAbout configs\n-------------\n\n[Config Sync](/kubernetes-engine/enterprise/config-sync/docs/config-sync-overview) is designed for cluster\noperators who manage many clusters. You can ensure that your clusters meet\nbusiness and compliance standards by letting Config Sync manage namespaces,\nRoles, RoleBindings, ResourceQuotas, and other important Kubernetes objects,\nacross your fleet.\n\nWhen Config Sync manages these resources, it keeps your enrolled clusters in\nsync using *configs* . A config is a YAML or JSON file that is stored in a source\nof truth. Config Sync supports Git repositories, OCI images, and Helm charts\nas the source of truth. Configs\ncontain the same type of configuration details that you can\nmanually apply to a cluster using the `kubectl apply` command. You can create a\nconfig for any Kubernetes object that can exist in a cluster. However, some\nKubernetes objects, such as Secrets, contain sensitive information that might be\ninappropriate to store in a source of truth. Use your judgment when considering\nwhether to manage these types of objects using Config Sync.\n\nYou can also use Config Sync with\n[Config Connector](/config-connector/docs/overview) to sync configs for\n[Google Cloud resources](/config-connector/docs/reference/resources). To learn\nmore about working with Config Connector, see\n[managing Google Cloud resources using Config Connector](/config-connector/docs/how-to/managing-deleting-resources).\nYou can also simplify the installation of Config Sync and Config Connector\nby [setting up Config Controller](/kubernetes-engine/enterprise/config-controller/docs/setup).\n\nLimitations\n-----------\n\n- Some Kubernetes resources contain immutable fields, like Pod selectors in a\n Deployment object. You can't change any immutable field in a config by\n changing the value in the source of truth. Attempting such a change causes a\n `KNV2009` error. If you need to change an immutable field, delete the object\n from your source of truth, wait for Config Sync to delete the object\n from the cluster, and then re-create the object in your source of truth with\n your updates.\n\n- If you use [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules),\n you must\n [grant Config Sync access](/kubernetes-engine/enterprise/config-sync/docs/how-to/installing-config-sync#git-creds-secret)\n to all repositories, including any submodules.\n\n- You can't use Config Sync to directly manage built-in Kubernetes\n ClusterRoles. GKE comes with some built-in [user facing\n roles](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles),\n such as `cluster-admin`, `admin`, `edit`, and `view`. You can't directly\n manage these ClusterRoles with Config Sync, otherwise Config Sync\n fights with GKE. To add permissions to the built-in\n ClusterRoles, use\n [role aggregation](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#aggregated-clusterroles)\n to modify them indirectly. To modify the roles, create a uniquely named\n ClusterRole in your source of truth with the appropriate annotations.\n\nSelect how to organize your configs\n-----------------------------------\n\nConfig Sync uses a source of truth for config storage and version control.\nThere are two different formats you can choose for your source of truth;\n[unstructured](/kubernetes-engine/enterprise/config-sync/docs/how-to/unstructured-repo) and\n[hierarchical](/kubernetes-engine/enterprise/config-sync/docs/concepts/hierarchical-repo).\n\nThe unstructured source format lets you organize configs in whatever way is most\nconvenient. This format can be especially useful if you are organizing or\ngenerating configs using a tool such as [Kustomize](https://kustomize.io/),\n[kpt](https://kpt.dev), or\n[Helm](https://helm.sh/). For an example of how you might organize\nyour configs, see\n[Example format for an unstructured repository](/kubernetes-engine/enterprise/config-sync/docs/how-to/unstructured-repo#example).\n\nThe hierarchical, or structured, source format separates configs into distinct\ncategories to help you organize the configs. The categories are system\nconfiguration, cluster metadata, cluster-level configuration, and namespace\nconfiguration. For more information about the hierarchical source format, see\n[Structure of the hierarchical repo](/kubernetes-engine/enterprise/config-sync/docs/concepts/hierarchical-repo#structure_of_the_repo).\n\nUnstructured is the recommended format for most users. In addition,\nwhen you configure [RepoSync objects](/kubernetes-engine/enterprise/config-sync/docs/reference/rootsync-reposync-fields),\nyou must use the unstructured source format.\n\n### Supported features for unstructured and hierarchical formats\n\nThe following table highlights the differences between the unstructured and\nhierarchical formats:\n\nWhen to add configs to the source\n---------------------------------\n\nIf you are creating an unstructured format, you can start adding configs to\nit as soon as it's created. If you are creating a hierarchical format, use\nthe [`nomos init`](/kubernetes-engine/enterprise/config-sync/docs/how-to/nomos-command#init) command to\ninitialize the source of truth, or create the directory structure manually.\n\nEmpty directories cannot be committed to a Git repository, so before you\nconfigure Config Sync, you must create configs and\nadd them into your repository.\n\nAfter you have created the source of truth and added configs to it, use the\n[`nomos vet`](/kubernetes-engine/enterprise/config-sync/docs/how-to/nomos-command#vet) command to verify the\nstructure of your source of truth and check the syntax and validity of your\nconfigs.\n\nConfigure Config Sync to read from the source of truth\n------------------------------------------------------\n\nAfter you've created a source of truth and placed your configs into it, you can\nconfigure Config Sync to read from the source. After you've completed\nthis step, Config Sync syncs configs from your source of truth to your clusters.\n\nYou configure the location of the source of truth when you\n[install Config Sync](/kubernetes-engine/enterprise/config-sync/docs/how-to/installing-config-sync#configuring-config-sync),\nand you can edit Config Sync's configuration later. In addition to the\nlocation of the source of truth, you can specify a branch or subdirectory to\nwatch, if the source has contents other than configs.\n\nIf you are using a hierarchical format, and\n[installing Config Sync manually with `kubectl`](/kubernetes-engine/enterprise/config-sync/docs/how-to/installing-kubectl),\ndon't place the Operator's config in the `system/`\ndirectory, or any of the other reserved directories such as `cluster/` or\n`namespaces/`. Placing the config in one of the reserved directories causes\n`nomos vet` to fail and logs an error such as\n[KNV1033: IllegalSystemResourcePlacementError](/kubernetes-engine/enterprise/config-sync/docs/reference/errors#knv1033),\n[KNV1038: IllegalKindInNamespacesError](/kubernetes-engine/enterprise/config-sync/docs/reference/errors#knv1038),\nor [KNV1039: IllegalKindInClusterError](/kubernetes-engine/enterprise/config-sync/docs/reference/errors#knv1039).\n\nYou can grant people access to a given product team's deployment source of truth.\nHowever, when you grant a person access to a deployment source of truth, that\nperson is also granted the same RBAC as the reconciler running for that source of\ntruth.\n\nTo configure authentication and authorization between Config Sync and\nthe source of truth, see the installation step about\n[configuring the `git-creds` Secret](/kubernetes-engine/enterprise/config-sync/docs/how-to/installing-config-sync#git-creds-secret).\n\n### Ignore object mutations\n\nIf you don't want Config Sync to maintain the state of the object in the\ncluster after it exists, you can add the\n`client.lifecycle.config.k8s.io/mutation: ignore` annotation to the object that\nyou want Config Sync to ignore mutations in.\n\nTo use the annotation, you must enable the\n[RootSync and RepoSync APIs](/kubernetes-engine/enterprise/config-sync/docs/reference/rootsync-reposync-fields).\n\nThe following example shows you how to add the annotation to an object: \n\n metadata:\n annotations:\n client.lifecycle.config.k8s.io/mutation: ignore\n\nYou cannot manually modify this annotation on managed objects in the cluster.\n\nWhat's next\n-----------\n\n- Learn how to [manage namespaces and namespace-scoped objects](/kubernetes-engine/enterprise/config-sync/docs/how-to/namespace-scoped-objects).\n- To learn how to publish an OCI image, see [Sync OCI artifacts from Artifact Registry](/kubernetes-engine/enterprise/config-sync/docs/how-to/sync-oci-artifacts-from-artifact-registry).\n- To learn how to sync from a Helm chart, see [Sync Helm charts from Artifact Registry](/kubernetes-engine/enterprise/config-sync/docs/how-to/sync-helm-charts-from-artifact-registry)."]]