ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

Argo CD 核心配置 argocd-cm.yaml 全参数详解与实战指南

Argo CD 核心配置 argocd-cm.yaml 全参数详解与实战指南 Argo CD 核心配置 argocd-cm.yaml 全参数详解与实战指南【免费下载链接】argo-cdDeclarative Continuous Deployment for Kubernetes项目地址: https://gitcode.com/GitHub_Trending/ar/argo-cdArgo CD 的绝大部分系统级行为——从外部访问地址、SSO 登录、资源差异比较、健康检查脚本到 UI 外观、同步超时与 Webhook 刷新策略——都由argocd-cmConfigMap 集中控制。本文以仓库中 docs/operator-manual/argocd-cm.yaml 示例为骨架逐项拆解每个配置键的语义、默认值与底层实现对应 util/settings/settings.go 中的键名常量与解析逻辑帮助运维人员直接复制、裁剪并落地到自己的集群中。一、argocd-cm 是什么argocd-cm是 Argo CD 安装包内置的一个 Kubernetes ConfigMap声明在 manifests/base/config/argocd-cm.yaml 中默认位于argocd命名空间apiVersion: v1 kind: ConfigMap metadata: name: argocd-cm namespace: argocd labels: app.kubernetes.io/name: argocd-cm app.kubernetes.io/part-of: argocd data: # 这里写入全部配置项所有配置都以data下的键值对形式存在。其中“布尔”键一律使用字符串true/false需要多行结构化内容的键如dex.config、resource.exclusions则使用 YAML 块标量|。从源码结构看util/settings/settings.go 中集中定义了所有合法键名的常量如settingURLKey url、statusBadgeEnabledKey statusbadge.enabled并由SettingsManager通过 informer 监听该 ConfigMap任何变更都会被ResyncInformers()触发并推送给各组件。因此修改argocd-cm通常无需重启任何组件即可动态生效唯一的例外是timeout.reconciliation详见下文该小节。官方完整示例即 docs/operator-manual/argocd-cm.yaml本文下述配置块即来自该文件并做了逐项注释。二、外部访问地址与状态徽章2.1 url 与 additionalUrls# Argo CD 对外暴露的基础 URL可选。配置 SSO 时必填。 url: https://argo-cd-demo.argoproj.io # 额外的对外 URL 列表可选适用于多域名访问场景 additionalUrls: | - https://argo-cd-demo2.argoproj.iourl用户访问 Argo CD 的外部地址。源码中对应ArgoCDSettings.URL字段util/settings/settings.go注释明确指出“省略该值将禁用 SSO”。additionalUrls当 Argo CD 可从多个域名访问时配置该列表可保证各域名下的 SSO 回调、OIDC 校验等正常工作。2.2 状态徽章status badge# 启用应用状态徽章功能 statusbadge.enabled: true # 覆盖状态徽章使用的 Argo CD 根 URL必须包含末尾斜杠 # 原示例 URL 中的 statusbadge.url 会被替换为实际地址 # 例如应用 myapp 的徽章地址为 # statusbadge.urlapi/badge?namemyapprevisiontrue statusbadge.url: https://cd-status.apps.argoproj.io/statusbadge.url仅覆盖徽章图片的域名前缀其余路径部分保持默认。若不设置则使用url的值。三、用户、会话与匿名访问# 启用匿名用户访问。匿名用户获得 argocd-rbac-cm.yaml 中为默认角色配置的权限 users.anonymous.enabled: true # 指定 Token 的过期时长 users.session.duration: 24h # 指定本地用户密码的正则表达式约束 passwordPattern: ^.{8,32}$users.anonymous.enabled对应键anonymousUserEnabledKey匿名用户的权限由 docs/operator-manual/argocd-rbac-cm.yaml 中的默认角色决定。users.session.duration会话/JWT Token 的有效期示例为 24 小时支持60s、15m等 Go duration 格式。passwordPattern本地账号密码必须匹配的正则示例要求 8~32 位任意字符对应settingsPasswordPatternKey。四、统计、帮助与二进制下载# 启用 Google Analytics 追踪填写 Tracking ID ga.trackingid: G-XXXXXXXXXX # 设为 false 表示不将用户 ID 哈希后再上报默认会哈希 ga.anonymizeusers: false # 帮助页面中“获取帮助”的聊天入口 URL通常是 Slack 频道 help.chatUrl: https://mycorp.slack.com/argo-cd # 帮助入口的显示文本默认 Chat now! help.chatText: Chat now! # 帮助页面中额外提供的 Argo CD 二进制下载地址默认已内置当前平台的 Linux 二进制。 # 提供后帮助页面会为不同 OS/架构显示额外的下载按钮。 help.download.linux-amd64: path-or-url-to-download help.download.linux-arm64: path-or-url-to-download help.download.linux-ppc64le: path-or-url-to-download help.download.linux-s390x: path-or-url-to-download help.download.darwin-amd64: path-or-url-to-download help.download.darwin-arm64: path-or-url-to-download help.download.windows-amd64: path-or-url-to-downloadga.anonymizeusers对应ArgoCDSettings.GoogleAnalytics.AnonymizeUsers默认开启哈希。help.download.*对应settingsBinaryUrlsKey help.download前缀Help.BinaryURLs以 map 形式保存util/settings/settings.go。五、SSODex 与 OIDC5.1 dex.configdex.config: | # 可选配置 Dex 的存储后端用于持久化会话与签名密钥 storage: type: kubernetes config: inCluster: true web: tlsMinVersion: 1.2 connectors: # GitHub 连接器示例 - type: github id: github name: GitHub config: clientID: aabbccddeeff00112233 clientSecret: $dex.github.clientSecret orgs: - name: your-github-org teams: - red-team # 可选的静态客户端配置供 Argo Workflow 等其他服务复用 Dex # staticClients: # - id: argo-workflow # name: Argo Workflow # redirectURIs: # - https://argo/oauth2/callback # secret: $secretReferencedex.config是一段完整的 Dex 配置 YAML。注意clientSecret: $dex.github.clientSecret这种$引用写法——它会从argocd-secret中按 key 读取真实密钥避免把敏感信息写进 ConfigMap。完整连接器清单可参见 Dex 官方文档仓库内相关说明见 docs/operator-manual/user-management/index.md。5.2 dex.auth.connectorId# 默认的 Dex 连接器 ID用于强制 Dex 认证端点做 HTTP 重定向。 # 当 Dex 同时配置了“人类用户”和“机器账号”两个连接器时很有用。 dex.auth.connectorId: github对应源码键settingDexAuthConnectorIDKey dex.auth.connectorId。5.3 oidc.config# 作为 Dex 替代方案的 OIDC 配置可选 oidc.config: | name: Okta issuer: https://dev-123456.oktapreview.com clientID: aaaabbbbccccddddeee clientSecret: $oidc.okta.clientSecret # 可选请求的 OIDC scope。缺省为 [openid, profile, email, groups] requestedScopes: [openid, profile, email] # 可选在 ID Token 中请求的 OIDC claims requestedIDTokenClaims: {groups: {essential: true}}源码中OIDCConfig结构util/settings/settings.go还支持cliClientID、enableUserInfoGroups、userInfoBaseURL、userInfoPath、logoutURL、rootCA、enablePKCEAuthentication、domainHint、azure等高级字段均可按需补充。5.4 oidc.tls.insecure.skip.verify# 校验 OIDC 提供方外部或内置 DexToken 时是否跳过证书校验。 # 设为 true 会让 JWT 校验在提供方证书无效时仍然通过 # 仅在完全理解风险的前提下才应开启。默认 false。 oidc.tls.insecure.skip.verify: false六、资源差异比较与自定义resource.customizations6.1 ignoreDifferences忽略期望/实际状态差异# 针对特定 group_kind 的差异忽略规则键格式为 # resource.customizations.ignoreDifferences.group_kind resource.customizations.ignoreDifferences.admissionregistration.k8s.io_MutatingWebhookConfiguration: | jsonPointers: - /webhooks/0/clientConfig/caBundle jqPathExpressions: - .webhooks[0].clientConfig.caBundle managedFieldsManagers: - kube-controller-manager # 对所有资源GK生效的差异忽略规则 resource.customizations.ignoreDifferences.all: | managedFieldsManagers: - kube-controller-manager jsonPointers: - /spec/replicas支持的三种匹配方式jsonPointersRFC 6902 JSON 指针如/metadata/annotations/autoscaling.alpha.kubernetes.io~1behavior~1转义/~0转义~jqPathExpressionsjq 风格路径表达式managedFieldsManagers按 field manager 名忽略差异。6.2 ignoreResourceUpdates减少不必要的重新协调# 是否启用 ignoreResourceUpdates 规则。设为 false 时规则不生效 # 资源的所有更新都会写入集群缓存。默认 true。 resource.ignoreResourceUpdatesEnabled: true # 对所有资源生效的“更新忽略”规则 resource.customizations.ignoreResourceUpdates.all: | jsonPointers: - /metadata/resourceVersion # 按 group_kind 拆分的“更新忽略”规则 resource.customizations.ignoreResourceUpdates.argoproj.io_Application: | jsonPointers: - /status # jsonPointers 与 jqPathExpressions 可以同时指定 resource.customizations.ignoreResourceUpdates.autoscaling_HorizontalPodAutoscaler: | jqPathExpressions: - .metadata.annotations.autoscaling.alpha.kubernetes.io/behavior - .metadata.annotations.autoscaling.alpha.kubernetes.io/conditions - .metadata.annotations.autoscaling.alpha.kubernetes.io/metrics - .metadata.annotations.autoscaling.alpha.kubernetes.io/current-metrics jsonPointers: - /metadata/annotations/autoscaling.alpha.kubernetes.io~1behavior - /metadata/annotations/autoscaling.alpha.kubernetes.io~1conditions - /metadata/annotations/autoscaling.alpha.kubernetes.io~1metrics - /metadata/annotations/autoscaling.alpha.kubernetes.io~1current-metrics该机制对应源码常量resourceIgnoreResourceUpdatesEnabledKey。值得注意的是安装包的默认 ConfigMap manifests/base/config/argocd-cm.yaml 已内置了一批开箱即用的规则忽略所有资源的/status变化健康状态变化仍会触发更新、忽略 HPA 的 legacy annotations、ReplicaSet的扩缩容 annotations、EndpointSlice/Endpoints的元数据变化等——生产环境建议保留这些默认规则再按需叠加自己的规则。6.3 health自定义健康检查 Lua 脚本resource.customizations.health.certmanager.k8s.io_Certificate: | hs {} if obj.status ~ nil then if obj.status.conditions ~ nil then for i, condition in ipairs(obj.status.conditions) do if condition.type Ready and condition.status False then hs.status Degraded hs.message condition.message return hs end if condition.type Ready and condition.status True then hs.status Healthy hs.message condition.message return hs end end end end hs.status Progressing hs.message Waiting for certificate return hs resource.customizations.health.cert-manager.io_Certificate: | # 内容同上针对新版 cert-manager 的 API group脚本输入为资源对象obj输出hs.status可取Healthy/Progressing/Degraded/Suspended等并可用hs.message给出原因。上例同时覆盖了新旧两代 cert-manager API groupcertmanager.k8s.io与cert-manager.io。6.4 actions自定义资源动作resource.customizations.actions.apps_Deployment: | # Lua 脚本声明该资源上可用的自定义动作 discovery.lua: | actions {} actions[restart] {} return actions definitions: - name: restart # Lua 脚本对 obj 进行修改 action.lua: | local os require(os) if obj.spec.template.metadata nil then obj.spec.template.metadata {} end if obj.spec.template.metadata.annotations nil then obj.spec.template.metadata.annotations {} end obj.spec.template.metadata.annotations[kubectl.kubernetes.io/restartedAt] os.date(!%Y-%m-%dT%XZ) return objdiscovery.lua负责在 UI 中列出可用动作action.lua负责修改对象并返回。上例为 Deployment 增加了一个等效于kubectl rollout restart的restart动作。更多内置动作可参考 docs/operator-manual/resource_actions_builtin.md 与 docs/operator-manual/resource_actions.md。七、资源收录、排除与观察范围7.1 exclusions / inclusions / selectors# 完全忽略整类资源 group/kind可选。 # 排除高流量资源可显著提升性能与内存占用并降低对 Kubernetes API Server 的压力。 # 值为 glob* 匹配所有值省略 groups/kinds/clusters 表示匹配全部。 # 注意events.k8s.io 与 metrics.k8s.io 默认已被排除。 resource.exclusions: | - apiGroups: - repositories.stash.appscode.com kinds: - Snapshot clusters: - *.local # 默认收录所有 group/kindresource.inclusions 用于自定义收录清单 resource.inclusions: | - apiGroups: - repositories.stash.appscode.com kinds: - Snapshot clusters: - *.local # 默认观察某 group/kind 的全部对象resource.selectors 用标签选择器收窄观察范围。 # 选择器以字符串形式直接传给 Kubernetes API Server。 resource.selectors: | - apiGroups: - kinds: - Pod clusters: - *.local selector: !argocd.argoproj.io/instance生产实践建议exclusions优先采用 manifests/base/config/argocd-cm.yaml 中的内置默认集Endpoints/EndpointSlice、coordination.k8s.io 的 Lease、各类 authn/authz review 资源、CSR、Cilium/Kyverno 中间产物等它们都是“高流量、高变更且几乎不会出现在 Git 声明中”的元数据对象。7.2 敏感信息掩码与自定义标签# 在 UI/CLI 中对 Secret 资源上的这些注解值做掩码逗号分隔 resource.sensitive.mask.annotations: openshift.io/token-secret.value,api-key # 在 UI 中展示的 metadata.labels 键逗号分隔 resource.customLabels: tier7.3 事件标签过滤# 当 Application 及其 AppProject 上存在这些 label 键时会将对应标签附加到 # Application 生成的 Kubernetes 事件上支持通配符。 # 若 Application 与 AppProject 标签冲突以 Application 的值为准。 resource.includeEventLabelKeys: team,env* # 需要从事件中排除的 label 键支持通配符 resource.excludeEventLabelKeys: environment,bu八、比较选项与 RBAC 感知resource.compareoptions: | # 为 true 时忽略 RBAC 资源中聚合角色aggregated roles造成的差异 ignoreAggregatedRoles: true # 禁用指定资源类型的 status 字段 diff # crd - CustomResourceDefinitions # all - 所有资源默认 # none - 不忽略 ignoreResourceStatusField: all # 只观察 controller 有权限 list 的资源。 # 取值可为空禁用、normal 或 strict默认空禁用。 resource.respectRBAC: normalignoreResourceStatusField的取值在源码中对应IgnoreStatus类型util/settings/settings.gorespectRBAC的normal/strict则在RespectRBAC()函数中解析util/settings/settings.go。九、配置管理工具kustomize、Jsonnet、Helm9.1 启用/禁用工具# 控制是否启用对应配置管理工具缺省均为 true kustomize.enable: true jsonnet.enable: true helm.enable: true源码通过sourceTypeToEnableGenerationKey映射util/settings/settings.go将kustomize.enable、helm.enable、jsonnet.enable分别绑定到 Kustomize、Helm、Directory(Jsonnet) 三类 Application source 类型。9.2 Kustomize 构建参数与多版本# 传给 kustomize build 的构建参数可选 kustomize.buildOptions: --load_restrictor none # 按版本指定二进制路径与构建参数推荐的新式写法 kustomize.path.v3.9.1: /custom-tools/kustomize_3_9 kustomize.buildOptions.v3.9.1: --enable_kyaml true # 按版本指定二进制路径旧式写法已弃用仅保持向后兼容 kustomize.version.v3.5.1: /custom-tools/kustomize_3_5_1 kustomize.version.v3.5.4: /custom-tools/kustomize_3_5_4源码中kustomize.version与kustomize.path分别对应常量kustomizeVersionKeyPrefix/kustomizePathPrefixKeyutil/settings/settings.go。旧式kustomize.version.vX.Y.Z已在GetKustomizeBinaryPath()中标记为 deprecated会打印告警日志但为兼容仍被支持新部署请使用kustomize.path.version。Application 侧通过spec.source.kustomize.version选择对应版本未注册的版本会返回KustomizeVersionNotRegisteredError。9.3 Helm values 文件协议# 允许的远程 values 文件 scheme逗号分隔http/https 默认允许。 # 设为空值可完全禁用远程 values 文件。 helm.valuesFileSchemes: http, https十、应用跟踪与同步行为10.1 实例标签键与资源跟踪方式# Argo CD 注入应用名作为跟踪标签的 label 键名可选。 # 跟踪标签用于判断 prune 时需要删除哪些资源。 # 缺省为 app.kubernetes.io/instance。 application.instanceLabelKey: mycompany.com/appname # 传播到应用 Pod 视图的节点标签逗号分隔可选 application.allowedNodeLabels: topology.kubernetes.io/zone,node.kubernetes.io/instance-type # 资源跟踪方式可选值 # - annotation 用注解承载附加元数据做跟踪不再使用标签 # - annotationlabel 注解跟踪 额外用应用名打标签 # - label 用 application.instanceLabelKey 标签跟踪 application.resourceTrackingMethod: annotation对应源码键settingsApplicationInstanceLabelKey、allowedNodeLabelsKey、settingsResourceTrackingMethodKeyutil/settings/settings.go。10.2 安装实例 ID# 可选的安装 ID允许在同一集群中运行多个 Argo CD 安装实例 installationID: my-unique-id10.3 同步身份模拟与修订覆盖权限# 启用后应用同步可通过 impersonation 使用自定义 ServiceAccount # 使同步权限与 control-plane ServiceAccount 解耦。默认 false。 application.sync.impersonation.enabled: false # 启用模拟后是否强制要求必须配置 ServiceAccount。 # 为 false 时若找不到匹配的 ServiceAccount 则回退使用 controller 的 # ServiceAccount。出于安全考虑默认 true仅在完全信任所有应用时才关闭。 application.sync.impersonation.enforced: true # 为 true 时同步时传入与 Application 中不同的 revision 需要 override 权限 # 当前默认false仅需 sync 权限。官方强烈建议设为 true # 下一个大版本将把默认值改为 true。 application.sync.requireOverridePrivilegeForRevisionSync: true相关键名见 util/settings/settings.go身份模拟的完整使用流程见 docs/operator-manual/app-sync-using-impersonation.md。十一、账户与管理员# 禁用 admin 用户。admin 默认启用 admin.enabled: false # 新增一个本地用户并赋予 apiKey 与 login 能力 # apiKey - 允许生成 API 密钥 # login - 允许通过 UI 登录 accounts.alice: apiKey, login # 禁用该用户。用户默认启用 accounts.alice.enabled: falseaccounts.name与accounts.name.enabled由 util/settings/accounts.go 解析构成 Argo CD 本地用户体系的基础。十二、UI 定制# 可选的自定义 CSS运行时加载。 # 本地 CSS文件需挂载到 argocd-server 容器的 /shared/app 子目录下 #如 /shared/app/custom路径相对 /shared/app 填写 # 否则浏览器可能因 incorrect MIME type 无法导入。 # 远程 CSS支持通过完整 URL 加载。 ui.cssurl: ./custom/my-styles.css # 可选的在每个 UI 页面顶部展示的横幅内容。 # 每次更新该值都会清除用户 localStorage 中“永久隐藏横幅”的设置。 ui.bannercontent: Hello there! # 横幅链接可选。设置后整个横幅文本变成链接。 # 可以只有 bannercontent 而没有 bannerurl反之不行。 ui.bannerurl: https://argoproj.github.io # 取消注释可让横幅不显示关闭按钮成为永久横幅仅一行文本 # ui.bannerpermanent: true # 横幅位置可选 top、bottom、both缺省 top # ui.bannerposition: bottom # 设为 true 禁用 UI 中的受管资源Resources视图。 # 禁用后导航栏隐藏 Resources 项/resources 页面提示功能未启用。默认 false。 ui.view.resources.disabled: false # SSO 登录按钮文字的覆盖可选 # ui.loginButtonText: SSO Login配套的自定义样式指南见 docs/operator-manual/custom-styles.md 与 docs/operator-manual/ui-customization.md。十三、Deep Links 与扩展后端13.1 project / application / resource 三级 Deep Links# 项目级链接示例 project.links: | - url: https://myaudit-system.com?project{{.metadata.name}} title: Audit description: system audit logs icon.class: fa-book # 应用级链接示例 application.links: | # URL 模板使用 pkg.go.dev/text/template 求值 - url: https://mycompany.splunk.com?search{{.spec.destination.namespace}} title: Splunk # 条件显示使用 github.com/expr-lang/expr 求值条件 - url: https://mycompany.splunk.com?search{{.spec.destination.namespace}} title: Splunk if: spec.project default # 引用注解中的主机名 - url: https://{{.metadata.annotations.splunkhost}}?search{{.spec.destination.namespace}} title: Splunk if: metadata.annotations.splunkhost # 资源级链接示例 resource.links: | - url: https://mycompany.splunk.com?search{{.metadata.namespace}} title: Splunk if: kind Pod || kind Deployment完整语法与示例见 docs/operator-manual/deep_links.md。13.2 扩展后端extension.configextension.config: | extensions: # name 定义扩展路由注册的端点必填 - name: some-extension backend: # 到扩展服务器的拨号超时。可选默认 2s connectionTimeout: 2s # 活跃连接之间的 keep-alive 探测间隔。可选默认 15s keepAlive: 15s # 空闲keep-alive连接的关闭等待时长。可选默认 60s idleConnectionTimeout: 60s # API server 与扩展服务器之间的最大空闲连接数。可选默认 30 maxIdleConnections: 30 services: # 扩展后端地址必填 - url: http://httpbin.org # 指定后请求转发要求应用的 destination 名称/服务器与此匹配。 # 仅一个 service 时可省略多个 service 时必填。 cluster: name: some-cluster server: https://some-cluster对应源码中的ExtensionConfig字段util/settings/settings.go各超时参数均有明确默认值。十四、Webhook 与执行器# 可发送到 Webhook 服务器的最大 payload 大小MB webhook.maxPayloadSizeMB: 50 # 是否启用 UI 的 exec 功能默认禁用 exec.enabled: false # 允许用于 exec 的 shell 列表及尝试顺序 exec.shells: bash,sh,powershell,cmdwebhook.maxPayloadSizeMB对应常量settingsWebhookMaxPayloadSizeMB默认值为 50MBdefaultMaxWebhookPayloadSize。exec相关能力可参考 docs/operator-manual/web_based_terminal.md。十五、协调超时与刷新抖动# 应用协调超时Argo 尝试发现仓库中是否有新版本 manifests 的间隔。 # 设为 0 则禁用超时协调仍受其他触发机制驱动。默认 2 分钟并附加 jitter。 # 对 argocd-repo-server 而言该设置定义缓存的 git revision 过期时间 # 设为 0 时使用 --default-cache-expiration默认 24 小时可被 # ARGOCD_DEFAULT_CACHE_EXPIRATION 环境变量覆盖。 # 注意修改该设置后必须手动重启 argocd-repo-server deployment # 与 argocd-application-controller statefulset或 deployment若如此配置。 timeout.reconciliation: 120s # 应用数量很大时周期性刷新会冲击刷新队列与 repo-server。 # 可为同步超时附加 jitter 来分散刷新jitter 是允许叠加的最大时长 # 若同步超时 3 分钟、jitter 1 分钟实际超时在 3~4 分钟之间。 # 值为 0 时禁用默认 1 分钟。 timeout.reconciliation.jitter: 60s # Webhook 触发的刷新可附加的最大 jitter 时长。 # 多个 webhook 事件同时到达如批量合并后时jitter 将每次刷新 # 随机延迟 0 到该时长避免 repo-server 瞬时尖峰。设为 0 禁用默认。 webhook.refresh.jitter: 0s # 启用 webhook 刷新 jitter 所需的最小受影响应用数。 # 例如设为 10单个 webhook 事件影响超过 10 个应用时才应用 jitter # 否则立即刷新不延迟。与 webhook.refresh.jitter 配合使用。默认 10。 webhook.refresh.jitter.threshold: 10对应源码常量见 util/settings/settings.go默认阈值defaultWebhookRefreshJitterThreshold 10util/settings/settings.go。十六、集群与服务器行为# 是否允许使用 in-cluster 服务器地址默认启用 cluster.inClusterEnabled: true # UI 渲染 Pod 日志的最大数量。应用 Pod 数超过该值时不再渲染日志 # 防止渲染大量日志导致 UI 无响应。默认 10。 server.maxPodLogsToRender: 10 # 启用独立的 rollback RBAC 动作。 # 为 true 时用户必须被显式授予 rollback 动作才能执行回滚 # 缺省或为 false 时回滚沿用 sync 权限向后兼容。 server.rbac.rollback.enforce.enable: falsecluster.inClusterEnabled的默认值常量defaultInClusterEnabledFlag trueutil/settings/settings.go。十七、Source Hydrator 提交配置以下键与 Source Hydrator将多仓库/多应用源“水合”为一个单一 manifests 仓库的功能相关# Hydrator 创建提交时使用的作者名可选缺省 Argo CD commit.author.name: Argo CD # Hydrator 创建提交时使用的作者邮箱可选缺省 argo-cdexample.com commit.author.email: argo-cdexample.com # 提交消息模板遍历 .metadata 对象的字段并按类型map/array/基本值格式化。 # 这是默认模板聚焦于特定 metadata 属性 sourceHydrator.commitMessageTemplate: | {{.metadata.drySha | trunc 7}}: {{ .metadata.subject }} {{- if .metadata.body }} {{ .metadata.body }} {{- end }} {{ range $ref : .metadata.references }} {{- if and $ref.commit $ref.commit.author }} Co-authored-by: {{ $ref.commit.author }} {{- end }} {{- end }} {{- if .metadata.author }} Co-authored-by: {{ .metadata.author }} {{- end }} # 水合过程中自动生成的 README.md 内容模板。 # 可用占位符.RepoURL、.DrySHA、.Commands 等 # 用于提供可复现的说明。模板从 ConfigMap 动态加载可按环境定制。 sourceHydrator.readmeMessageTemplate: | # Manifest Hydration To hydrate the manifests in this repository, run the following commands: shell git clone {{ .RepoURL }} # cd into the cloned directory git checkout {{ .DrySHA }} {{ range $command : .Commands -}} {{ $command }} {{ end -}}{{ if .References -}}References{{ range $ref : .References -}} {{ if $ref.Commit -}}[{{ $ref.Commit.SHA | mustRegexFind [0-9a-f] | trunc 7 }}]({{ $ref.Commit.RepoURL }}): {{ $ref.Commit.Subject }} ({{ $ref.Commit.Author }}) {{ end -}} {{ end -}} {{ end -}}这两个模板的默认值与源码中的 CommitMessageTemplate、DefaultManifestHydrationReadmeTemplate 完全一致[util/settings/settings.go](https://link.gitcode.com/i/d004cd56dce0952403e712d18ffe24f0#L49-L84)说明示例文件展示的即出厂默认值sourceHydrator.readmeMessageTemplate 的运行时读取逻辑位于 GetHydratorReadmeTemplate()[util/settings/settings.go](https://link.gitcode.com/i/d004cd56dce0952403e712d18ffe24f0#L870)。 ## 十八、如何应用与验证配置 1. **修改 ConfigMap**用 kubectl edit configmap argocd-cm -n argocd 修改或直接 kubectl apply -f 一份自定义后的清单文件基础模板见 [manifests/base/config/argocd-cm.yaml](https://link.gitcode.com/i/b8fd4cf81b29204df3f36e95541165e8)。 2. **动态生效**除 timeout.reconciliation 外绝大多数配置由 SettingsManager 通过 informer 监听并自动 ResyncInformers() 推送[util/settings/settings.go](https://link.gitcode.com/i/d004cd56dce0952403e712d18ffe24f0#L757)无需重启。timeout.reconciliation 修改后需手动重启 argocd-repo-server 与 argocd-application-controller。 3. **验证**修改后观察各组件日志确认无解析告警在 UI 中核对横幅、徽章、Deep Links、自定义动作等是否按预期呈现在 Application 详情页检查 ignoreDifferences / health / actions 是否生效。 4. **与其他配置文件的配合**argocd-cm 关注“系统级行为”账号权限另见 [docs/operator-manual/argocd-rbac-cm.yaml](https://link.gitcode.com/i/e73da9a7b71e28322cc78fc6a87a4e56)敏感密钥存放在 argocd-secret[docs/operator-manual/argocd-secret.yaml](https://link.gitcode.com/i/a967617031b943228dfe9c8a060c3eda)启动参数级别的覆盖则通过 [docs/operator-manual/argocd-cmd-params-cm.yaml](https://link.gitcode.com/i/8b1169a7075b8ab6b50e8ffd57b5d60b) 完成。 ## 结语 argocd-cm.yaml 是 Argo CD 运维中最常打交道的配置文件。本文从官方示例 [docs/operator-manual/argocd-cm.yaml](https://link.gitcode.com/i/7602405f2a285b22fcc150be4989380e) 出发覆盖了外部访问与 SSO、资源比较与忽略规则、自定义健康检查与动作、配置管理工具、应用跟踪、UI 定制、Deep Links、超时抖动与 Source Hydrator 等全部参数并对照 [util/settings/settings.go](https://link.gitcode.com/i/d004cd56dce0952403e712d18ffe24f0) 的常量定义说明了各键的底层绑定关系与默认值。实际部署时建议以官方示例为起点按上述分类逐项裁剪并在变更后利用 informer 热加载机制快速验证效果。【免费下载链接】argo-cdDeclarative Continuous Deployment for Kubernetes项目地址: https://gitcode.com/GitHub_Trending/ar/argo-cd创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表