1. 매니페스트 생성 (nginx-pod.yaml)
apiVersion: v1
kind: Pod #Pod를 만들때는 apiVersion을 V1을 써야하는데 공식문서에서 이렇게 안내한다. 따로 이유를 알 필요는 없음
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80
imagePullPolicy: IfNotPresent
2. pod 시작
kubectl apply -f nginx-pod.yaml
3. 실행중인 pod 확인
kubectl get pods
4. pod 내부로 진입
kubectl exec -it nginx-pod -- bash
5. pod 포트 포워딩
kubectl port-forward pod/nginx-pod 80:80
6. pod 삭제
kubectl delete pod nginx-pod
7. pod 디버깅 할때
kubectl describe pod <pod-name> # Pod 상태 및 이슈 확인
kubectl logs <pod-name> -f # 실시간 로그 확인 (follow mode)
kubectl exec -it <pod-name> -- /bin/sh # Pod 내부 접근 (sh shell)
kubectl exec -it <pod-name> -- /bin/bash # Pod 내부 접근 (bash shell)
'DevOps > k8s' 카테고리의 다른 글
| Kubernetes에서 MySQL과 연동하여 볼륨(Persistent Volume) 사용하기 (0) | 2025.02.06 |
|---|---|
| 쿠버네티스 ConfigMap과 Secret 완벽 정리 (0) | 2025.02.05 |
| Kubernetes에서 Service란? (0) | 2025.02.04 |
| Docker + GitHub Actions 배포 vs 쿠버네티스 배포 비교 (0) | 2025.02.04 |
| Kubernetes Deployment를 사용하여 여러 개의 Pod 실행하기 (0) | 2025.02.04 |