java
CHAPTER 96 / 99
읽기 약 2분
FUNCTION
컨테이너 오케스트레이션: K8s 기초
핵심 개념
Pod·Service·Deployment·ConfigMap·kubectl — Spring Boot 앱 K8s 배포.
본문
K8s 핵심 개념
Pod: 컨테이너 1+ 묶음 (가장 작은 배포 단위)
ReplicaSet: Pod 복제본 관리
Deployment: 선언적 업데이트·롤백
Service: 네트워크 추상화 (안정적 endpoint)
Ingress: 외부 트래픽 라우팅
ConfigMap/Secret: 설정·시크릿 분리
Namespace: 논리적 격리Deployment
# ohs-backend-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ohs-backend
labels:
app: ohs-backend
spec:
replicas: 3
selector:
matchLabels:
app: ohs-backend
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: ohs-backend
spec:
containers:
- name: app
image: myorg/ohs-backend:1.0.0
ports:
- containerPort: 8080
env:
- name: SPRING_PROFILES_ACTIVE
value: prod
- name: DB_URL
valueFrom:
secretKeyRef:
name: ohs-secrets
key: db-url
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "1000m"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 60
periodSeconds: 10
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 30
periodSeconds: 5Service
apiVersion: v1
kind: Service
metadata:
name: ohs-backend
spec:
type: ClusterIP # 내부만 (Pod IP는 변하므로 안정적 endpoint)
ports:
- port: 80
targetPort: 8080
selector:
app: ohs-backendIngress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ohs-ingress
annotations:
cert-manager.io/cluster-issuer: letsencrypt
spec:
tls:
- hosts:
- api.openhyperstep.com
secretName: ohs-tls
rules:
- host: api.openhyperstep.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ohs-backend
port:
number: 80ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: ohs-config
data:
application.yml: |
server:
port: 8080
spring:
jpa:
hibernate:
ddl-auto: validateSecret
# Secret 생성
kubectl create secret generic ohs-secrets \
--from-literal=db-password=mypassword \
--from-literal=jwt-secret=$(openssl rand -base64 32)kubectl 기본 명령
# 적용
kubectl apply -f deployment.yml
# 조회
kubectl get pods
kubectl get svc
kubectl get deployments
# 상세
kubectl describe pod <pod-name>
# 로그
kubectl logs <pod-name>
kubectl logs -f deployment/ohs-backend
# 디버깅
kubectl exec -it <pod-name> -- /bin/sh
# 스케일
kubectl scale deployment ohs-backend --replicas=5
# 롤링 업데이트
kubectl set image deployment/ohs-backend app=myorg/ohs-backend:1.1.0
# 롤백
kubectl rollout undo deployment/ohs-backend
# 삭제
kubectl delete -f deployment.ymlHorizontal Pod Autoscaler
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: ohs-backend-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ohs-backend
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70다음 챕터
CH.28 "Helm 차트" — K8s 패키지 관리.
AI 프롬프트
🤖 AI에게 잘 물어보는 법 — 모델·전략별 프롬프트
Claude
무료: Sonnet 4.6 / Pro $20/mo: Opus 4.6
내 Spring 코드의 Kubernetes 기초 부분을 분석해서 리소스 limit·probe 적정성와 개선 우선순위를 알려줘.
ChatGPT
무료: GPT-5.5 / Plus $20/mo: GPT-5.5 Pro
Kubernetes 기초 vs 다른 패턴 비교를 실전 사례 5개로 보여주고 K8s vs ECS vs Cloud Run를 알려줘.
Gemini
무료: 2.5 Flash / Pro $19.99/mo: 3.1 Pro
내 코드베이스 전체를 분석해서 Kubernetes 기초 관련 잘못된 배포 설정를 보고해줘.
Grok
무료: Grok 4.1 / SuperGrok $30/mo
2026년 한국 기업의 Kubernetes 기초 채택률과 한국 IT의 K8s 채택률를 솔직히 알려줘.
⭐ 이것만 기억하세요
컨테이너 오케스트레이션: K8s 기초는 이 3가지만 확실히 잡으세요
1.K8s = Pod + Deployment + Service + Ingress 4종으로 대부분 시나리오
2.liveness/readiness probe + 리소스 limit + HPA = 안정적 운영
3.다음 챕터 CH.28에서 Helm — K8s 매니페스트 패키지화
공유하기
진행도 96 / 99