Saturday, 15 November 2025

Kubernet - kubectl run nginx-demo --image=nginx vs minikube kubectl -- create deployment nginx-web --image=nginx

Both commands are used to start an Nginx container in a Kubernetes environment, but they differ significantly in what kind of resource they create and where they are intended to be executed.

Here is a breakdown of the two commands:


1. kubectl run nginx-demo --image=nginx

This command is the older, simpler approach to creating Pods directly, but its current function depends heavily on the version of Kubernetes you are using.

  • Primary Action (Modern Kubernetes v1.20+): By default, kubectl run creates a single Pod.

    • Resource Type: Pod.

    • Self-Healing: None. If the Pod crashes or the Node fails, it is not automatically recreated.

  • Intended Use: Running a single, short-lived Pod for testing, debugging, or troubleshooting.

FeatureDetails
Commandkubectl run nginx-demo --image=nginx
ResourcePod (typically)
PersistenceLow (no self-healing)
UsageQuick testing or troubleshooting

2. minikube kubectl -- create deployment nginx-web --image=nginx

This is the standard, modern way to run an application in Kubernetes. It creates a higher-level resource that ensures your application stays running.

  • Primary Action: It creates a Deployment resource.

    • Resource Type: Deployment (which manages a ReplicaSet, which manages Pods).

    • Self-Healing: Yes. The ReplicaSet ensures the desired number of Pods (default is 1) is always running. If a Pod crashes, a replacement is automatically created.

  • Intended Use: Running applications that need to be stable, persistent, and highly available (like a web server).

  • The minikube kubectl -- prefix is necessary here because you are running a standalone kubectl command through the minikube wrapper, as kubectl is not installed on your host system.

FeatureDetails
Commandminikube kubectl -- create deployment nginx-web --image=nginx
ResourceDeployment (Recommended for applications)
PersistenceHigh (has self-healing)
UsageRunning production-ready, stable applications

No comments:

Post a Comment

Building a Safer PostgreSQL CI/CD Pipeline with GitHub Actions: Dev → PR Review → Test Promotion

In my previous post, we explored a simple push-to-main deployment strategy . While functional, that model is not considered an industry best...