[[["易于理解","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-05-15。"],[],[],null,["# Deployment methodology\n\nWe recommend that you use declarative infrastructure to deploy your foundation\nin a consistent and controllable manner. This approach helps enable consistent\ngovernance by enforcing policy controls about acceptable resource configurations\ninto your pipelines. The blueprint is deployed using a GitOps flow, with\nTerraform used to define infrastructure as code (IaC), a Git repository for\nversion control and approval of code, and Cloud Build for CI/CD automation\nin the deployment pipeline. For an introduction to this concept, see [managing\ninfrastructure as code with Terraform, Cloud Build, and\nGitOps](/docs/terraform/resource-management/managing-infrastructure-as-code).\n\nThe following sections describe how the deployment pipeline is used to manage\nresources in your organization.\n\nPipeline layers\n---------------\n\nTo separate the teams and technology stack that are responsible for managing\ndifferent layers of your environment, we recommend a model that uses different\npipelines and different personas that are responsible for each layer of the\nstack.\n\nThe following diagram introduces our recommended model for separating a\nfoundation pipeline, infrastructure pipeline, and application pipeline.\n\nThe diagram introduces the pipeline layers in this model:\n\n- The *foundation pipeline* deploys the foundation resources that are used across the platform. We recommend that a single central team is responsible for managing the foundation resources that are consumed by multiple business units and workloads.\n- The *infrastructure pipeline* deploys projects and infrastructure that are used by workloads, such as VM instances or databases. The blueprint sets up a separate infrastructure pipeline for each business unit, or you might prefer a single infrastructure pipeline used by multiple teams.\n- The *application pipeline* deploys the artifacts for each workload, such as containers or images. You might have many different application teams with individual application pipelines.\n\nThe following sections introduce the usage of each pipeline layer.\n\n### The foundation pipeline\n\nThe foundation pipeline deploys the foundation resources. It also sets up the\ninfrastructure pipeline that is used to deploy infrastructure used by workloads.\n\nTo create the foundation pipeline, you first clone or fork the\nterraform-example-foundation to your own Git repository. Follow the steps in the\n[`0-bootstrap` README\nfile](https://github.com/terraform-google-modules/terraform-example-foundation/tree/master/0-bootstrap)\nto configure your bootstrap folder and resources.\n\nAfter you create the foundation pipeline in the `0-bootstrap` stage, the\nfollowing stages deploy resources on the foundation pipeline. Review the README\ndirections for each stage and implement each stage sequentially.\n\n### The infrastructure pipeline\n\nThe infrastructure pipeline deploys the projects and infrastructure (for\nexample, the VM instances and databases) that are used by workloads. The\nfoundation pipeline deploys multiple infrastructure pipelines. This separation\nbetween the foundation pipeline and infrastructure pipeline allows for a\nseparation between platform-wide resources and workload-specific resources.\n\nThe following diagram describes how the blueprint configures multiple\ninfrastructure pipelines that are intended for use by separate teams.\n\nThe diagram describes the following key concepts:\n\n- Each infrastructure pipeline is used to manage infrastructure resources independently of the foundation resources.\n- Each business unit has its own infrastructure pipeline, managed in a dedicated project in the `common` folder.\n- Each of the infrastructure pipelines has a service account with permission to deploy resources only to the projects that are associated with that business unit. This strategy creates a separation of duties between the privileged service accounts used for the foundation pipeline and those used by each infrastructure pipeline\n\nThis approach with multiple infrastructure pipelines is recommended when you\nhave multiple entities inside your organization that have the skills and\nappetite to manage their infrastructure separately, particularly if they have\ndifferent requirements such as the types of pipeline validation policy they want\nto enforce. Alternatively, you might prefer to have a single infrastructure\npipeline managed by a single team with consistent validation policies.\n\nIn the\n[terraform-example-foundation](https://github.com/terraform-google-modules/terraform-example-foundation/tree/master),\nstage 4 configures an infrastructure pipeline, and stage 5 demonstrates an\nexample of using that pipeline to deploy infrastructure resources.\n\n### The application pipeline\n\nThe application pipeline is responsible for deploying application artifacts for\neach individual workload, such as images or Kubernetes containers that run the\nbusiness logic of your application. These artifacts are deployed to\ninfrastructure resources that were deployed by your infrastructure pipeline.\n\nThe enterprise foundation blueprint sets up your foundation pipeline and\ninfrastructure pipeline, but doesn't deploy an application pipeline. For an\nexample application pipeline, see the [enterprise application\nblueprint](/architecture/blueprints/enterprise-application-blueprint/architecture).\n\nAutomating your pipeline with Cloud Build\n-----------------------------------------\n\nThe blueprint uses Cloud Build to automate CI/CD processes. The\nfollowing table describes the controls are built into the foundation pipeline\nand infrastructure pipeline that are deployed by the\n[terraform-example-foundation](https://github.com/terraform-google-modules/terraform-example-foundation/tree/master)\nrepository. If you are developing your own pipelines using other CI/CD\nautomation tools, we recommend that you apply similar controls.\n\nBranching strategy\n------------------\n\nWe recommend a [persistent branch](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows)\nstrategy for submitting code to your Git system and deploying resources through\nthe foundation pipeline. The following diagram describes the persistent branch\nstrategy.\n\nThe diagram describes three persistent branches in Git (development,\nnon-production, and production) that reflect the corresponding\nGoogle Cloud environments. There are also multiple ephemeral feature\nbranches that don't correspond to resources that are deployed in your\nGoogle Cloud environments.\n\nWe recommend that you enforce a [pull request\n(PR)](https://git-scm.com/docs/git-request-pull) process into your Git system so\nthat any code that is merged to a persistent branch has an approved PR.\n\nTo develop code with this persistent branch strategy, follow these high-level\nsteps:\n\n1. When you're developing new capabilities or working on a bug fix, create a new branch based off of the development branch. Use a naming convention for your branch that includes the type of change, a ticket number or other identifier, and a human-readable description, like `feature/123456-org-policies`.\n2. When you complete the work in the feature branch, open a PR that targets the development branch.\n3. When you submit the PR, the PR triggers the foundation pipeline to perform `terraform plan` and `terraform validate` to stage and verify the changes.\n4. After you validate the changes to the code, merge the feature or bug fix into the development branch.\n5. The merge process triggers the foundation pipeline to run `terraform apply` to deploy the latest changes in the development branch to the development environment.\n6. Review the changes in the development environment using any manual reviews, functional tests, or end-to-end tests that are relevant to your use case. Then promote changes to the non-production environment by opening a PR that targets the non-production branch and merge your changes.\n7. To deploy resources to the production environment, repeat the same process as step 6: review and validate the deployed resources, open a PR to the production branch, and merge.\n\nWhat's next\n-----------\n\n- Read about [operations best\n practices](/architecture/blueprints/security-foundations/operation-best-practices) (next document in this series)."]]