첫 번째 파드 배포
YAML 매니페스트와 `kubectl`을 사용하여 Kubernetes 클러스터에 간단한 애플리케이션을 파드로 정의하고 배포합니다.
첫 번째 파드 배포은(는) CoddyKit의 무료 Docker & Kubernetes for Developers 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Docker & Kubernetes for Developers 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Pods: Smallest K8s Unit
In Kubernetes, the smallest deployable unit is a Pod. Think of a Pod as a logical host for one or more containers.
While Docker deals with individual containers, Kubernetes orchestrates Pods. A Pod encapsulates application containers, storage resources, a unique network IP, and options that govern how containers run.
Why Pods, Not Just Containers?
Why do we need Pods when we already have containers?
- Shared Resources: Containers within the same Pod share the same network namespace and IP address. They can communicate using
localhost. - Co-location: Pods ensure that co-located containers (like an app and a helper 'sidecar') are always scheduled together on the same node.
- Abstraction: Pods provide an abstraction layer over individual containers, making orchestration simpler.
Anatomy of a Pod
A Pod is more than just a container. It includes:
- Application Containers: One or more containers (e.g., your app, a logging agent).
- Storage: Shared storage volumes for data persistence.
- Network: A unique IP address and network namespace.
- Configuration: Information on how to run the containers.
Pods are designed to be ephemeral. If a Pod dies, Kubernetes creates a new one (often managed by a higher-level object).
Defining Pods with YAML
Kubernetes resources, including Pods, are defined using YAML (YAML Ain't Markup Language) files. YAML is a human-readable data serialization standard.
These files act as blueprints, telling Kubernetes what you want to create and how.
Every Kubernetes object needs these top-level fields: apiVersion, kind, metadata, and spec.
Basic Pod YAML Structure
Let's look at the basic structure of a Pod definition in YAML:
apiVersion: v1
kind: Pod
metadata:
name: my-first-pod
labels:
app: webserver
spec:
containers:
- name: my-container
image: nginx:latest
ports:
- containerPort: 80Our First Pod: Nginx
We'll deploy a simple Nginx web server as our first Pod. Nginx is a popular open-source HTTP server.
This manifest describes a Pod named nginx-pod, running a single container based on the nginx:latest Docker image, exposing port 80.
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80Introducing `kubectl`
To interact with your Kubernetes cluster, you'll use the command-line tool called kubectl (pronounced "kube-control" or "kube-cuddle").
kubectl allows you to run commands against Kubernetes clusters, including deploying applications, inspecting and managing cluster resources, and viewing logs.
Ensure your kubectl is configured to point to your cluster.
Deploying Your Pod
Once you have your Pod definition in a YAML file (e.g., nginx-pod.yaml), you can deploy it to your Kubernetes cluster using the kubectl apply command.
This command tells Kubernetes to create or update resources based on the provided configuration.
Try running this:
kubectl apply -f nginx-pod.yamlChecking Pod Status
After deploying, you'll want to check if your Pod is running correctly. Use kubectl get pods to see a list of all Pods in the current namespace.
To get more detailed information about a specific Pod, use kubectl describe pod <pod-name>.
Pending: Pod accepted, but containers not yet created.Running: Pod has been bound to a node and all containers have been created.Error: At least one container terminated in failure.
kubectl get pods
kubectl describe pod nginx-podAccessing Pod Logs
When debugging applications inside your Pod, checking the container logs is crucial. Use the kubectl logs command to retrieve logs from a container within a Pod.
This helps you see what your application is doing or if any errors occurred during startup or runtime.
kubectl logs nginx-podPod Deployment Question
You've just learned how to define and deploy a Pod using YAML and kubectl. Imagine you've created my-app.yaml and deployed it.
Which command would you use to check the detailed status and events of your newly deployed Pod named my-app-pod?
Recap: Your First Pod
Congratulations! You've deployed your first Kubernetes Pod.
- Pods are the smallest deployable units in Kubernetes, encapsulating containers, storage, and network.
- You define Pods using YAML manifests with fields like
apiVersion,kind,metadata, andspec. - The
kubectlcommand-line tool is used to manage Kubernetes resources. - You deploy Pods with
kubectl apply -f <filename>, check status withkubectl get podsandkubectl describe pod, and view logs withkubectl logs.
Next, we'll explore how Deployments manage Pods at scale!
자주 묻는 질문
“첫 번째 파드 배포” 강의는 무료인가요?
네 — “첫 번째 파드 배포” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Docker & Kubernetes for Developers 강의 전체를 잠금 해제할 수 있습니다. Docker & Kubernetes for Developers 강의에는 총 4개의 강의가 포함되어 있습니다.
“첫 번째 파드 배포”에서 뭘 배우나요?
YAML 매니페스트와 `kubectl`을 사용하여 Kubernetes 클러스터에 간단한 애플리케이션을 파드로 정의하고 배포합니다. 브라우저에서 직접 실행하는 실습 코드로 Docker & Kubernetes for Developers을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Docker & Kubernetes for Developers을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Docker & Kubernetes for Developers은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“첫 번째 파드 배포” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Docker & Kubernetes for Developers 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Docker & Kubernetes for Developers 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.