GCP DevOps Project

Sprint 05

Sprint 05

In Sprint 0.5, we’ll extend our CI/CD pipeline to push Docker images into a Google Kubernetes Engine (GKE) cluster. By breaking this large goal into focused milestones, we improve visibility, estimation accuracy, and enable parallel work.

Why split into milestones?

Breaking down tasks helps with:

  • Tracking incremental progress
  • Clarifying deliverables
  • Providing more accurate time estimates
  • Allowing multiple team members to work concurrently

Milestone Breakdown

StepGoalExample Command
1. Create NamespaceIsolate resources in the clusterkubectl create namespace my-app
2. Write Deployment ManifestDefine your Kubernetes DeploymentSee deployment.yaml below
3. Update Cloud BuildApply manifests in your build pipelineSee cloudbuild.yaml snippet
4. Validate DeploymentEnsure pods and services are runningkubectl get all -n my-app

The image lists four steps for a deployment process: creating a namespace in a GKE cluster, creating a deployment file, updating Cloud Build code, and validating the deployment.


1. Create a GKE Namespace

Define an isolated namespace before any resources are applied:

# namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: my-app

Apply it in your pipeline or manually:

kubectl apply -f namespace.yaml

2. Prepare the Deployment Manifest

Create deployment.yaml to describe your application pods and replicas:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app-deployment
  namespace: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app
        image: gcr.io/PROJECT_ID/my-app:latest
        ports:
        - containerPort: 8080

3. Update Your Cloud Build Configuration

Modify your cloudbuild.yaml to include steps for namespace creation and manifest application:

steps:
  - name: gcr.io/cloud-builders/kubectl
    args:
      - apply
      - -f
      - namespace.yaml
  - name: gcr.io/cloud-builders/kubectl
    args:
      - apply
      - -f
      - deployment.yaml
images:
  - gcr.io/PROJECT_ID/my-app:$SHORT_SHA

For more details on Cloud Build, see the Cloud Build documentation.

4. Validate the Deployment

After Cloud Build finishes, confirm that your pods and services are up:

kubectl get all -n my-app

The image lists four steps for a deployment process: creating a namespace in a GKE cluster, creating a deployment file, updating Cloud Build code for deployment, and validating the deployment.

Watch Video

Watch video content

Previous
Sprint 04 review