Kubernetes Container Runtime 완벽 가이드! containerd와 CRI 구조 이해하기

Kubernetes에서 Pod와 Container가 실제로 실행되기 위해서는 Container Runtime이 필요합니다.

Scheduler가 실행 위치를 결정하고 kubelet이 실행 명령을 전달하면, 실제 Container 생성과 실행은 Container Runtime이 담당합니다.

예:

Pod 생성 요청

Scheduler Node 선택

kubelet 실행 요청

Container Runtime 호출

Container 생성

Kubernetes Architecture에서 Container Runtime은 Worker Node의 핵심 실행 계층입니다.

구성 요소역할
kubeletContainer 실행 요청
CRIRuntime 연결 표준
containerdContainer 실행
runc실제 Container 생성
Linux Kernel격리 환경 제공

Container Runtime 구조를 이해하면 Kubernetes에서 Container가 실제로 어떻게 실행되는지 이해할 수 있습니다.

Kubernetes Container Runtime이 필요한 이유

Kubernetes는 직접 Container를 실행하지 않습니다.

역할을 분리합니다.

Kubernetes:

“어떤 Container를 실행할지 관리”

Container Runtime:

“Container를 실제 실행”

이 구조를 통해 다양한 Runtime을 사용할 수 있습니다.

Kubernetes CRI(Container Runtime Interface)란?

CRI는 Kubernetes와 Container Runtime 사이의 표준 인터페이스입니다.

구조:

kubelet

CRI

Container Runtime

Container 실행

Kubernetes는 Runtime 내부 구현을 직접 알 필요 없이 CRI를 통해 통신합니다.

Kubernetes Container Runtime 구조

전체 실행 흐름:

API Server

↓

kubelet

↓

CRI

↓

containerd

↓

runc

↓

Linux Kernel

↓

Container

각 계층이 역할을 분리하여 관리합니다.

Kubernetes containerd란?

containerd는 현재 Kubernetes에서 가장 많이 사용하는 Container Runtime입니다.

특징:

  • CNCF 프로젝트
  • 경량 구조
  • 안정적인 운영
  • Docker와 동일한 기반 기술

Production Kubernetes 환경에서는 containerd 사용이 일반적입니다.

Docker와 containerd 관계

초기 Kubernetes에서는 Docker Engine을 많이 사용했습니다.

구조:

Docker Engine

containerd

runc

하지만 Kubernetes는 직접 Docker 기능이 필요하지 않았습니다.

현재:

kubelet

containerd

runc

구조로 운영됩니다.

Kubernetes runc 역할

runc는 실제 Container 실행을 담당하는 저수준 Runtime입니다.

역할:

  • Namespace 생성
  • Cgroup 설정
  • Process 실행
  • Container Isolation

Linux Kernel 기능을 이용하여 Container 환경을 만듭니다.

Kubernetes Container 실행 과정

예:

nginx Pod 생성

1단계:

kubectl apply

API Server 저장

2단계:

Scheduler Node 선택

3단계:

kubelet 전달

4단계:

CRI 호출

5단계:

containerd Image 확인

6단계:

runc Container 생성

7단계:

nginx 실행

이 과정이 Kubernetes Container 실행 흐름입니다.

Kubernetes Image와 Container Runtime 관계

Container Runtime은 Image를 기반으로 Container를 생성합니다.

구조:

Container Image

Image Pull

Filesystem Layer 생성

Container 생성

Process 실행

ImagePullBackOff 문제와 연결됩니다.

Kubernetes containerd 주요 명령어

Runtime 상태 확인:

systemctl status containerd

Container 목록 확인:

crictl ps

Image 확인:

crictl images

Kubernetes 환경에서는 Docker 명령보다 CRI 도구를 많이 사용합니다.

Kubernetes crictl이란?

crictl은 CRI 기반 Container 관리 도구입니다.

가능한 작업:

  • Container 확인
  • Image 확인
  • Log 확인
  • Runtime Debug

예:

crictl ps

현재 실행 중인 Container를 확인합니다.

Kubernetes Container Runtime과 Namespace

Container 격리는 Linux Namespace를 사용합니다.

제공:

  • Process Isolation
  • Network Isolation
  • Filesystem Isolation

여러 Container가 같은 Kernel을 사용하지만 독립 환경처럼 동작합니다.

Kubernetes Container Runtime과 Cgroups

Cgroups는 Resource 제한을 담당합니다.

관리:

  • CPU
  • Memory
  • Block I/O

예:

Container Memory Limit 설정

Cgroup 적용

사용량 제한

OOMKilled 문제와 연결됩니다.

Kubernetes Runtime 장애 분석

Container 실행 문제가 발생하면 확인합니다.

Runtime 상태 확인

systemctl status containerd

Runtime Log 확인

journalctl -u containerd

Container 확인

crictl ps

장애 원인을 분석합니다.

Kubernetes Container Runtime 장애 원인

대표 원인:

원인설명
Runtime 중지Container 실행 불가
Image 문제Pull 실패
Disk 부족Layer 저장 실패
Permission 오류실행 실패
CRI 연결 오류kubelet 통신 실패

Worker Node 장애 분석에서 중요합니다.

Kubernetes Container Runtime과 Storage

Container Runtime은 Image Layer를 저장합니다.

구조:

Image Layer

Container Storage

Node Disk

Disk 부족 발생:

Container 생성 실패

따라서 Disk 관리가 필요합니다.

Kubernetes Container Runtime 보안

Runtime 보안 관리:

  • Image 검증
  • Runtime 업데이트
  • Root 권한 제한
  • Seccomp 적용
  • AppArmor 적용

Container Security와 연결됩니다.

Kubernetes Container Runtime Monitoring

운영 환경에서는 Runtime 상태를 확인합니다.

Metric:

  • Container Count
  • Image Pull 시간
  • Runtime Error
  • CPU / Memory 사용량

Prometheus Monitoring과 연결합니다.

Kubernetes Container Runtime 운영 전략

Production 환경:

containerd 안정화

Image 관리

Disk Monitoring

Runtime Update

Security 적용

안정적인 Container 운영 환경을 구축합니다.

Kubernetes Container Runtime 장점

장점설명
표준화CRI 기반 구조
확장성Runtime 선택 가능
안정성Production 검증
효율성경량 실행 구조

Container Runtime은 Kubernetes 실행 기반입니다.

자주 묻는 질문

Kubernetes에서 Docker를 사용할 수 없나요?

현재 Kubernetes에서는 Docker Engine 대신 containerd 같은 CRI Runtime 사용이 일반적입니다.

containerd와 Docker의 차이는 무엇인가요?

Docker는 개발자 도구와 관리 기능을 포함하고, containerd는 Container 실행에 집중한 Runtime입니다.

Container Runtime 장애가 발생하면 어떻게 되나요?

해당 Node의 Pod 실행과 Container 관리에 문제가 발생할 수 있습니다.

마무리

Kubernetes Container Runtime은 kubelet 요청을 받아 실제 Container를 실행하는 Worker Node 핵심 계층입니다.

구성 요소역할
CRI통신 표준
containerdContainer 관리
runc실제 실행
Linux Kernel격리 제공

Container Runtime 구조를 이해하면 Kubernetes Pod 실행 과정과 Worker Node 동작 원리를 완벽하게 이해할 수 있습니다.

다음 글에서는 Kubernetes Network 동작의 핵심 Component인 Kubernetes kube-proxy 완벽 가이드! Service Network와 Traffic Routing 구조 이해하기를 진행하겠습니다.

댓글 남기기