Blog
Kubernetes
DevOps
Platform Engineering
2
minutes

A Quick Technical Guide to Automating Kubernetes Deployments

Get a quick technical guide to automating Kubernetes deployments. Learn to use kubectl and YAML for consistent application setup, updates, and rollbacks in your cluster.
Morgan Perry
Co-founder
Summary
Twitter icon
linkedin icon

Automating Kubernetes deployments streamlines your development workflows and ensures consistency across environments.

This guide focuses on using native Kubernetes tools such as kubectl and YAML configuration files to automate your deployment processes.

Prerequisites

  • A working Kubernetes cluster
  • kubectl command-line tool installed
  • Basic understanding of Kubernetes concepts and YAML syntax

Step 1: Creating a Deployment YAML File

Start by creating a YAML file for your deployment. This file will define the desired state of your application in the Kubernetes cluster. Here’s a simple example of a YAML file for deploying a basic nginx container:

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx

This configuration creates a deployment named nginx-deployment, starting three replicas of the nginx container.

Step 2: Deploying with kubectl

To deploy the application to your Kubernetes cluster, run the following command:

kubectl apply -f nginx-deployment.yaml

This command instructs Kubernetes to set up the deployment as described in your YAML file.

Step 3: Automating Deployment Updates and Testing Automation

Automate with CI/CD Pipeline: Configure a CI/CD pipeline (e.g., Jenkins, GitLab CI, GitHub Actions) to automatically run kubectl apply -f <configuration-file>.yaml whenever changes are pushed to the main branch. Here is an example using GitLab CI:

deploy:
stage: deploy
script:
- kubectl apply -f nginx-deployment.yaml
only:
- main

Step 4:Testing the Automation

  • Make a change (e.g., update the nginx image version in the YAML file).
  • Commit and push the change; watch the CI/CD pipeline trigger and update the deployment.
  • Verify updates using kubectl rollout status deployment/nginx-deployment.
  • Optionally, test rollback by deploying a faulty configuration and then executing kubectl rollout undo deployment/nginx-deployment.

Step 5: Verifying the Deployment

After deploying, verify the status of your deployment with:

kubectl get deployments

This command provides details about the current deployments, including their desired and actual states.

Ready to Streamline Your Deployments?

For a deeper dive into how these and other tools can transform your CI/CD pipelines, read our Kubernetes automation tools article here.

Share on :
Twitter icon
linkedin icon
Ready to rethink the way you do DevOps?
Qovery is a DevOps automation platform that enables organizations to deliver faster and focus on creating great products.
Book a demo

Suggested articles

DevOps
Observability
Heroku
 minutes
Deploy to EKS, AKS, or GKE Without Writing a Single Line of YAML

Stop choosing between Heroku's simplicity and Kubernetes' power. Learn how to deploy to EKS, GKE, or AKS with a PaaS-like experience—zero YAML required, full control retained.

Mélanie Dallé
Senior Marketing Manager
DevOps
Platform Engineering
 minutes
GitOps vs. DevOps: How Can They Work Together?

Is it GitOps or DevOps? Stop choosing between them. Learn how DevOps culture and GitOps workflows work together to automate Kubernetes, eliminate drift, and accelerate software delivery.

Mélanie Dallé
Senior Marketing Manager
DevSecOps
Platform Engineering
Internal Developer Platform
 minutes
Cut Tool Sprawl: Automate Your Tech Stack with a Unified Platform

Stop letting tool sprawl drain your engineering resources. Discover how unified automation platforms eliminate configuration drift, close security gaps, and accelerate delivery by consolidating your fragmented DevOps stack.

Mélanie Dallé
Senior Marketing Manager
Product
Observability
5
 minutes
Alerting with guided troubleshooting in Qovery Observe

Get alerted and fix issues with full context. Qovery Observe notifies you when something goes wrong and guides you straight to the metrics and signals that explain why, all in one place.

Alessandro Carrano
Head of Product
DevOps
Developer Experience
 minutes
Top 10 Terraform Cloud Alternatives: The DevOps Guide to Escaping "State File Nightmares"

Tired of rising licensing costs and complex state management? Discover the top 10 alternatives to modernize your Infrastructure as Code, empower developers, and regain control of your cloud spend.

Mélanie Dallé
Senior Marketing Manager
DevOps
 minutes
Top 10 Jenkins Alternatives: The DevOps Guide to Escaping "Plugin Chaos"

Tired of Jenkins maintenance and broken pipelines? Discover the top 10 alternatives to modernize your CI/CD, automate environments, and reduce operational toil.

Mélanie Dallé
Senior Marketing Manager
DevOps
 minutes
10 DigitalOcean Alternatives for Scaling DevOps Teams

Top DigitalOcean alternatives for scaling teams. Compare Qovery (Multi-cloud automation), AWS, GCP, and Vultr to find the best fit for performance and scale.

Mélanie Dallé
Senior Marketing Manager
DevOps
 minutes
Top 5 Vercel Alternatives: Escape Cost, Lock-in, and Frontend Constraints

Stop paying Vercel overages and battling lock-in. Compare Qovery (full-stack automation on your cloud), Render, Netlify, and Fly.io to find the best alternative for DevOps and enterprise scaling.

Mélanie Dallé
Senior Marketing Manager

It’s time to rethink
the way you do DevOps

Turn DevOps into your strategic advantage with Qovery, automating the heavy lifting while you stay in control.