0Pricing
Docker & Kubernetes for Developers · 강의

Kubernetes Deployment 이해

Deployment가 애플리케이션의 원하는 상태를 관리하여 롤링 업데이트와 롤백을 가능하게 하는 방식을 학습합니다.

Kubernetes Deployment 이해은(는) CoddyKit의 무료 Docker & Kubernetes for Developers 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Docker & Kubernetes for Developers 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

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!

자주 묻는 질문

“Kubernetes Deployment 이해” 강의는 무료인가요?

네 — “Kubernetes Deployment 이해” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Docker & Kubernetes for Developers 강의 전체를 잠금 해제할 수 있습니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.

“Kubernetes Deployment 이해”에서 뭘 배우나요?

Deployment가 애플리케이션의 원하는 상태를 관리하여 롤링 업데이트와 롤백을 가능하게 하는 방식을 학습합니다. 브라우저에서 직접 실행하는 실습 코드로 Docker & Kubernetes for Developers을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Docker & Kubernetes for Developers을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Docker & Kubernetes for Developers은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“Kubernetes Deployment 이해” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Docker & Kubernetes for Developers 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Docker & Kubernetes for Developers 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Kubernetes Deployment 이해
  2. Service를 활용한 애플리케이션 노출
  3. 애플리케이션 확장 및 자동 복구
  4. 롤링 업데이트 및 롤백
← Docker & Kubernetes for Developers(으)로 돌아가기