gitops
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<objective>Routing note: For ambiguous user intents, use the shared clarification templates in references/intent-clarification.md.
<objective>路由说明:如果用户意图不明确,请使用references/intent-clarification.md中的通用澄清模板。
GitOps with TrueFoundry
基于TrueFoundry的GitOps
Set up GitOps-style deployments with TrueFoundry. Store deployment configurations as YAML specs in Git and auto-deploy on push using in CI/CD pipelines.
tfy apply使用TrueFoundry搭建GitOps模式的部署流程。将部署配置以YAML规范的形式存储在Git中,在CI/CD流水线中通过实现代码推送后自动部署。
tfy applyWhen to Use
适用场景
Set up automated Git-based deployments with . Store TrueFoundry YAML specs in Git and auto-deploy on push/merge via CI/CD pipelines.
tfy apply需要使用搭建基于Git的自动化部署流程,将TrueFoundry YAML规范存储在Git中,通过CI/CD流水线在代码推送/合并后自动部署。
tfy applyWhen NOT to Use
不适用场景
- User wants to deploy manually from local code → prefer skill; ask if the user wants another valid path
deploy - User wants to deploy an LLM model → prefer skill; ask if the user wants another valid path
llm-deploy - User wants to check what's deployed → prefer skill; ask if the user wants another valid path
applications - User wants to deploy a Helm chart → prefer skill; ask if the user wants another valid path
helm - User just wants to check TrueFoundry connection → prefer skill; ask if the user wants another valid path
status
- 用户想要从本地代码手动部署 → 优先使用技能;询问用户是否需要选择其他有效路径
deploy - 用户想要部署LLM模型 → 优先使用技能;询问用户是否需要选择其他有效路径
llm-deploy - 用户想要查看已部署的内容 → 优先使用技能;询问用户是否需要选择其他有效路径
applications - 用户想要部署Helm chart → 优先使用技能;询问用户是否需要选择其他有效路径
helm - 用户仅想要检查TrueFoundry连接状态 → 优先使用技能;询问用户是否需要选择其他有效路径
status
Prerequisites
前置条件
Always verify before setting up GitOps:
- Credentials — and
TFY_BASE_URLmust be set (env orTFY_API_KEY).env - TrueFoundry CLI — CLI must be available in the CI/CD environment (installed via
tfy)pip install truefoundry - Git repository — A Git repo to store deployment specs
For credential check commands and .env setup, see . Use the skill to verify connection before proceeding.
</context>
<instructions>references/prerequisites.mdstatus搭建GitOps前请务必确认以下内容:
- 凭证 — 和
TFY_BASE_URL必须配置完成(环境变量或TFY_API_KEY文件中).env - TrueFoundry CLI — CI/CD环境中必须安装CLI(可通过
tfy安装)pip install truefoundry - Git仓库 — 用于存储部署规范的Git仓库
如需凭证检查命令和.env配置说明,请查看。在继续操作前请使用技能验证连接状态。
</context>
<instructions>references/prerequisites.mdstatusHow GitOps Works with TrueFoundry
TrueFoundry的GitOps工作原理
GitOps treats Git as the single source of truth for deployment configurations. The workflow is:
- Store specs in Git — All TrueFoundry resource YAML specs live in the repository
- Review via pull requests — Changes are reviewed before merging, with validating specs in CI
tfy apply --dry-run - Auto-deploy on merge — When specs are merged to the default branch, deploys them automatically
tfy apply - Full audit trail — Git history tracks every change, who made it, and when
GitOps将Git作为部署配置的唯一可信源,工作流程如下:
- 将规范存储在Git中 — 所有TrueFoundry资源的YAML规范都存放在代码仓库中
- 通过拉取请求进行评审 — 变更在合并前需经过评审,CI中通过验证规范的有效性
tfy apply --dry-run - 合并后自动部署 — 当规范被合并到默认分支时,会自动完成部署
tfy apply - 完整审计追踪 — Git历史记录会追踪每一次变更、变更提交人及提交时间
Repository Organization
仓库组织方式
Organize your repo with directories for each resource type:
truefoundry-configs/
├── clusters/
│ └── my-cluster/
│ ├── dev-workspace/
│ │ ├── my-api-service.yaml
│ │ ├── my-worker.yaml
│ │ └── my-llm.yaml
│ ├── staging-workspace/
│ │ ├── my-api-service.yaml
│ │ └── my-worker.yaml
│ └── prod-workspace/
│ ├── my-api-service.yaml
│ └── my-worker.yaml
├── gateway/
│ ├── models.yaml
│ ├── guardrails.yaml
│ └── tool-servers.yaml
├── integrations/
│ └── custom-integration.yaml
├── teams/
│ └── my-team.yaml
└── virtualaccounts/
└── my-account.yaml按资源类型创建目录来组织仓库内容:
truefoundry-configs/
├── clusters/
│ └── my-cluster/
│ ├── dev-workspace/
│ │ ├── my-api-service.yaml
│ │ ├── my-worker.yaml
│ │ └── my-llm.yaml
│ ├── staging-workspace/
│ │ ├── my-api-service.yaml
│ │ └── my-worker.yaml
│ └── prod-workspace/
│ ├── my-api-service.yaml
│ └── my-worker.yaml
├── gateway/
│ ├── models.yaml
│ ├── guardrails.yaml
│ └── tool-servers.yaml
├── integrations/
│ └── custom-integration.yaml
├── teams/
│ └── my-team.yaml
└── virtualaccounts/
└── my-account.yamlKey Principles
核心原则
- One YAML file per resource — Each TrueFoundry resource (service, job, model, etc.) gets its own file
- Filename matches resource name — The YAML filename should match the field inside the spec
name - Separate directories per workspace — Keep dev, staging, and prod configs in separate directories
- Extract specs from the UI — Use "Edit -> Apply Using YAML" in the TrueFoundry dashboard to get the YAML spec for any existing resource
- 每个资源对应一个YAML文件 — 每个TrueFoundry资源(服务、任务、模型等)都有独立的配置文件
- 文件名与资源名一致 — YAML文件名需与规范内部的字段值匹配
name - 各工作空间目录独立 — 将开发、预发、生产环境的配置存放在独立目录中
- 从UI导出规范 — 使用TrueFoundry控制台中的「编辑 -> 使用YAML应用」功能,获取任意现有资源的YAML规范
Manifest File Structure
清单文件结构
Each YAML spec follows the standard TrueFoundry manifest format. For example, a service spec:
yaml
type: service
name: my-api-service
image:
type: image
image_uri: my-registry/my-app:latest
command: uvicorn main:app --host 0.0.0.0 --port 8000
ports:
- port: 8000
expose: true
protocol: TCP
app_protocol: http
host: my-api-dev.ml.example.truefoundry.cloud
workspace_fqn: my-cluster:dev-workspace
env:
APP_ENV: development
LOG_LEVEL: debug
replicas:
min: 1
max: 3
resources:
cpu_request: 0.5
cpu_limit: 1.0
memory_request: 512
memory_limit: 1024每个YAML规范都遵循标准的TrueFoundry清单格式,例如服务规范:
yaml
type: service
name: my-api-service
image:
type: image
image_uri: my-registry/my-app:latest
command: uvicorn main:app --host 0.0.0.0 --port 8000
ports:
- port: 8000
expose: true
protocol: TCP
app_protocol: http
host: my-api-dev.ml.example.truefoundry.cloud
workspace_fqn: my-cluster:dev-workspace
env:
APP_ENV: development
LOG_LEVEL: debug
replicas:
min: 1
max: 3
resources:
cpu_request: 0.5
cpu_limit: 1.0
memory_request: 512
memory_limit: 1024Environment-Specific Configs (Dev / Staging / Prod)
环境专属配置(开发/预发/生产)
Maintain separate YAML files per environment. Common differences:
| Setting | Dev | Staging | Prod |
|---|---|---|---|
| 1 | 1 | 2+ |
| 1 | 3 | 10+ |
| 0.25 | 0.5 | 1.0+ |
| 256 | 512 | 1024+ |
| debug | info | warn |
| | | |
| | | |
Example directory layout:
clusters/my-cluster/
├── dev-workspace/
│ └── my-service.yaml # min resources, 1 replica, debug logging
├── staging-workspace/
│ └── my-service.yaml # moderate resources, autoscaling, info logging
└── prod-workspace/
└── my-service.yaml # full resources, HA replicas, warn logging为每个环境维护独立的YAML文件,常见差异如下:
| 配置项 | 开发环境 | 预发环境 | 生产环境 |
|---|---|---|---|
| 1 | 1 | 2+ |
| 1 | 3 | 10+ |
| 0.25 | 0.5 | 1.0+ |
| 256 | 512 | 1024+ |
| debug | info | warn |
| | | |
| | | |
示例目录结构:
clusters/my-cluster/
├── dev-workspace/
│ └── my-service.yaml # 最低资源配置、1个副本、debug级别日志
├── staging-workspace/
│ └── my-service.yaml # 中等资源配置、自动扩缩容、info级别日志
└── prod-workspace/
└── my-service.yaml # 全量资源配置、高可用副本、warn级别日志Using tfy apply
in CI/CD Pipelines
tfy apply在CI/CD流水线中使用tfy apply
tfy applyThe command is the core of GitOps with TrueFoundry.
tfy applytfy applyBasic Usage
基础用法
bash
undefinedbash
undefinedInstall TrueFoundry CLI (pin version range to prevent supply-chain attacks)
安装TrueFoundry CLI(固定版本范围避免供应链攻击)
pip install 'truefoundry>=0.5.0,<1.0'
pip install 'truefoundry>=0.5.0,<1.0'
Authenticate (uses TFY_HOST and TFY_API_KEY env vars)
认证(使用TFY_HOST和TFY_API_KEY环境变量)
TFY_HOST is the TrueFoundry platform URL (same as TFY_BASE_URL)
TFY_HOST是TrueFoundry平台URL(与TFY_BASE_URL一致)
Dry run — validate without deploying
试运行 — 仅验证不部署
tfy apply --file path/to/spec.yaml --dry-run
tfy apply --file path/to/spec.yaml --dry-run
Apply — deploy the spec
应用 — 部署规范
tfy apply --file path/to/spec.yaml
undefinedtfy apply --file path/to/spec.yaml
undefinedApplying Multiple Files
批量应用文件
To apply all changed files in a CI/CD pipeline, detect which files were modified in the commit or PR:
bash
undefined要在CI/CD流水线中应用所有变更的文件,可检测提交或PR中修改的文件:
bash
undefinedApply each changed YAML file
应用每个变更的YAML文件
while IFS= read -r file; do
[ -z "$file" ] && continue
echo "Applying $file..."
tfy apply --file "$file"
done < <(git diff --name-only HEAD~1 HEAD -- '*.yaml')
undefinedwhile IFS= read -r file; do
[ -z "$file" ] && continue
echo "Applying $file..."
tfy apply --file "$file"
done < <(git diff --name-only HEAD~1 HEAD -- '*.yaml')
undefinedHandling Deleted Files
处理已删除文件
When a YAML spec file is deleted from the repo, the corresponding resource should be removed. The CI/CD pipeline should detect deleted files and handle them:
bash
undefined当YAML规范文件从仓库中删除时,对应的资源也需要被移除。CI/CD流水线需要检测删除的文件并进行处理:
bash
undefinedWarn about deleted files
对删除的文件发出警告
while IFS= read -r file; do
[ -z "$file" ] && continue
echo "WARNING: $file was deleted. Remove the resource manually from the TrueFoundry dashboard."
done < <(git diff --name-only --diff-filter=D HEAD~1 HEAD -- '*.yaml')
undefinedwhile IFS= read -r file; do
[ -z "$file" ] && continue
echo "WARNING: $file was deleted. Remove the resource manually from the TrueFoundry dashboard."
done < <(git diff --name-only --diff-filter=D HEAD~1 HEAD -- '*.yaml')
undefinedCI/CD Integration
CI/CD集成
For complete workflow files for each CI provider:
- GitHub Actions: See references/gitops-github-actions.md -- PR validation (dry-run) and merge-to-deploy workflows, plus required secrets setup.
- GitLab CI: See references/gitops-gitlab-ci.md -- validate and deploy stages with caching.
- Bitbucket Pipelines: See references/gitops-bitbucket-pipelines.md -- PR validation and branch-based deploy.
All providers require and as repository secrets/variables.
TFY_HOSTTFY_API_KEY如需各CI提供商的完整工作流文件,请查看:
- GitHub Actions:查看references/gitops-github-actions.md — 包含PR验证(dry-run)和合并部署工作流,以及所需的密钥配置说明。
- GitLab CI:查看references/gitops-gitlab-ci.md — 包含带缓存的验证和部署阶段配置。
- Bitbucket Pipelines:查看references/gitops-bitbucket-pipelines.md — 包含PR验证和基于分支的部署配置。
所有提供商都需要将和配置为仓库密钥/变量。
TFY_HOSTTFY_API_KEYStep-by-Step: Setting Up GitOps (Summary)
GitOps搭建步骤(概览)
- Verify TrueFoundry connection — Use the skill to confirm credentials
status - Create the repo structure — Set up directories for your resource types (clusters, gateway, etc.)
- Export existing specs — In the TrueFoundry dashboard, go to each resource -> Edit -> Apply Using YAML. Save each spec as a YAML file in the repo.
- Add CI/CD workflows — Copy the appropriate workflow files for your CI provider (see above)
- Set repository secrets — Add and
TFY_HOSTas secrets/variables in your CI providerTFY_API_KEY - Test with a dry run — Open a PR with a small change to verify the validation pipeline works
- Merge and deploy — Merge the PR and confirm the apply pipeline deploys successfully
<success_criteria>
- 验证TrueFoundry连接 — 使用技能确认凭证有效
status - 创建仓库结构 — 为不同资源类型(集群、网关等)创建对应目录
- 导出现有规范 — 在TrueFoundry控制台中,进入每个资源 -> 编辑 -> 使用YAML应用,将每个规范保存为仓库中的YAML文件。
- 添加CI/CD工作流 — 复制适用于你的CI提供商的工作流文件(见上文)
- 配置仓库密钥 — 在你的CI提供商中将和
TFY_HOST添加为密钥/变量TFY_API_KEY - 试运行测试 — 提交包含小改动的PR,验证验证流水线是否正常工作
- 合并部署 — 合并PR,确认应用流水线成功完成部署
<success_criteria>
Success Criteria
成功标准
- The user has a Git repository with TrueFoundry YAML specs organized by environment (dev/staging/prod)
- The CI/CD pipeline validates specs on pull requests using
tfy apply --dry-run - The CI/CD pipeline auto-deploys specs on merge to the default branch using
tfy apply - The agent has provided the user with the correct CI workflow files for their CI provider (GitHub Actions, GitLab CI, or Bitbucket Pipelines)
- Repository secrets (,
TFY_HOST) are configured in the CI providerTFY_API_KEY - The user can verify the pipeline works by opening a PR with a small YAML change and seeing validation pass
</success_criteria>
<references>- 用户拥有按环境(开发/预发/生产)组织的存储TrueFoundry YAML规范的Git仓库
- CI/CD流水线在拉取请求阶段使用验证规范有效性
tfy apply --dry-run - CI/CD流水线在合并到默认分支时使用自动部署规范
tfy apply - Agent已为用户提供适配其CI提供商(GitHub Actions、GitLab CI或Bitbucket Pipelines)的正确CI工作流文件
- 仓库密钥(、
TFY_HOST)已在CI提供商中完成配置TFY_API_KEY - 用户可以通过提交包含小改动的YAML文件的PR,查看验证通过,来确认流水线正常工作
</success_criteria>
<references>Composability
可组合能力
- Verify connection first: Use skill to check TrueFoundry credentials
status - Find workspace FQN: Use skill to get workspace FQNs for your specs
workspaces - Check existing deployments: Use skill to see what is already deployed
applications - Deploy LLM models via GitOps: Use skill to generate the manifest YAML, then store it in Git
llm-deploy - Manage secrets: Use skill to set up secret groups referenced in your specs
secrets - View deployment logs: Use skill to debug deployments after apply
logs
- 优先验证连接:使用技能检查TrueFoundry凭证
status - 查询工作空间FQN:使用技能获取规范所需的工作空间FQN
workspaces - 检查现有部署:使用技能查看已部署的内容
applications - 通过GitOps部署LLM模型:使用技能生成清单YAML,然后存储到Git中
llm-deploy - 管理密钥:使用技能创建规范中引用的密钥组
secrets - 查看部署日志:使用技能调试应用后的部署问题
logs
Error Handling
错误处理
tfy apply Failed — Invalid Spec
tfy apply执行失败 — 规范无效
tfy apply returned a validation error.
Check:
- YAML syntax is valid (no tabs, proper indentation)
- Required fields are present (type, name, workspace_fqn)
- Resource references exist (workspace, secrets, etc.)
Run: tfy apply --file spec.yaml --dry-runtfy apply returned a validation error.
Check:
- YAML syntax is valid (no tabs, proper indentation)
- Required fields are present (type, name, workspace_fqn)
- Resource references exist (workspace, secrets, etc.)
Run: tfy apply --file spec.yaml --dry-runtfy apply Failed — Authentication Error
tfy apply执行失败 — 认证错误
401 Unauthorized from tfy apply.
Check:
- TFY_HOST is set correctly (the platform URL, e.g., https://your-org.truefoundry.cloud)
- TFY_API_KEY is valid and not expired
- Secrets are configured correctly in your CI provider401 Unauthorized from tfy apply.
Check:
- TFY_HOST is set correctly (the platform URL, e.g., https://your-org.truefoundry.cloud)
- TFY_API_KEY is valid and not expired
- Secrets are configured correctly in your CI providertfy apply Failed — Workspace Not Found
tfy apply执行失败 — 未找到工作空间
Workspace FQN in the spec does not exist.
Check:
- workspace_fqn field matches an existing workspace
- Use the workspaces skill to list available workspacesWorkspace FQN in the spec does not exist.
Check:
- workspace_fqn field matches an existing workspace
- Use the workspaces skill to list available workspacesCI Pipeline Not Triggering
CI流水线未触发
Workflow not running on push/PR.
Check:
- File path filters match your YAML file locations
- Branch filters match your default branch name
- CI provider secrets are set (TFY_HOST, TFY_API_KEY)Workflow not running on push/PR.
Check:
- File path filters match your YAML file locations
- Branch filters match your default branch name
- CI provider secrets are set (TFY_HOST, TFY_API_KEY)Filename / Spec Name Mismatch
文件名/规范名称不匹配
The YAML filename should match the 'name' field inside the spec.
Example: my-service.yaml should contain name: my-service
This is a convention for clarity — tfy apply uses the internal name, not the filename.The YAML filename should match the 'name' field inside the spec.
Example: my-service.yaml should contain name: my-service
This is a convention for clarity — tfy apply uses the internal name, not the filename.