create-environment
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Environment
创建环境
Generate Harness Environment YAML and push to Harness via MCP.
生成Harness Environment YAML并通过MCP推送到Harness。
Instructions
操作说明
- Determine environment type - for dev/staging/QA,
PreProductionfor live environmentsProduction - Define variables and overrides - Environment-specific config values and manifest overrides
- Generate YAML using the structure below
- Create via MCP using with resource_type
harness_createenvironment
- 确定环境类型 - 适用于dev/staging/QA环境,
PreProduction适用于生产环境Production - 定义变量与覆盖配置 - 环境专属的配置值和清单覆盖项
- 使用下方结构生成YAML
- 通过MCP创建:调用,指定resource_type为
harness_createenvironment
Environment Structure
环境结构
yaml
environment:
name: Staging
identifier: staging
orgIdentifier: default
projectIdentifier: my_project
type: PreProduction # PreProduction or Production
tags:
tier: staging
variables:
- name: domain
type: String
value: staging.myapp.com
- name: replicas
type: Number
value: "2"
- name: db_password
type: Secret
value: <+secrets.getValue("staging_db_password")>
overrides:
manifests:
- manifest:
identifier: values_override
type: Values
spec:
store:
type: Github
spec:
connectorRef: github
repoName: config
branch: main
paths: [values-staging.yaml]yaml
environment:
name: Staging
identifier: staging
orgIdentifier: default
projectIdentifier: my_project
type: PreProduction # PreProduction or Production
tags:
tier: staging
variables:
- name: domain
type: String
value: staging.myapp.com
- name: replicas
type: Number
value: "2"
- name: db_password
type: Secret
value: <+secrets.getValue("staging_db_password")>
overrides:
manifests:
- manifest:
identifier: values_override
type: Values
spec:
store:
type: Github
spec:
connectorRef: github
repoName: config
branch: main
paths: [values-staging.yaml]Environment Types
环境类型
- - Dev, QA, staging, integration environments
PreProduction - - Live production environments (enables additional safeguards)
Production
- - 开发、QA、staging、集成环境
PreProduction - - 生产环境(启用额外安全防护)
Production
Multi-Environment Setup
多环境配置
Create dev, staging, and prod:
yaml
undefined创建dev、staging和prod环境:
yaml
undefinedDev
Dev
environment:
name: Development
identifier: dev
type: PreProduction
variables:
- name: domain
type: String
value: dev.myapp.com
environment:
name: Development
identifier: dev
type: PreProduction
variables:
- name: domain
type: String
value: dev.myapp.com
Staging
Staging
environment:
name: Staging
identifier: staging
type: PreProduction
variables:
- name: domain
type: String
value: staging.myapp.com
environment:
name: Staging
identifier: staging
type: PreProduction
variables:
- name: domain
type: String
value: staging.myapp.com
Production
Production
environment:
name: Production
identifier: prod
type: Production
variables:
- name: domain
type: String
value: myapp.com
undefinedenvironment:
name: Production
identifier: prod
type: Production
variables:
- name: domain
type: String
value: myapp.com
undefinedCreating via MCP
通过MCP创建
Call MCP tool: harness_create
Parameters:
resource_type: "environment"
org_id: "<organization>"
project_id: "<project>"
body: <environment YAML>List environments:
Call MCP tool: harness_list
Parameters:
resource_type: "environment"
org_id: "<organization>"
project_id: "<project>"调用MCP工具:harness_create
参数:
resource_type: "environment"
org_id: "<organization>"
project_id: "<project>"
body: <environment YAML>列出环境:
调用MCP工具:harness_list
参数:
resource_type: "environment"
org_id: "<organization>"
project_id: "<project>"Examples
示例
- "Create dev, staging, and prod environments" - Generate 3 environments with appropriate types
- "Set up a production environment with overrides" - Production type with manifest overrides
- "创建dev、staging和prod环境" - 生成3个对应类型的环境
- "搭建带覆盖配置的生产环境" - Production类型并配置清单覆盖
Performance Notes
性能注意事项
- When creating multiple environments (dev/staging/prod), ensure variable values are distinct per environment.
- Verify that manifest override paths exist in the referenced repository before creating.
- Use Production type only for live environments — it enables additional safeguards like deployment freezes.
- 创建多个环境(dev/staging/prod)时,确保每个环境的变量值唯一。
- 创建前验证清单覆盖路径在引用的仓库中存在。
- 仅在生产环境使用Production类型——它会启用部署冻结等额外安全防护。
Troubleshooting
故障排查
- - Environment exists; use
DUPLICATE_IDENTIFIERharness_update - Production type enables deployment freeze and approval guardrails
- - 环境已存在;使用
DUPLICATE_IDENTIFIER更新harness_update - Production类型会启用部署冻结和审批防护机制