{"id":2360,"date":"2026-07-24T00:35:31","date_gmt":"2026-07-23T17:35:31","guid":{"rendered":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/24\/how-to-create-a-kubernetes-deployment-a-step-by-step-guide\/"},"modified":"2026-07-24T00:35:31","modified_gmt":"2026-07-23T17:35:31","slug":"how-to-create-a-kubernetes-deployment-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/24\/how-to-create-a-kubernetes-deployment-a-step-by-step-guide\/","title":{"rendered":"How to Create a Kubernetes Deployment: A Step-by-Step Guide"},"content":{"rendered":"<h1>How to Create a Kubernetes Deployment: A Step-by-Step Guide<\/h1>\n<p>A Kubernetes Deployment is the most common way to run stateless applications in a cluster. It manages a set of identical Pods, handles rolling updates, and provides self-healing capabilities. In this tutorial, you will learn how to create a Deployment from scratch using the imperative and declarative approaches.<\/p>\n<p>Before you begin, ensure you have a running Kubernetes cluster (e.g., minikube or a cloud-based cluster) and <code>kubectl<\/code> installed. The following steps assume you are using the command line.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/via.placeholder.com\/800x600\/4a90d9\/ffffff?text=how%20to%20create%20a%20Kubernetes%20deployment\" alt=\"Article illustration\" style=\"display:block;margin:20px auto;max-width:100%;height:auto;border-radius:8px;\" \/><\/p>\n<h2>1. Define the Deployment Manifest<\/h2>\n<p>Every Deployment starts with a YAML file that defines its desired state. Create a file named <code>nginx-deployment.yaml<\/code> with this content:<\/p>\n<pre><code>apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: nginx-deployment\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: nginx\n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:1.21\n        ports:\n        - containerPort: 80<\/code><\/pre>\n<h3>Key Fields Explained<\/h3>\n<ul>\n<li><strong>replicas:<\/strong> Number of Pod replicas to run.<\/li>\n<li><strong>selector:<\/strong> Defines which Pods the Deployment manages by labels.<\/li>\n<li><strong>template:<\/strong> The Pod specification used to create new Pods.<\/li>\n<\/ul>\n<h2>2. Apply the Deployment<\/h2>\n<p>Use <code>kubectl apply<\/code> to create the Deployment in your cluster:<\/p>\n<pre><code>kubectl apply -f nginx-deployment.yaml<\/code><\/pre>\n<p>This command sends the manifest to the Kubernetes API server, which then creates the Deployment and its associated Pods.<\/p>\n<h2>3. Verify the Deployment<\/h2>\n<p>Check the status of your Deployment and its Pods:<\/p>\n<pre><code>kubectl get deployments\nkubectl get pods<\/code><\/pre>\n<h2>4. Update or Scale the Deployment<\/h2>\n<p>To change the number of replicas, edit the YAML file and re-apply, or use the imperative command:<\/p>\n<pre><code>kubectl scale deployment nginx-deployment --replicas=5<\/code><\/pre>\n<p>For a rolling update (e.g., change the image), modify the <code>image<\/code> field in the YAML and run <code>kubectl apply<\/code> again.<\/p>\n<p><strong>Conclusion:<\/strong> Creating a Kubernetes Deployment is straightforward once you understand the YAML structure. Use the declarative approach with a manifest file to keep your infrastructure as code, and leverage <code>kubectl<\/code> commands to manage your application lifecycle. Experiment with scaling and rolling updates to see Kubernetes\u2019 self-healing in action.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Create a Kubernetes Deployment: A Step-by-Step Guide A Kubernetes Deployment is the most common way to run stateless applications in a cluster. It manages a set of identical Pods, handles rolling updates, and provides self-healing capabilities. In this tutorial, you will learn how to create a Deployment from scratch using the imperative and &hellip; <\/p>\n","protected":false},"author":2716,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-2360","post","type-post","status-publish","format-standard","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/users\/2716"}],"replies":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/comments?post=2360"}],"version-history":[{"count":0,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2360\/revisions"}],"wp:attachment":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/media?parent=2360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/categories?post=2360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/tags?post=2360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}