apiVersion:v1items:-apiVersion:configsync.gke.io/v1beta1kind:RootSyncmetadata:annotations:configmanagement.gke.io/managed-by-hub:"true"configmanagement.gke.io/update-time:"1644945169"creationTimestamp:"2022-02-15T17:12:52Z"generation:1name:root-syncnamespace:config-management-systemresourceVersion:"211980457"uid:aa30a94b-2825-4590-ad30-5af848403502spec:git:auth:nonebranch:maindir:/quickstart/config-syncperiod:15srepo:https://github.com/GoogleCloudPlatform/anthos-config-management-samplesrevision:HEADsecretRef:{}override:resources:-containerName:"git-sync"memoryLimit:"400Mi"sourceFormat:unstructured# Remainder of RootSync omitted
[[["易于理解","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,["# Configure Config Sync with kubectl commands\n\nThis page explains how to configure Config Sync using `kubectl` commands\nafter you've\n[installed Config Sync using the Google Cloud console or Google Cloud CLI](/kubernetes-engine/enterprise/config-sync/docs/how-to/installing-config-sync).\n\nWhile you can make many configuration changes using the console or CLI, you\nneed to use `kubectl` commands to\n[override some Config Sync defaults](/kubernetes-engine/enterprise/config-sync/docs/reference/rootsync-reposync-fields#override-resources), to control SSL certificate\nverification, and to use a certificate authority.\n\nCreate and edit the RootSync configuration file\n-----------------------------------------------\n\nTo configure Config Sync using `kubectl` commands, you edit a\n[RootSync object](/kubernetes-engine/enterprise/config-sync/docs/reference/rootsync-reposync-fields) by creating\na YAML file.\n\nWhen you install Config Sync using the Google Cloud console or\nGoogle Cloud CLI, Config Sync automatically creates a RootSync object named\n`root-sync`. This object contains the most recent configuration information for\nConfig Sync. Whenever you make a change in the Google Cloud console or\nGoogle Cloud CLI, `root-sync` is updated.\n\n### Learn about the fields you can edit using `kubectl`\n\nYou can make advanced changes to `root-sync` using `kubectl` commands for the\nfields not supported in the Google Cloud console or Google Cloud CLI. If you want to\ncreate and then update RootSync or RepoSync objects directly using `kubectl`\ncommands, see\n[RootSync and RepoSync fields](/kubernetes-engine/enterprise/config-sync/docs/reference/rootsync-reposync-fields).\n\nBefore you make any changes to the YAML file that you create in the following\nsection, familiarize yourself with the following table. This table lists the\nfields that you can edit and add. If you edit fields not listed in this table,\nConfig Sync automatically reverts changes back to the values you set when you\nlast configured Config Sync in the Google Cloud console or Google Cloud CLI.\n\n| **Note:** Changes to fields that aren't in the preceding table are only reverted for the RootSync object that Config Sync creates when you install using the Google Cloud console or Google Cloud CLI. If you manually created a RootSync object named `root-sync` using an alternate installation method, you can edit all of the fields listed in [RootSync and RepoSync fields](/kubernetes-engine/enterprise/config-sync/docs/reference/rootsync-reposync-fields).\n\n### Create the file\n\nTo create and edit a configuration file for `root-sync`, complete the\nfollowing steps:\n\n1. To make sure that you're retrieving the configuration information for the\n correct cluster, configure `kubectl` command-line access:\n\n gcloud container clusters get-credentials \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e \\\n --zone \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e \\\n --project \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of the cluster that has the Config Sync configuration that you want to change\n - \u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e: the zone that you created your cluster in\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID\n2. Copy the configuration information from the RootSync object that\n Config Sync created into a YAML file:\n\n kubectl get rootsync root-sync -n config-management-system -o yaml \u003e\n \u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e.yaml\n\n Replace \u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e with a name for your configuration\n file.\n3. Open the YAML file that you created and make the required configuration\n changes. For example, to override the memory limit of the `git-sync`\n container, add the following fields in bold:\n\n apiVersion: v1\n items:\n - apiVersion: configsync.gke.io/v1beta1\n kind: RootSync\n metadata:\n annotations:\n configmanagement.gke.io/managed-by-hub: \"true\"\n configmanagement.gke.io/update-time: \"1644945169\"\n creationTimestamp: \"2022-02-15T17:12:52Z\"\n generation: 1\n name: root-sync\n namespace: config-management-system\n resourceVersion: \"211980457\"\n uid: aa30a94b-2825-4590-ad30-5af848403502\n spec:\n git:\n auth: none\n branch: main\n dir: /quickstart/config-sync\n period: 15s\n repo: https://github.com/GoogleCloudPlatform/anthos-config-management-samples\n revision: HEAD\n secretRef: {}\n override:\n resources:\n - containerName: \"git-sync\"\n memoryLimit: \"400Mi\"\n sourceFormat: unstructured\n # Remainder of RootSync omitted\n\n4. Apply the changes to the YAML file:\n\n kubectl apply -f \u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e.yaml\n\n5. To verify that Config Sync has applied your changes, view the RootSync\n object:\n\n kubectl describe rootsync root-sync -n config-management-system\n\n6. To verify that your changes haven't introduced any errors, use the\n [`nomos status`](/kubernetes-engine/enterprise/config-sync/docs/how-to/nomos-command#status-install) command:\n\n nomos status\n\n### Configure Certificate Authority\n\nFor servers configured with certificates from a Certificate Authority (CA)\nthat is not already trusted, Config Sync can be configured to use a CA\ncertificate to verify HTTPS connections to the server. This is supported for Git,\nHelm, or OCI servers. The CA certificate\nmust include full SSL certificates (Root/Intermediate/Leaf).\nIf your server is already using a trusted CA or you are not connecting over HTTPS,\nyou can skip this step and leave `caCertSecretRef` unset. \n\n### `RootSync`\n\n1. Fetch the CA certificate which was used to issue the certificate for your\n Git server and save it to a file.\n\n2. For `RootSync` objects, the Secret must be created in the `config-management-system`\n namespace. For example:\n\n ```\n kubectl create secret generic ROOT_CA_CERT_SECRET_NAME \n\n --namespace=config-management-system \n\n --from-file=cert=/path/to/CA_CERT_FILE\n ```\n\n \u003cbr /\u003e\n\n3. When you configure the `RootSync` object,\n set the value of the `caCertSecretRef.name` field in the `RootSync`\n object to \u003cvar translate=\"no\"\u003eROOT_CA_CERT_SECRET_NAME\u003c/var\u003e.\n\n### `RepoSync`\n\n1. Fetch the CA certificate which was used to issue the certificate for your\n Git server and save it to a file.\n\n2. For `RepoSync` objects, the Secret must be created in the same namespace as the\n RepoSync. For example:\n\n ```\n kubectl create secret generic NAMESPACE_CA_CERT_SECRET_NAME \n\n --namespace=REPO_SYNC_NAMESPACE \n\n --from-file=cert=/path/to/CA_CERT_FILE\n ```\n\n \u003cbr /\u003e\n\n3. When you [configure the `RepoSync`](/kubernetes-engine/enterprise/config-sync/docs/how-to/multiple-repositories#manage-namespace-repos-in-namespace),\n set the value of the `caCertSecretRef.name` field in the `RepoSync`\n object to \u003cvar translate=\"no\"\u003eNAMESPACE_CA_CERT_SECRET_NAME\u003c/var\u003e.\n\nRemove the RootSync object\n--------------------------\n\nTo delete `root-sync`, run the following command: \n\n kubectl delete -f \u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e\n\nReplace \u003cvar translate=\"no\"\u003eFILE_NAME\u003c/var\u003e with the name of your RootSync\nconfiguration file. For example, `root-sync.yaml`.\n\nDeleting a RootSync or RepoSync object does not clean up Config Sync\nannotations and labels. To clean up any managed resources, sync from an empty\nGit directory.\n\nWhat's next\n-----------\n\n- Learn more about the [RootSync and RepoSync fields](/kubernetes-engine/enterprise/config-sync/docs/reference/rootsync-reposync-fields).\n- Discover how to [Monitor RootSync and RepoSync objects](/kubernetes-engine/enterprise/config-sync/docs/how-to/monitor-rootsync-reposync)."]]