liveBook · Manning

Deployment pipeline

As explained in Kubernetes for Developers

A deployment pipeline is an automated sequence of validation and delivery steps that promotes software or configuration changes to a deployment environment.

A deployment pipeline removes the need for someone to apply every configuration change by hand. When a change is pushed to a configuration repository, a repository trigger runs deployment steps against a Kubernetes cluster. The rollout comes from committed configuration rather than an operator’s local files. section 11.3.1

A practical GitOps workflow is:

  • Change the Kubernetes configuration in the repository, then commit and push it. section 11.3.1
  • Let the pipeline apply the pushed configuration. If a correction is needed, change the repository and trigger another rollout instead of editing the cluster directly. section 11.3.1
  • Check the deployment environment before applying files. A script that checks the current namespace can prevent a wrong-environment rollout, but a namespace written into a configuration file overrides that safeguard. section 11.3

Deploy on a repository push with Cloud Build

For a Google Kubernetes Engine cluster, give the Cloud Build service account permission to act on the cluster, create a trigger for pushes to the configuration repository, and point it at a build configuration that runs kubectl apply -f on the configuration folder. section 11.3.2

Listing 11.3 Chapter11/11.3.2_CloudBuild/cloudbuild-deploy.yaml
steps:
- name: 'gcr.io/cloud-builders/kubectl'
 id: Deploy
 args:
 - 'apply'
 - '-f'
 - '$FOLDER'
 env:
 - 'CLOUDSDK_COMPUTE_REGION=us-west1'
 - 'CLOUDSDK_CONTAINER_CLUSTER=my-cluster'

The Cloud Build configuration shows the deploy step, its kubectl arguments, and the region and cluster environment variables. section 11.3.2

A push-triggered pipeline runs when the repository changes. A GitOps operator such as Flux takes a different approach: it continually reconciles the cluster with the repository and can act when they diverge between pushes. Kubernetes leaves teams free to assemble either a simple push-to-deploy workflow or a pipeline with additional controls such as security scanning. section 11.3.2 section 1.2.2

How Kubernetes for Developers covers it

How deep it goes
Defines the repository trigger and sketches a Cloud Build setup, while deferring a complete end-to-end CI/CD flow.
Examples
Uses namespace-checking rollout scripts and a Cloud Build configuration that runs kubectl apply against a GKE cluster.
What it assumes
Assumes a configuration repository and Kubernetes cluster; the Cloud Build example additionally requires service-account access to GKE.
What you can do after
Apply it via Cloud Build by granting cluster access, creating a repository-push trigger, and configuring a kubectl deployment step.
How it connects
Connects GitOps, configuration as code, Kubernetes namespaces, continuous deployment, and GitOps operators.

Also explained in

Compare how 30 books explain deployment pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes for Developers. The section links point to the parts of the book it draws on.