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
 minutes
The Top 10 Porter Alternatives: Finding a More Flexible DevOps Platform

Looking for a Porter alternative? Discover why Qovery stands out as the #1 choice. Compare features, pros, and cons of the top 10 platforms to simplify your deployment strategy and empower your team.

Mélanie Dallé
Senior Marketing Manager
AWS
Deployment
 minutes
AWS App Runner Alternatives: Top 10 Choices for Effortless Container Deployment

AWS App Runner limits control and locks you into AWS. See the top 10 alternatives, including Qovery, to gain crucial customization, cost efficiency, and multi-cloud flexibility for containerized application deployment.

Mélanie Dallé
Senior Marketing Manager
Kubernetes
 minutes
Kubernetes Management: Best Practices & Tools for Managing Clusters and Optimizing Costs

Master Kubernetes management and cut costs with essential best practices and tools. Learn about security, reliability, autoscaling, GitOps, and FinOps to simplify cluster operations and optimize cloud spending.

Mélanie Dallé
Senior Marketing Manager
AWS
GCP
Azure
Cloud
Business
10
 minutes
10 Best AWS Elastic Beanstalk Alternatives

AWS Elastic Beanstalk is often rigid and slow. This guide details the top 10 Elastic Beanstalk alternatives—including Heroku, Azure App Service, and Qovery—comparing the pros, cons, and ideal use cases for achieving superior flexibility, faster deployments, and better cost control.

Morgan Perry
Co-founder
Kubernetes
DevOps
7
 minutes
Kubernetes Cloud Migration Strategy: Master the Shift, Skip the Disaster

Master your Kubernetes migration strategy with this expert guide. Learn the critical planning phases, mitigate major risks (data, security, dependencies), and see how Qovery simplifies automation and compliance for a fast, successful, and reliable transition.

Morgan Perry
Co-founder
SecurityAndCompliance
DevSecOps
 minutes
Qovery Achieves SOC 2 Type II Compliance

Qovery is officially SOC 2 Type II compliant with an Unqualified Opinion. Get the highest assurance of continuously verified security controls for enterprise-grade application deployments and simplify due diligence.

Pierre Mavro
CTO & Co-founder
Product
Observability
 minutes
Troubleshoot Faster with the New Log Search and Filtering in Qovery Observe

Following the launch of Qovery Observe, we’re progressively adding new capabilities to help you better monitor, debug, and understand your applications. Today, we’re excited to announce a major improvement to the Logs experience: you can now search and filter directly within your application logs.

Alessandro Carrano
Lead Product Manager
Platform Engineering
DevOps
Terraform
7
 minutes
Top 5 Crossplane Alternatives & Competitors

Go beyond Crossplane. Discover Qovery, the #1 DevOps automation tool, and 4 other IaC alternatives (Terraform, Pulumi) for simplified multi-cloud infrastructure management and deployment.

Morgan Perry
Co-founder

It’s time to rethink
the way you do DevOps

Say goodbye to DevOps overhead. Qovery makes infrastructure effortless, giving you full control without the trouble.