0Pricing
Docker & Kubernetes for Developers · Ders

Kubernetes dağıtımlarını anlama

Dağıtımların uygulamanızın istenen durumunu nasıl yönettiğini, aşamalı güncellemeleri ve geri almaları nasıl etkinleştirdiğini öğrenin.

Kubernetes dağıtımlarını anlama, CoddyKit'te ücretsiz bir Docker & Kubernetes for Developers dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Docker & Kubernetes for Developers öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Docker & Kubernetes for Developers kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Meet Kubernetes Deployments

Welcome to the world of Kubernetes Deployments! After learning about Pods, you might wonder how to manage many identical Pods reliably.

Deployments are a powerful Kubernetes resource that helps you declare and manage the desired state of your applications.

Why Deployments are Essential

Imagine running a web server. You need multiple copies (replicas) for high availability and to handle traffic. If one crashes, you need another to take its place.

Deployments automate these tasks:

  • Self-Healing: Replaces failed Pods automatically.
  • Scaling: Easily adjust the number of Pod replicas.
  • Updates: Perform rolling updates without downtime.
  • Rollbacks: Revert to previous versions if something goes wrong.

Desired State in Action

The core concept behind a Deployment is its desired state. You tell Kubernetes what you want your application to look like, and it works to make it happen.

For example, if you say "I want 3 Nginx Pods running version 1.21," the Deployment will ensure exactly 3 Pods with Nginx 1.21 are running, even if some fail.

Deployments and ReplicaSets

Under the hood, Deployments use another Kubernetes resource called a ReplicaSet.

  • A ReplicaSet ensures a specified number of Pod replicas are running at all times.
  • When you create a Deployment, it automatically creates a ReplicaSet.
  • When you update a Deployment, it creates a new ReplicaSet and gracefully scales down the old one while scaling up the new one.

Building a Deployment Manifest

Like most Kubernetes resources, Deployments are defined using YAML. Key fields include:

  • apiVersion: apps/v1 (for Deployments)
  • kind: Deployment
  • metadata: Name, labels to identify the Deployment.
  • spec:
    • replicas: The desired number of Pods.
    • selector: How the Deployment finds its Pods (using labels).
    • template: The Pod definition (just like a standalone Pod YAML!).

Example: Nginx Deployment

Let's create a simple Deployment for Nginx. This YAML specifies 3 replicas of an Nginx web server.

You would typically save this as nginx-deployment.yaml and apply it using kubectl apply -f nginx-deployment.yaml.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.21.6
        ports:
        - containerPort: 80

Checking Deployment Status

Once you've applied your Deployment, you can check its status using kubectl commands:

  • kubectl get deployments: Shows a summary of your deployments.
  • kubectl get pods -l app=nginx: See the Pods managed by your Nginx deployment.
  • kubectl describe deployment nginx-deployment: Get detailed information, including events and associated ReplicaSets.

Seamless App Updates

One of the best features of Deployments is rolling updates. This allows you to update your application version without downtime.

When you change the image or configuration in your Deployment's YAML, Kubernetes:

  1. Creates new Pods with the updated version.
  2. Gradually terminates old Pods as new ones become ready.

This ensures your application remains available throughout the update process.

Performing a Rolling Update

Let's update our Nginx Deployment to a newer version. You would edit your nginx-deployment.yaml file and change the image to nginx:1.22.1.

Then, apply the changes: kubectl apply -f nginx-deployment.yaml. Kubernetes will perform a rolling update!

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.22.1 # Changed from 1.21.6
        ports:
        - containerPort: 80

Reverting Changes

Sometimes an update goes wrong. Deployments allow you to easily rollback to a previous stable version.

Kubernetes keeps a history of your Deployments' revisions. You can see this history and revert to an earlier state if needed, minimizing the impact of bad deployments.

  • kubectl rollout history deployment nginx-deployment: View past revisions.
  • kubectl rollout undo deployment nginx-deployment --to-revision=1: Revert to a specific revision.

Deployment Knowledge Check

You've learned about the power of Kubernetes Deployments!

Which of the following capabilities is NOT directly provided by a Kubernetes Deployment?

Deployment Power-Up!

Congratulations! You've successfully understood Kubernetes Deployments.

We covered:

  • What Deployments are and why they are crucial for managing applications.
  • The concept of desired state and how Deployments use ReplicaSets.
  • How to create, inspect, update, and rollback Deployments.

Next, we'll explore how to make your applications accessible using Kubernetes Services!

Sıkça Sorulan Sorular

“Kubernetes dağıtımlarını anlama” dersi ücretsiz mi?

Evet — “Kubernetes dağıtımlarını anlama” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Docker & Kubernetes for Developers kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Docker & Kubernetes for Developers kursu toplamda 4 dersten oluşur.

“Kubernetes dağıtımlarını anlama” dersinde ne öğreneceğim?

Dağıtımların uygulamanızın istenen durumunu nasıl yönettiğini, aşamalı güncellemeleri ve geri almaları nasıl etkinleştirdiğini öğrenin. Docker & Kubernetes for Developers ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Docker & Kubernetes for Developers öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Docker & Kubernetes for Developers, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.

“Kubernetes dağıtımlarını anlama” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Docker & Kubernetes for Developers dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Docker & Kubernetes for Developers dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Kubernetes dağıtımlarını anlama
  2. Hizmetlerle uygulamaları dışa açma
  3. Uygulamaları ölçeklendirme ve kendi kendine iyileştirme
  4. Aşamalı Güncellemeler ve Geri Alımlar
← Docker & Kubernetes for Developers Sayfasına Dön