이번 실습에서는 쿠버네티스의 핵심 리소스 관리와 Pod 생성부터 배포 전략, Docker 이미지 제작 및 푸시까지 다양한 내용을 다뤘습니다. 이 글에서는 실습 과정을 정리하고, 핵심 개념을 쉽게 이해할 수 있도록 설명드리겠습니다.
kubectl api-resources
쿠버네티스의 리소스들은 Object 형태의 클래스처럼 사용됩니다.
예: pods, services, deployments 등
kubectl create ns testns
kubectl get ns
Namespace는 리소스를 격리하여 관리할 수 있게 해줍니다.
YAML을 이용한 선언형 방식:
apiVersion: v1
kind: Namespace
metadata:
name: testns
삭제는 다음과 같이:
kubectl delete -f .
apiVersion: v1
kind: Pod
metadata:
name: mypod
namespace: testns
spec:
containers:
- name: myctn
image: nginx
kubectl apply -f testns.yml
kubectl get pod -n testns
kubectl logs mypod -n testns
kubectl describe pod mypod -n testns
kubectl port-forward mypod -n testns 8001:80
ps -ef | grep port-forward
kill -9 <PID>
kubectl exec -it mypod -n testns -- /bin/bash
내부 웹서버 테스트:
curl -s localhost | head -5
kubectl taint nodes node1 special=only:NoSchedule
apiVersion: v1
kind: Pod
metadata:
name: httpdpod
spec:
containers:
- name: httpdctn
image: httpd
tolerations:
- key: "special"
operator: "Equal"
value: "only"
effect: "NoSchedule"
nodeSelector:
kubernetes.io/hostname: node1
kubectl apply -f httpdpod.yml
kubectl get pod -o wide
kubectl taint node node1 special-
mkdir blue green
touch blue/{Dockerfile,index.html}
touch green/{Dockerfile,index.html}
docker build -t brian24/aws9:blue ./blue
docker build -t brian24/aws9:green ./green
docker push brian24/aws9:blue
docker push brian24/aws9:green
이번 실습에서는 쿠버네티스의 기본 오브젝트 구조를 이해하고, 실제 Pod를 만들고 관리하는 방법, taint와 toleration으로 노드 배치를 제어하는 방법, Docker 이미지를 직접 만들어 쿠버네티스에서 활용하는 방법까지 배웠습니다.
쿠버네티스는 선언형으로 리소스를 관리한다는 점이 핵심입니다.
Kubernetes 배포 기본 개념 및 실습 정리 (1) | 2025.04.15 |
---|---|
25.04.14. 쿠버네티스 Deployment 실습 정리 🚀 (0) | 2025.04.14 |
25.04.11. Kubernetes (1) | 2025.04.11 |
25.04.01. Docker Swarm && Kubenetes (0) | 2025.04.01 |
Docker Swarm 클러스터 설정 및 서비스 배포 흐름 정리 (1) | 2025.03.31 |