Skip to content

Docker image build and push workflow for Kubernetes

Docker image build and push workflow for Kubernetes

This document outlines the standard operating procedure for building, pushing, and deploying container images within a Kubernetes Context, specifically demonstrated using the Bookinfo sample application^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].

Workflow Principles

Before integrating changes into an official repository, the owner of a pull request is responsible for performing appropriate testing with images built and pushed to their own private Docker repository^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].

Build Process

The process involves tagging images with a specific version and a registry prefix^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md]. A build-services.sh script is typically used to automate the construction of the container images^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].

For example, to build images with a specific version tag (e.g., 1.16.3) and a user prefix (e.g., docker.io/shamsher31), one would run the build script located within the project's source directory^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].

Push and Update

A streamlined workflow is available to execute the build, push, and update steps in a single operation using a helper script^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md]. This script performs three actions:

  1. Builds the Docker images^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].
  2. Pushes the images to the designated Docker registry^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].
  3. Updates the Kubernetes YAML files with the latest image tags^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].

Deployment and Verification

Once images are pushed, the next step is to deploy the application to the Kubernetes cluster using the updated YAML configuration^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md]. The user must wait for all pods to reach the Running state to ensure the deployment was successful^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].

Functional testing is performed either via the command line, for instance by executing a curl command from within a running Pod to verify connectivity^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md], or by accessing the application directly through a browser^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md].

Sources

^[400-devops-07-monitoring-and-observability-k8s-istio-samples-bookinfo-readme.md]