Build and Push Container Images
This comprehensive guide demonstrates modern container image building and deployment with Tekton, including:
Source Code Management: Clone repositories with security scanning
Container Building: Build multi-architecture images with Kaniko
Security Integration: Image signing and SLSA provenance generation
Registry Management: Push to multiple cloud registries with authentication
Supply Chain Security: Implement modern DevSecOps practices
If you're already familiar with Tekton and want to see the complete examples, you can jump to the full code samples.
Prerequisites
Kubernetes Cluster: You must have a Kubernetes cluster 1.28+ running and kubectl properly configured to issue commands to your cluster.
Install Tekton Pipelines (v0.55.0+):
# Install latest Tekton Pipelines
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
# Verify installation
kubectl get pods --namespace tekton-pipelinesSee the Pipelines installation documentation for other installation options and vendor specific instructions.
Install Tekton CLI: Install the Tekton CLI,
tkn, on your machine:
If this is your first time using Tekton Pipelines, we recommend that you complete the Getting Started tutorials before proceeding with this guide.
Clone the Repository
Create a new Pipeline, pipeline.yaml, that uses the git clone Task to clone the source code from a git repository:
Then create the corresponding pipelinerun.yaml file:
For this how-to we are using a public repository as an example. You can also use git clone with private repositories, using SSH authentication.
Security Scanning and Vulnerability Assessment
Add security scanning to your pipeline before building the image:
Install the Trivy scanner task:
Build the container image with Kaniko
To build the image use the enhanced Kaniko Task with multi-architecture support:
Image Signing with Cosign
Add image signing to ensure supply chain security:
Create the Cosign signing task:
SLSA Provenance Generation
Generate SLSA provenance for supply chain attestation:
Create the SLSA provenance task:
Run your Pipeline
You are ready to install the Tasks and run the pipeline.
Install the
git-clone,trivy-scanner,kaniko,cosign-sign, andslsa-provenanceTasks:Apply the Secret with your Docker credentials.
Apply the Pipeline:
Create the PipelineRun:
This creates a PipelineRun with a unique name each time:
Use the PipelineRun name from the output of the previous step to monitor the Pipeline execution:
After a few seconds, the output confirms that the image was built and pushed successfully:
Full Code Samples (2025)
Complete Secure Pipeline
Production PipelineRun
Docker Credentials Secret
Cosign Keys Secret
Container Registry Authentication
For different registry providers, configure your Docker credentials accordingly:
Docker Hub
AWS ECR
Google Container Registry
Azure Container Registry
Advanced Features
Multi-Architecture Builds
For building multi-platform images, update the Kaniko task:
Cache Optimization
Enable advanced caching for faster builds:
This guide provides a complete, production-ready pipeline with modern security practices, including vulnerability scanning, image signing, and SLSA provenance generation that meets 2025 DevSecOps standards.
Last updated